code stringlengths 12 2.05k | label_name stringlengths 6 8 | label int64 0 95 |
|---|---|---|
def include_allowed?(target, reader)
doc = reader.document
return false if doc.safe >= ::Asciidoctor::SafeMode::SECURE
return false if doc.attributes.fetch('max-include-depth', 64).to_i < 1
return false if target_uri?(target) && !doc.attributes.key?('allow-uri-read')
true
end | CWE-78 | 6 |
def validate_each(record, attribute, value)
adapter = Paperclip.io_adapters.for(value)
if Paperclip::MediaTypeSpoofDetector.using(adapter, value.original_filename).spoofed?
record.errors.add(attribute, :spoofed_media_type)
end
end | CWE-79 | 1 |
def self.get_copies_folder(user_id)
my_folder = User.get_my_folder(user_id)
unless my_folder.nil?
con = "(parent_id=#{my_folder.id}) and (name='#{Item.copies_folder}')"
begin
copies_folder = Folder.where(con).first
rescue
end
if copies_folder.nil?
folder = Fold... | CWE-89 | 0 |
def verify_signature(string, signature)
if signature.nil?
fail InvalidSignature, "missing \"signature\" param"
elsif signature != generate_signature(string)
fail InvalidSignature, "provided signature does not match the calculated signature"
end
end | CWE-203 | 38 |
def create
Log.add_info(request, params.inspect)
if params[:thetisBoxEdit].nil? or params[:thetisBoxEdit].empty?
@group = nil
else
@group = Group.new
@group.name = params[:thetisBoxEdit]
@group.parent_id = params[:selectedGroupId]
@group.save!
@group.create_group_fol... | CWE-89 | 0 |
def test_execute_details_cleans_text
spec_fetcher do |fetcher|
fetcher.spec 'a', 2 do |s|
s.summary = 'This is a lot of text. ' * 4
s.authors = ["Abraham Lincoln \u0001", "\u0002 Hirohito"]
s.homepage = "http://a.example.com/\u0003"
end
fetcher.legacy_platform
end
... | CWE-94 | 14 |
def team_organize
Log.add_info(request, params.inspect)
team_id = params[:team_id]
unless team_id.blank?
begin
@team = Team.find(team_id)
rescue
@team = nil
ensure
if @team.nil?
flash[:notice] = t('msg.already_deleted', :name => Team.model_name.human)
... | CWE-89 | 0 |
def verify_signature(jwt)
head = token_head(jwt)
# Make sure the algorithm is supported and get the decode key.
if head[:alg] == 'RS256'
[rs256_decode_key(head[:kid]), head[:alg]]
elsif head[:alg] == 'HS256'
[@client_secret, head[:alg]]
else
r... | CWE-347 | 25 |
def update_by_ajax
Log.add_info(request, params.inspect)
cat_h = {:desktop => User::AUTH_DESKTOP, :user => User::AUTH_USER, :log => User::AUTH_LOG}
yaml = ApplicationHelper.get_config_yaml
cat_h.keys.each do |cat|
next if params[cat].nil? or params[cat].empty?
unless @login_user.admin... | CWE-89 | 0 |
def html_postprocess(_field, html)
helper = ContentTextHelpers.new
helper.sanitize(helper.auto_link(html))
end | CWE-94 | 14 |
def get_auth_teams
Log.add_info(request, params.inspect)
begin
@folder = Folder.find(params[:id])
rescue
@folder = nil
end
target_user_id = (@login_user.admin?(User::AUTH_TEAM))?(nil):(@login_user.id)
@teams = Team.get_for(target_user_id, true)
session[:folder_id] = params[:... | CWE-89 | 0 |
def setup
@namespace = "theplaylist"
@store = Redis::Store.new :namespace => @namespace, :marshalling => false # TODO remove mashalling option
@client = @store.instance_variable_get(:@client)
@rabbit = "bunny"
@default_store = Redis::Store.new
@other_namespace = 'other'
@other_store = Red... | CWE-502 | 15 |
def test_should_allow_anchors
assert_sanitized %(<a href="foo" onclick="bar"><script>baz</script></a>), %(<a href=\"foo\"></a>)
end
def test_video_poster_sanitization
assert_sanitized %(<video src="videofile.ogg" autoplay poster="posterimage.jpg"></video>), %(<video src="videofile.ogg" poster="posterima... | CWE-79 | 1 |
def self.from(stream)
header = stream.read 512
empty = (header == "\0" * 512)
fields = header.unpack UNPACK_FORMAT
new :name => fields.shift,
:mode => fields.shift.oct,
:uid => fields.shift.oct,
:gid => fields.shift.oct,
:size => fields.shift.oct... | CWE-835 | 42 |
def check_owner
return if params[:id].nil? or params[:id].empty? or @login_user.nil?
email = Email.find(params[:id])
if !@login_user.admin?(User::AUTH_MAIL) and email.user_id != @login_user.id
Log.add_check(request, '[check_owner]'+request.to_s)
flash[:notice] = t('msg.need_to_be_owner')
... | CWE-89 | 0 |
def show
Log.add_info(request, params.inspect)
@group_id = params[:group_id]
official_title_id = params[:id]
unless official_title_id.nil? or official_title_id.empty?
@official_title = OfficialTitle.find(official_title_id)
end
render(:layout => (!request.xhr?))
end | CWE-89 | 0 |
it 'is possible to return hash errors in jsonapi format' do
get '/'
expect(['{"error":"rain!","detail":"missing widget"}',
'{"detail":"missing widget","error":"rain!"}']).to include(last_response.body)
end | CWE-79 | 1 |
it "handles Symbol keys" do
cl = subject.build_command_line("true", :abc => "def")
expect(cl).to eq "true --abc def"
end | CWE-78 | 6 |
def index
valid_http_methods :get, :post, :put
# for permission check
if params[:package] and not ["_repository", "_jobhistory"].include?(params[:package])
pkg = DbPackage.get_by_project_and_name( params[:project], params[:package], use_source=false )
else
prj = DbProject.get_by_name para... | CWE-434 | 5 |
def calculated_media_type
@calculated_media_type ||= calculated_content_type.split("/").first
end | CWE-79 | 1 |
def properly_encode(fragment, options)
fragment.xml? ? fragment.to_xml(options) : fragment.to_html(options)
end | CWE-79 | 1 |
def comment_link(uniqueid, data)
comment = comment_for_type(data)
i18n_key = data[:cutoff] ? 'truncated' : 'full'
notification = t(
"notifications.comment.#{i18n_key}",
name: data[:user],
comment: strip_tags(data[:comment]),
typename: data[:typename]
)
notification_link(uni... | CWE-79 | 1 |
def deliver!(mail)
if ::File.respond_to?(:makedirs)
::File.makedirs settings[:location]
else
::FileUtils.mkdir_p settings[:location]
end
mail.destinations.uniq.each do |to|
::File.open(::File.join(settings[:location], to), 'a') { |f| "#{f.write(mail.encoded)}\r\n\r\n... | CWE-22 | 2 |
it "handles Symbol keys with underscore and tailing '='" do
cl = subject.build_command_line("true", :abc_def= => "ghi")
expect(cl).to eq "true --abc-def=ghi"
end | CWE-78 | 6 |
def set_auth_teams
Log.add_info(request, params.inspect)
@folder = Folder.find(params[:id])
if Folder.check_user_auth(@folder.id, @login_user, 'w', true)
read_teams = []
write_teams = []
teams_auth = params[:teams_auth]
unless teams_auth.nil?
teams_auth.each do |auth_para... | CWE-89 | 0 |
def filename_from_header
return nil unless file.meta.include? 'content-disposition'
match = file.meta['content-disposition'].match(/filename=(?:"([^"]+)"|([^";]+))/)
return nil unless match
match[1].presence || match[2].presence
end | CWE-918 | 16 |
def check_owner
return if (params[:id].nil? or params[:id].empty? or @login_user.nil?)
address = Address.find(params[:id])
if !@login_user.admin?(User::AUTH_ADDRESSBOOK) and address.owner_id != @login_user.id
Log.add_check(request, '[check_owner]'+request.to_s)
flash[:notice] = t('msg.need... | CWE-89 | 0 |
def make_rs256_token(payload = nil)
payload = { sub: 'abc123' } if payload.nil?
JWT.encode payload, rsa_private_key, 'RS256', kid: jwks_kid
end | CWE-347 | 25 |
def remove_application(users)
return if users.nil? or users.empty?
array = ["(xtype='#{Comment::XTYPE_APPLY}')"]
array << "(item_id=#{self.item_id})"
user_con_a = []
users.each do |user_id|
user_con_a << "(user_id=#{user_id})"
end
array << '(' + user_con_a.join(' or ') + ')'
... | CWE-89 | 0 |
it "returns default error message for spoofed media type" do
build_validator
file = File.new(fixture_file("5k.png"), "rb")
@dummy.avatar.assign(file)
detector = mock("detector", :spoofed? => true)
Paperclip::MediaTypeSpoofDetector.stubs(:using).returns(detector)
@validator.validate(@dummy)
... | CWE-79 | 1 |
def self.open(path_or_url, ext = nil, options = {})
options, ext = ext, nil if ext.is_a?(Hash)
ext ||=
if File.exist?(path_or_url)
File.extname(path_or_url)
else
File.extname(URI(path_or_url).path)
end
ext.sub!(/:.*/, '') # hack for filenames or URLs t... | CWE-78 | 6 |
def self.exists_copies_folder?(user_id)
my_folder = User.get_my_folder(user_id)
unless my_folder.nil?
con = "(parent_id=#{my_folder.id}) and (name='#{Item.copies_folder}')"
begin
copies_folder = Folder.where(con).first
rescue
end
end
return !copies_folder.nil?
end | CWE-89 | 0 |
def get_group_equipment
Log.add_info(request, params.inspect)
@group_id = nil
if !params[:thetisBoxSelKeeper].nil?
@group_id = params[:thetisBoxSelKeeper].split(':').last
elsif !params[:group_id].nil? and !params[:group_id].empty?
@group_id = params[:group_id]
end
submit_url = ur... | CWE-89 | 0 |
def self.execute_action_move(mail_filter, email, val)
mail_folder_id = val
mail_folder = MailFolder.find_by_id(mail_folder_id)
if !mail_folder.nil? and (mail_folder.user_id == email.user_id)
email.update_attribute(:mail_folder_id, mail_folder_id)
end
return true
end | CWE-89 | 0 |
it 'sets file extension based on content-type if missing' do
expect(subject.original_filename).to eq "test.jpeg"
end | CWE-918 | 16 |
def self.using(file, name)
new(file, name)
end | CWE-79 | 1 |
def accepts?(env)
session = session env
token = session[:csrf] ||= session['_csrf_token'] || random_string
safe?(env) ||
env['HTTP_X_CSRF_TOKEN'] == token ||
Request.new(env).params[options[:authenticity_param]] == token
end | CWE-203 | 38 |
def self.destroy_by_user(user_id, add_con=nil)
SqlHelper.validate_token([user_id])
con = "user_id=#{user_id}"
con << " and (#{add_con})" unless add_con.nil? or add_con.empty?
emails = Email.where(con).to_a
emails.each do |email|
email.destroy
end
end | CWE-89 | 0 |
def sanitize(html, options = {})
return unless html
return html if html.empty?
Loofah.fragment(html).tap do |fragment|
remove_xpaths(fragment, XPATHS_TO_REMOVE)
end.text(options)
end | CWE-79 | 1 |
it 'should return nil if the key ID is invalid' do
expect(jwt_validator.jwks_key(:alg, "#{jwks_kid}_invalid")).to eq(nil)
end | CWE-347 | 25 |
it 'returns all campaigns belonging to the inbox to administrators' do
# create a random campaign
create(:campaign, account: account)
get "/api/v1/accounts/#{account.id}/inboxes/#{inbox.id}/campaigns",
headers: administrator.create_new_auth_token,
as: :json
... | CWE-79 | 1 |
def format_object(object, html=true, &block)
if block_given?
object = yield object
end
case object.class.name
when 'Array'
object.map {|o| format_object(o, html)}.join(', ').html_safe
when 'Time'
format_time(object)
when 'Date'
format_date(object)
when 'Fixnum'
... | CWE-79 | 1 |
def html_message
key = keys.last.to_s.gsub('_', ' ').gsub(/\b('?[a-z])/) { $1.capitalize }
%(<span class="translation_missing" title="translation missing: #{keys.join('.')}">#{key}</span>) | CWE-79 | 1 |
def unfolded_header
@unfolded_header ||= unfold(raw_source)
end | CWE-93 | 33 |
def self.destroy_by_user(user_id, add_con=nil)
SqlHelper.validate_token([user_id])
con = "user_id=#{user_id}"
con << " and (#{add_con})" unless add_con.nil? or add_con.empty?
mail_accounts = MailAccount.where(con).to_a
mail_accounts.each do |mail_account|
mail_account.destroy
end
en... | CWE-89 | 0 |
it 'supports passing read options to RMagick' do
expect_any_instance_of(::Magick::Image::Info).to receive(:density=).with(10)
expect_any_instance_of(::Magick::Image::Info).to receive(:size=).with("200x200")
instance.manipulate! :read => {
:density => 10,
:size => %{"200x200"}
... | CWE-94 | 14 |
it "sanitizes Fixnum array param value" do
cl = subject.build_command_line("true", nil => [1])
expect(cl).to eq "true 1"
end | CWE-78 | 6 |
def get_group_users
Log.add_info(request, params.inspect)
@group_id = nil
if !params[:thetisBoxSelKeeper].nil?
@group_id = params[:thetisBoxSelKeeper].split(':').last
elsif !params[:group_id].nil? and !params[:group_id].empty?
@group_id = params[:group_id]
end
submit_url = url_fo... | CWE-89 | 0 |
def split_header
self.fields = unfolded_header.split(CRLF)
end | CWE-93 | 33 |
it "converts the comment markup to HTML" do
expect(comment.generate_html(:body)).to match(%r{<em>italic</em>})
expect(comment.generate_html(:body)).to match(%r{<strong>bold</strong>})
end | CWE-79 | 1 |
def new_ally_request_link(uniqueid, data)
link = "/profile?uid=#{data[:uid]}"
link_html = "<a href=\"#{link}\">#{data[:user]}</a>"
# rubocop:disable Layout/LineLength
"<div id=\"#{uniqueid}\"><div>#{t('notifications.ally.sent_html', link_to_user: link_html)}</div>#{request_actions(data[:user_id])}</di... | CWE-79 | 1 |
def target_uri?(target)
::Asciidoctor::Helpers.uriish?(target)
end | CWE-78 | 6 |
it 'should return an x5c key' do
expect(jwt_validator.jwks_key(:x5c, jwks_kid).length).to eq(1)
end | CWE-347 | 25 |
def file_list io # :nodoc:
header = String.new
read_until_dashes io do |line|
header << line
end
YAML.load header
end | CWE-502 | 15 |
def do_execute
Log.add_info(request, params.inspect)
mail_account = MailAccount.find_by_id(params[:mail_account_id])
mail_folder = MailFolder.find_by_id(params[:mail_folder_id])
if mail_account.user_id != @login_user.id \
or mail_folder.user_id != @login_user.id
render(:text => t('msg.... | CWE-89 | 0 |
def rename_title
Log.add_info(request, params.inspect)
org_title = params[:org_title]
new_title = params[:new_title]
if org_title.nil? or new_title.nil? or org_title == new_title
render(:partial => 'ajax_title', :layout => false)
return
end
titles = User.get_config_titles
un... | CWE-89 | 0 |
def stub_dummy_jwks
stub_request(:get, 'https://example.org/.well-known/jwks.json')
.to_return(
headers: { 'Content-Type' => 'application/json' },
body: rsa_token_jwks,
status: 200
)
end | CWE-347 | 25 |
it 'should escape the content of removed `plaintext` elements' do
Sanitize.fragment('<plaintext>hello! <script>alert(0)</script>')
.must_equal 'hello! <script>alert(0)</script>'
end | CWE-79 | 1 |
def sanitize_string(host)
if host.start_with?(".")
/\A(.+\.)?#{Regexp.escape(host[1..-1])}\z/i
else
/\A#{Regexp.escape host}\z/i
end
end | CWE-601 | 11 |
def paginate_by_sql(model, sql, per_page, options={})
if options[:count]
if options[:count].is_a?(Integer)
total = options[:count]
else
total = model.count_by_sql(options[:count])
end
else
total = model.count_by_sql_wrapping_select_query(sql)
end
object_pages =... | CWE-89 | 0 |
def team_organize
Log.add_info(request, params.inspect)
team_id = params[:team_id]
unless team_id.blank?
begin
@team = Team.find(team_id)
rescue
@team = nil
ensure
if @team.nil?
flash[:notice] = t('msg.already_deleted', :name => Team.model_name.human)
... | CWE-89 | 0 |
def test_sanitize_script
assert_sanitized "a b c<script language=\"Javascript\">blah blah blah</script>d e f", "a b cd e f"
end | CWE-79 | 1 |
def create
Log.add_info(request, params.inspect)
parent_id = params[:selectedFolderId]
unless Folder.check_user_auth(parent_id, @login_user, 'w', true)
flash[:notice] = 'ERROR:' + t('folder.need_auth_to_modify')
render(:partial => 'ajax_folder_entry', :layout => false)
return
end
... | CWE-89 | 0 |
def meeting_link(uniqueid, data)
notification = t(
"notifications.meeting.#{data[:type]}",
name: data[:user],
group_name: data[:group],
meeting_name: data[:typename]
)
link = specific_meeting_link(data[:type], data[:typeid], data[:group_id])
notification_link(uniqueid, link, no... | CWE-79 | 1 |
def _process_user_attrs(user, attrs)
if attrs[:birthday].nil?
begin
attrs[:birthday] = attrs[:birthday_y] + '-' + attrs[:birthday_m] + '-' + attrs[:birthday_d]
rescue
end
attrs.delete(:birthday_y)
attrs.delete(:birthday_m)
attrs.delete(:birthday_d)
end
if !att... | CWE-89 | 0 |
def unfold(string)
string.gsub(/#{CRLF}#{WSP}+/, ' ').gsub(/#{WSP}+/, ' ')
end | CWE-93 | 33 |
def activity_user
user = current_user.pref[:activity_user]
if user && user != "all_users"
user = if user =~ /@/ # email
User.where(:email => user).first
else # first_name middle_name last_name any_name
name_query = if user.include?(" ")
user.name_permutations.map{... | CWE-89 | 0 |
def html_postprocess(_field, html)
html
end | CWE-79 | 1 |
def setup
@store = Redis::Store.new :marshalling => true
@rabbit = OpenStruct.new :name => "bunny"
@white_rabbit = OpenStruct.new :color => "white"
@store.set "rabbit", @rabbit
@store.del "rabbit2"
end | CWE-502 | 15 |
def self.save_group_value(group_id, category, key, value)
SqlHelper.validate_token([group_id, category, key])
con = []
con << "(group_id=#{group_id})"
con << "(category='#{category}')"
con << "(xkey='#{key}')"
setting = Setting.where(con.join(' and ')).first
if value.nil?
unless ... | CWE-89 | 0 |
it "with params as nil" do
cl = subject.build_command_line("true", nil)
expect(cl).to eq "true"
end | CWE-78 | 6 |
def send_password
Log.add_info(request, params.inspect)
mail_addr = params[:thetisBoxEdit]
SqlHelper.validate_token([mail_addr], ['@-'])
begin
users = User.where("email='#{mail_addr}'").to_a
rescue => evar
end
if users.nil? or users.empty?
Log.add_error(request, evar)
f... | CWE-89 | 0 |
def quote_column_name(name) #:nodoc:
@quoted_column_names[name] ||= "`#{name}`"
end | CWE-89 | 0 |
def ffi_lib(*names)
raise LoadError.new("library names list must not be empty") if names.empty?
lib_flags = defined?(@ffi_lib_flags) ? @ffi_lib_flags : FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL
ffi_libs = names.map do |name|
if name == FFI::CURRENT_PROCESS
... | CWE-426 | 70 |
def authenticate(*credentials, &block)
raise ArgumentError, 'at least 2 arguments required' if credentials.size < 2
if credentials[0].blank?
return authentication_response(return_value: false, failure: :invalid_login, &block)
end
if @sorcery_config.downcase_username_bef... | CWE-307 | 26 |
def accepted_ally_link(uniqueid, data)
notification = t(
'notifications.ally.accepted',
name: data[:user]
)
link = "/profile?uid=#{data[:uid]}"
notification_link(uniqueid, link, notification)
end | CWE-79 | 1 |
def build_command_line(command, params = nil)
return command.to_s if params.nil? || params.empty?
"#{command} #{assemble_params(sanitize(params))}"
end | CWE-78 | 6 |
def self.get_for_group(group_id, category=nil)
SqlHelper.validate_token([group_id, category])
con = []
con << "(group_id=#{group_id})"
con << "(category='#{category}')" unless category.nil?
settings = Setting.where(con.join(' and ')).to_a
return nil if settings.nil? or settings.empty?
... | CWE-89 | 0 |
def destroy
Log.add_info(request, params.inspect)
if params[:check_user].nil?
list
render(:action => 'list')
return
end
count = 0
params[:check_user].each do |user_id, value|
if value == '1'
begin
User.destroy(user_id)
rescue => evar
L... | CWE-89 | 0 |
def cama_current_user
return @cama_current_user if defined?(@cama_current_user)
# api current user...
@cama_current_user = cama_calc_api_current_user
return @cama_current_user if @cama_current_user
return nil unless cookies[:auth_token].present?
c = cookies[:auth_token].split("&")
return ... | CWE-613 | 7 |
def parse(socket=nil)
@socket = socket
begin
@peeraddr = socket.respond_to?(:peeraddr) ? socket.peeraddr : []
@addr = socket.respond_to?(:addr) ? socket.addr : []
rescue Errno::ENOTCONN
raise HTTPStatus::EOFError
end
read_request_line(socket)
if @http_ver... | CWE-444 | 41 |
def self.search_by_host(key, operator, value)
conditions = "hosts.name #{operator} '#{value_to_sql(operator, value)}'"
direct = Puppetclass.all(:conditions => conditions, :joins => :hosts, :select => 'puppetclasses.id').map(&:id).uniq
hostgroup = Hostgroup.joins(:hosts).where(conditions).first
in... | CWE-89 | 0 |
it 'is possible to return errors in jsonapi format' do
get '/'
expect(last_response.body).to eq('{"error":"rain!"}')
end | CWE-79 | 1 |
def self.get_for(user_id, date_s)
SqlHelper.validate_token([user_id, date_s])
begin
con = "(user_id=#{user_id}) and (date='#{date_s}')"
return Timecard.where(con).first
rescue
end
return nil
end | CWE-89 | 0 |
def group
Log.add_info(request, params.inspect)
date_s = params[:date]
if date_s.nil? or date_s.empty?
@date = Date.today
else
@date = Date.parse(date_s)
end
@group_id = params[:id]
group_users = Group.get_users(params[:id])
@user_schedule_hash = {}
unless group_user... | CWE-89 | 0 |
def create_workflow
Log.add_info(request, params.inspect)
@tmpl_folder, @tmpl_workflows_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_WORKFLOWS)
@group_id = params[:group_id]
if @group_id.nil? or @group_id.empty?
@group_id = '0' # '0' for ROOT
elsif @group_id == '0'
... | CWE-89 | 0 |
def get_group_users
Log.add_info(request, params.inspect)
@group_id = nil
if !params[:thetisBoxSelKeeper].nil?
@group_id = params[:thetisBoxSelKeeper].split(':').last
elsif !params[:group_id].nil? and !params[:group_id].empty?
@group_id = params[:group_id]
end
submit_url = url_fo... | CWE-89 | 0 |
def destroy
Log.add_info(request, params.inspect)
return unless request.post?
begin
Item.destroy(params[:id])
rescue => evar
Log.add_error(request, evar)
end
if params[:from_action].nil?
render(:text => params[:id])
else
params.delete(:controller)
params.de... | CWE-89 | 0 |
def self.get_for_user(user)
return [] if user.nil?
toys = Toy.where("user_id=#{user.id}").to_a
deleted_ary = []
return [] if toys.nil?
toys.each do |toy|
case toy.xtype
when Toy::XTYPE_ITEM
item = Item.find_by_id(toy.target_id)
if item.nil?
deleted... | CWE-89 | 0 |
def get_group_users
Log.add_info(request, params.inspect)
begin
@folder = Folder.find(params[:id])
rescue => evar
Log.add_error(request, evar)
end
@group_id = nil
if !params[:thetisBoxSelKeeper].nil?
@group_id = params[:thetisBoxSelKeeper].split(':').last
elsif !params[... | CWE-89 | 0 |
def get_mail_attachment
Log.add_info(request, params.inspect)
attached_id = params[:id].to_i
mail_attach = MailAttachment.find_by_id(attached_id)
if mail_attach.nil?
redirect_to(THETIS_RELATIVE_URL_ROOT + '/404.html')
return
end
email = Email.find_by_id(mail_attach.email_id)
... | CWE-89 | 0 |
def self.run_gpg(*args)
fragments = [
'gpg',
'--no-default-keyring'
] + args
command_line = fragments.join(' ')
output_file = Tempfile.new('gpg-output')
begin
output_file.close
result = system("#{command_line} > #{output_file.path} 2>&1")
ensure
... | CWE-94 | 14 |
it "should be an error instance if file was downloaded" do
stub_request(:get, "www.example.com/test.jpg").to_return(body: File.read(file_path("test.jpg")))
@instance.remote_image_url = "http://www.example.com/test.jpg"
e = @instance.image_integrity_error
expect(e).to be_... | CWE-918 | 16 |
def create_info_block(options)
return nil unless options
assignments = options.map { |k, v| "img.#{k} = #{v}" }
code = "lambda { |img| " + assignments.join(";") + "}"
eval code
end | CWE-94 | 14 |
def update_order
Log.add_info(request, params.inspect)
mail_account_id = params[:mail_account_id]
order_ary = params[:mail_filters_order]
@mail_account = MailAccount.find_by_id(mail_account_id)
if @mail_account.user_id != @login_user.id
render(:text => 'ERROR:' + t('msg.need_to_be_owner')... | CWE-89 | 0 |
def group
Log.add_info(request, params.inspect)
date_s = params[:date]
if date_s.nil? or date_s.empty?
@date = Date.today
date_s = @date.strftime(Schedule::SYS_DATE_FORM)
else
@date = Date.parse date_s
end
if params[:display] == 'mine'
redirect_to(:action => 'month')... | CWE-89 | 0 |
def scope_allowed_tags(tags)
Rails::Html::WhiteListSanitizer.allowed_tags = tags
yield Rails::Html::WhiteListSanitizer.new
ensure
Rails::Html::WhiteListSanitizer.allowed_tags = nil
end | CWE-79 | 1 |
def scope_allowed_attributes(attributes)
Rails::Html::WhiteListSanitizer.allowed_attributes = attributes
yield Rails::Html::WhiteListSanitizer.new
ensure
Rails::Html::WhiteListSanitizer.allowed_attributes = nil
end | CWE-79 | 1 |
def update
Log.add_info(request, params.inspect)
@equipment = Equipment.find(params[:id])
if (params[:groups].nil? or params[:groups].empty?)
params[:equipment][:groups] = nil
else
params[:equipment][:groups] = '|' + params[:groups].join('|') + '|'
end
if (params[:teams].nil? or... | CWE-89 | 0 |
def self.get_next_revision(user_id, source_id)
SqlHelper.validate_token([user_id, source_id])
copied_items = Item.where("user_id=#{user_id} and source_id=#{source_id}").order('created_at DESC').to_a
rev = 0
copied_items.each do |item|
rev_ary = item.title.scan(/[#](\d\d\d)$/)
next if re... | CWE-89 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.