code
stringlengths
12
2.05k
label
int64
0
1
programming_language
stringclasses
9 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
103
description
stringlengths
36
1.23k
url
stringlengths
36
48
label_name
stringclasses
2 values
def create_workflow Log.add_info(request, params.inspect) return unless request.post? @tmpl_folder, @tmpl_workflows_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_WORKFLOWS) @group_id = params[:group_id] SqlHelper.validate_token([@group_id]) if @group_id.blank? @group_id = '0' # '0' for ROOT elsif @group_id == '0' ; else group = nil begin group = Group.find(@group_id) rescue end if group.nil? render(:text => 'ERROR:' + t('msg.already_deleted', :name => Group.model_name.human)) return end end unless @tmpl_workflows_folder.nil? item = Item.new_workflow(@tmpl_workflows_folder.id) item.title = t('workflow.new') item.user_id = 0 item.save! workflow = Workflow.new workflow.item_id = item.id workflow.user_id = 0 workflow.status = Workflow::STATUS_NOT_APPLIED if @group_id == '0' workflow.groups = nil else workflow.groups = '|' + @group_id + '|' end workflow.save! else Log.add_error(request, nil, '/'+TemplatesHelper::TMPL_ROOT+'/'+TemplatesHelper::TMPL_WORKFLOWS+' NOT found!') end render(:partial => 'groups/ajax_group_workflows', :layout => false) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def upload Log.add_info(request, '') # Not to show passwords. return unless request.post? if params[:file].nil? or params[:file].size <= 0 render(:text => '') return end post_item = ZeptairPostHelper.get_item_for(@login_user) Attachment.create(params, post_item, 0) post_item.update_attribute(:updated_at, Time.now) render(:text => t('file.uploaded')) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def test_login_with_suburi_should_not_redirect_to_another_suburi @relative_url_root = Redmine::Utils.relative_url_root Redmine::Utils.relative_url_root = '/redmine' back_urls = [ 'http://test.host/', 'http://test.host/fake', 'http://test.host/fake/issues', 'http://test.host/redmine/../fake', 'http://test.host/redmine/../fake/issues', 'http://test.host/redmine/%2e%2e/fake', '//test.foo/fake', 'http://test.host//fake', 'http://test.host/\n//fake', '//[email protected]', '//test.foo', '////test.foo', '@test.foo', '[email protected]' ] back_urls.each do |back_url| post :login, :username => 'jsmith', :password => 'jsmith', :back_url => back_url assert_redirected_to '/my/page' end ensure Redmine::Utils.relative_url_root = @relative_url_root end
1
Ruby
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
safe
it 'should authenticate user and delete token' do user = Fabricate(:user) get "/session/current.json" expect(response.status).to eq(404) token = SecureRandom.hex $redis.setex "otp_#{token}", 10.minutes, user.username get "/session/otp/#{token}" expect(response.status).to eq(302) expect(response).to redirect_to("/") expect($redis.get("otp_#{token}")).to eq(nil) get "/session/current.json" expect(response.status).to eq(200) end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def rd.length 1024 * 1024 * 8 end
1
Ruby
CWE-119
Improper Restriction of Operations within the Bounds of a Memory Buffer
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
https://cwe.mitre.org/data/definitions/119.html
safe
def generation_time Time.at(data.unpack("N")[0]).utc end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def format_object(object, html=true, &block) if block_given? object = yield object end case object.class.name when 'Array' formatted_objects = object.map {|o| format_object(o, html)} html ? safe_join(formatted_objects, ', ') : formatted_objects.join(', ') when 'Time' format_time(object) when 'Date' format_date(object) when 'Fixnum' object.to_s when 'Float' sprintf "%.2f", object when 'User' html ? link_to_user(object) : object.to_s when 'Project' html ? link_to_project(object) : object.to_s when 'Version' html ? link_to_version(object) : object.to_s when 'TrueClass' l(:general_text_Yes) when 'FalseClass' l(:general_text_No) when 'Issue' object.visible? && html ? link_to_issue(object) : "##{object.id}" when 'Attachment' html ? link_to_attachment(object) : object.filename when 'CustomValue', 'CustomFieldValue' if object.custom_field f = object.custom_field.format.formatted_custom_value(self, object, html) if f.nil? || f.is_a?(String) f else format_object(f, html, &block) end else object.value.to_s end else html ? h(object) : object.to_s end
1
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
def self.get_sql_like(attr_names, keyword) key = SqlHelper.quote("%#{SqlHelper.escape_for_like(keyword)}%") con = [] attr_names.each do |attr_name| con << "(#{attr_name} like #{key})" end sql = con.join(' or ') sql = '(' + sql + ')' if con.length > 1 return sql end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "should return HTTP_X_FORWARDED_FOR as remote_address" do @connection.request.env['HTTP_X_FORWARDED_FOR'] = '1.2.3.4' @connection.remote_address.should == '1.2.3.4' end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def mget(*keys) options = (keys.pop if keys.last.is_a? Hash) || {} if keys.any? # Marshalling gets extended before Namespace does, so we need to pass options further if singleton_class.ancestors.include? Marshalling super(*keys.map {|key| interpolate(key) }, options) else super(*keys.map {|key| interpolate(key) }) end end end
0
Ruby
CWE-502
Deserialization of Untrusted Data
The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
it "returns the first matching document" do users.find(scope: scope).one.should eq documents.first end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def initiate primary, *secondaries = @nodes.shuffle primary.promote secondaries.each &:demote return primary, secondaries end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def initialize(file, name, content_type) @file = file @name = name @content_type = content_type || "" end
1
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
def scope_allowed_tags(tags) Rails::Html::WhiteListSanitizer.allowed_tags = tags yield Rails::Html::WhiteListSanitizer.new ensure Rails::Html::WhiteListSanitizer.allowed_tags = nil end
0
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
it "changes the current database" do session.use "moped_test_2" session.command(dbStats: 1)["db"].should eq "moped_test_2" end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def resource_metadata(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end return 200 if not params[:resourcename] or params[:resourcename] == "" resource_name = params[:resourcename][params[:resourcename].rindex(':')+1..-1] class_provider = params[:resourcename][0,params[:resourcename].rindex(':')] @resource = ResourceAgent.new(params[:resourcename]) if class_provider == "ocf:heartbeat" @resource.required_options, @resource.optional_options, @resource.info = getResourceMetadata(session, HEARTBEAT_AGENTS_DIR + resource_name) elsif class_provider == "ocf:pacemaker" @resource.required_options, @resource.optional_options, @resource.info = getResourceMetadata(session, PACEMAKER_AGENTS_DIR + resource_name) elsif class_provider == 'nagios' @resource.required_options, @resource.optional_options, @resource.info = getResourceMetadata(session, NAGIOS_METADATA_DIR + resource_name + '.xml') end @new_resource = params[:new] @resources, @groups = getResourcesGroups(session) erb :resourceagentform end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def entries(path=nil, identifier=nil, options={}) p1 = scm_iconv(@path_encoding, 'UTF-8', path) manifest = hg('rhmanifest', '-r', CGI.escape(hgrev(identifier)), CGI.escape(without_leading_slash(p1.to_s))) do |io| output = io.read.force_encoding('UTF-8') begin parse_xml(output)['rhmanifest']['repository']['manifest'] rescue end end path_prefix = path.blank? ? '' : with_trailling_slash(path) entries = Entries.new as_ary(manifest['dir']).each do |e| n = scm_iconv('UTF-8', @path_encoding, CGI.unescape(e['name'])) p = "#{path_prefix}#{n}" entries << Entry.new(:name => n, :path => p, :kind => 'dir') end as_ary(manifest['file']).each do |e| n = scm_iconv('UTF-8', @path_encoding, CGI.unescape(e['name'])) p = "#{path_prefix}#{n}" lr = Revision.new(:revision => e['revision'], :scmid => e['node'], :identifier => e['node'], :time => Time.at(e['time'].to_i)) entries << Entry.new(:name => n, :path => p, :kind => 'file', :size => e['size'].to_i, :lastrev => lr) end entries rescue HgCommandAborted nil # means not found end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def show_article auto_discovery_feed respond_to do |format| format.html do @comment = Comment.new @page_title = this_blog.article_title_template.to_title(@article, this_blog, params) @description = this_blog.article_desc_template.to_title(@article, this_blog, params) @keywords = @article.tags.map(&:name).join(", ") render "articles/#{@article.post_type}" end format.atom { render_feedback_feed("atom") } format.rss { render_feedback_feed("rss") } format.xml { render_feedback_feed("atom") } end rescue ActiveRecord::RecordNotFound error! end
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
it "should unstage user" do staged_user = Fabricate(:staged, email: '[email protected]', active: true, username: 'staged1', name: 'Stage Name') invite = Fabricate(:invite, email: '[email protected]') user = InviteRedeemer.create_user_from_invite(invite: invite, email: invite.email, username: 'walter', name: 'Walter White') expect(user.id).to eq(staged_user.id) expect(user.username).to eq('walter') expect(user.name).to eq('Walter White') expect(user.staged).to eq(false) expect(user.email).to eq('[email protected]') expect(user.approved).to eq(true) end
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
def remove(server) servers.delete(server) end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def data @data ||= @@generator.next end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
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
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it "returns the index with the provided key" do indexes[name: 1]["name"].should eq "name_1" end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def add_meta_attr(session, resource, key, value) stdout, stderr, retval = run_cmd( session, PCS, "resource", "meta", resource, key.to_s + "=" + value.to_s ) return retval end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def destroy Log.add_info(request, params.inspect) return unless request.post? begin team = Team.find(params[:id]) Item.destroy(team.item_id) rescue => evar Log.add_error(request, evar) end list flash[:notice] = t('msg.delete_success') render(:action => 'list') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def promote @primary = true @secondary = false hiccup end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
it "does not activate user invited via links" do invite = Fabricate(:invite, email: '[email protected]', emailed_status: Invite.emailed_status_types[:not_required]) user = InviteRedeemer.create_user_from_invite(invite: invite, email: invite.email, username: 'walter', name: 'Walter White') expect(user.username).to eq('walter') expect(user.name).to eq('Walter White') expect(user.email).to eq('[email protected]') expect(user.approved).to eq(true) expect(user.active).to eq(false) end
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
def calculated_content_type @calculated_content_type ||= type_from_file_command.chomp end
1
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
def auth @auth ||= {} end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "closes open cursors" do users.insert(100.times.map { Hash["scope" => scope] }) stats = Support::Stats.collect do users.find(scope: scope).limit(5).entries end stats[node_for_reads].grep(Moped::Protocol::KillCursors).count.should eq 1 end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
it "sanitizes Pathname param key" do cl = subject.build("true", Pathname.new("/usr/bin/ruby") => nil) expect(cl).to eq "true /usr/bin/ruby" end
1
Ruby
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
safe
def do_send Log.add_info(request, params.inspect) return unless request.post? begin email = Email.find(params[:id]) if email.status != Email::STATUS_DRAFT # Ignore clicked Send button twice or more at once. raise('ERROR:' + 'Specified E-mail is not a draft.') end mail_account = MailAccount.find(email.mail_account_id) if mail_account.user_id != @login_user.id raise('ERROR:' + t('msg.need_to_be_owner')) end sent_folder = MailFolder.get_for(@login_user, mail_account.id, MailFolder::XTYPE_SENT) email.do_smtp(mail_account) attrs = ActionController::Parameters.new({status: Email::STATUS_TRANSMITTED, mail_folder_id: sent_folder.id, sent_at: Time.now}) email.update_attributes(attrs.permit(Email::PERMIT_BASE)) flash[:notice] = t('msg.transmit_success') rescue => evar Log.add_error(request, evar) flash[:notice] = 'ERROR:' + t('msg.transmit_failed') + '<br/>' + evar.to_s end render(:partial => 'common/flash_notice', :layout => false) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def to_json(options = nil) [name].to_json end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def authenticate! unless Setting['oauth_active'] Rails.logger.warn 'Trying to authenticate with OAuth, but OAuth is not active' return nil end unless (incoming_key = OAuth::RequestProxy.proxy(request).oauth_consumer_key) == Setting['oauth_consumer_key'] Rails.logger.warn "oauth_consumer_key should be '#{Setting['oauth_consumer_key']}' but was '#{incoming_key}'" return nil end if OAuth::Signature.verify(request, :consumer_secret => Setting['oauth_consumer_secret']) if Setting['oauth_map_users'] user_name = request.headers['HTTP_FOREMAN_USER'].to_s User.unscoped.find_by_login(user_name).tap do |obj| Rails.logger.warn "Oauth: mapping to user '#{user_name}' failed" if obj.nil? end.try(:login) else User::ANONYMOUS_API_ADMIN end else Rails.logger.warn "OAuth signature verification failed." return nil end end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def set_workflow Log.add_info(request, params.inspect) return unless request.post? @item = Item.find(params[:id]) orders_hash = params.dup orders_hash.reject! { |key, value| key.index(/order-/) != 0 } orders_hash.sort_by { |key, value| key.split('-').last.to_i } orders = [] orders_hash.each do |key, value| user_ids = value.split(',') SqlHelper.validate_token([user_ids]) orders << '|' + user_ids.join('|') + '|' end @item.workflow.update_attribute(:users, orders.join(',')) render(:partial => 'ajax_item_workflow', :layout => false) rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_item_workflow', :layout => false) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
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 indirect = HostgroupClass.where(:hostgroup_id => hostgroup.path_ids).pluck(:puppetclass_id).uniq return { :conditions => "1=0" } if direct.blank? && indirect.blank? puppet_classes = (direct + indirect).uniq { :conditions => "puppetclasses.id IN(#{puppet_classes.join(',')})" } end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it "yields the new session" do session.stub(with: new_session) session.new(new_options) do |session| session.should eql new_session end end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def nodes # Find the nodes that were down but are ready to be refreshed, or those # with stale connection information. needs_refresh, available = @nodes.partition do |node| (node.down? && node.down_at < (Time.new - @options[:down_interval])) || node.needs_refresh?(Time.new - @options[:refresh_interval]) end # Refresh those nodes. available.concat refresh(needs_refresh) # Now return all the nodes that are available. available.reject &:down? end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def destroy return unless request.post? if params[:check_log].nil? list render(:action => 'list') return end count = 0 params[:check_log].each do |key, value| if value == '1' Log.delete(key) count += 1 end end list flash[:notice] = count.to_s + t('log.deleted') render(:action => 'list') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "reconnects without raising an exception" do node.ensure_connected do node.command("admin", ping: 1) end.should eq("ok" => 1) end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def get_sw_versions(params, request, session) versions = { "rhel" => get_rhel_version(), "pcs" => get_pcsd_version(), "pacemaker" => get_pacemaker_version(), "corosync" => get_corosync_version(), "cman" => get_cman_version(), } return JSON.generate(versions) end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def show Log.add_info(request, params.inspect) @group_id = params[:group_id] official_title_id = params[:id] SqlHelper.validate_token([@group_id, official_title_id]) unless official_title_id.blank? @official_title = OfficialTitle.find(official_title_id) end render(:layout => (!request.xhr?)) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def reconnect @servers = servers.map { |server| Server.new(server.address) } end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def logout session.context.logout(name) end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def update_order Log.add_info(request, params.inspect) mail_account_id = params[:mail_account_id] order_arr = params[:mail_filters_order] SqlHelper.validate_token([mail_account_id]) @mail_account = MailAccount.find(mail_account_id) if @mail_account.user_id != @login_user.id render(:text => 'ERROR:' + t('msg.need_to_be_owner')) return end filters = MailFilter.get_for(mail_account_id) # filters must be ordered by xorder ASC. filters.sort! { |filter_a, filter_b| id_a = filter_a.id.to_s id_b = filter_b.id.to_s idx_a = order_arr.index(id_a) idx_b = order_arr.index(id_b) if idx_a.nil? or idx_b.nil? idx_a = filters.index(id_a) idx_b = filters.index(id_b) end idx_a - idx_b } idx = 1 filters.each do |filter| next if filter.mail_account_id != mail_account_id.to_i filter.update_attribute(:xorder, idx) idx += 1 end render(:text => '') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def test_update_invalid Subnet.any_instance.stubs(:valid?).returns(false) put :update, {:id => Subnet.first, :subnet => {:network => nil}}, set_session_user assert_template 'edit' end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
def with_taxonomy_scope(loc = Location.current, org = Organization.current, inner_method = :subtree_ids) self.which_ancestry_method = inner_method self.which_location = Location.expand(loc) if SETTINGS[:locations_enabled] self.which_organization = Organization.expand(org) if SETTINGS[:organizations_enabled] scope = block_given? ? yield : where('1=1') scope = scope_by_taxable_ids(scope) scope.readonly(false) end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
def write_key_to_disk(key, identity) # Writing is disabled. Don't bother checking any other states. return unless lookup_config_option('learn_public_keys') =~ /^1|y/ publickey_dir = lookup_config_option('publickey_dir') unless publickey_dir Log.info("Public key sent with request but no publickey_dir defined in configuration. Not writing key to disk.") return end if File.directory?(publickey_dir) if File.exists?(old_keyfile = File.join(publickey_dir, "#{identity}_pub.pem")) old_key = File.read(old_keyfile).chomp unless old_key == key unless lookup_config_option('overwrite_stored_keys', 'n') =~ /^1|y/ Log.warn("Public key sent from '%s' does not match the stored key. Not overwriting." % identity) else Log.warn("Public key sent from '%s' does not match the stored key. Overwriting." % identity) File.open(File.join(publickey_dir, "#{identity}_pub.pem"), 'w') { |f| f.puts key } end end else Log.debug("Discovered a new public key for '%s'. Writing to '%s'" % [identity, publickey_dir]) File.open(File.join(publickey_dir, "#{identity}_pub.pem"), 'w') { |f| f.puts key } end else raise("Cannot write public key to '%s'. Directory does not exist." % publickey_dir) end end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def check_action_permission!(skip_source = nil) super(skip_source) # only perform the following check, if we are called from # BsRequest.permission_check_change_state! (that is, if # skip_source is set to true). Always executing this check # would be a regression, because this code is also executed # if a new request is created (which could fail if User.current # cannot modify the source_package). return unless skip_source target_project = Project.get_by_name(self.target_project) return unless target_project && target_project.is_a?(Project) target_package = target_project.packages.find_by_name(self.target_package) initialize_devel_package = target_project.find_attribute('OBS', 'InitializeDevelPackage') return if target_package || !initialize_devel_package source_package = Package.get_by_project_and_name(source_project, self.source_package) return if !source_package || User.current.can_modify_package?(source_package) msg = 'No permission to initialize the source package as a devel package' raise PostRequestNoPermission, msg end
1
Ruby
CWE-862
Missing Authorization
The software does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
safe
it "logs in and processes commands" do session.login *Support::MongoHQ.auth_credentials session.command(ping: 1).should eq("ok" => 1) end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def remove delete = Protocol::Delete.new( operation.database, operation.collection, operation.selector, flags: [:remove_first] ) session.with(consistency: :strong) do |session| session.execute delete end end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
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) return end end users = @team.get_users_a end team_members = params[:team_members] SqlHelper.validate_token([team_members]) created = false modified = false if team_members.nil? or team_members.empty? unless team_id.blank? # @team must not be nil. @team.save if modified = @team.clear_users end else if team_members != users if team_id.blank? item = Item.find(params[:id]) created = true @team = Team.new @team.name = item.title @team.item_id = params[:id] @team.status = Team::STATUS_STANDBY else @team.clear_users end @team.add_users(team_members) @team.save @team.remove_application(team_members) modified = true end end if created @team.create_team_folder end @item = @team.item if modified flash[:notice] = t('msg.register_success') end render(:partial => 'ajax_team_info', :layout => false) rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_team_info', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it "returns the living socket" do cluster.socket_for(:write).should eq socket end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def get_fence_levels(session, cib_dom=nil) unless cib_dom cib_dom = get_cib_dom(session) return {} unless cib_dom end fence_levels = {} cib_dom.elements.each( '/cib/configuration/fencing-topology/fencing-level' ) { |e| target = e.attributes['target'] fence_levels[target] ||= [] fence_levels[target] << { 'level' => e.attributes['index'], 'devices' => e.attributes['devices'] } } fence_levels.each { |_, val| val.sort_by! { |obj| obj['level'].to_i }} return fence_levels end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def each cursor = Cursor.new(session.with(retain_socket: true), operation) cursor.to_enum.tap do |enum| enum.each do |document| yield document end if block_given? end end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def pipeline Threaded.begin :pipeline begin yield ensure Threaded.end :pipeline end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def self.dump(object) MultiJson.dump object, mode: :compat, escape_mode: :xss_safe, time_format: :ruby end
0
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def to_io @server end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def logging(operations) instrument_start = (logger = Moped.logger) && logger.debug? && Time.new yield ensure log_operations(logger, operations, Time.new - instrument_start) if instrument_start && !$! end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def read_lines(filename, selector) if selector IO.foreach(filename).select.with_index(1, &selector) else URI.open(filename, &:read) end end
0
Ruby
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
def save_tokens(params, request, session) # pcsd runs as root thus always returns hacluster's tokens if not allowed_for_local_cluster(session, Permissions::FULL) return 403, "Permission denied" end new_tokens = {} params.each{|nodes| if nodes[0].start_with?"node:" and nodes[0].length > 5 node = nodes[0][5..-1] token = nodes[1] new_tokens[node] = token end } tokens_cfg = Cfgsync::PcsdTokens.from_file('') sync_successful, sync_responses = Cfgsync::save_sync_new_tokens( tokens_cfg, new_tokens, get_corosync_nodes(), $cluster_name ) if sync_successful return [200, JSON.generate(read_tokens())] else return [400, "Cannot update tokenfile."] end end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def remove_acl_usergroup(session, role_id, usergroup_id) stdout, stderror, retval = run_cmd( session, PCS, "acl", "role", "unassign", role_id.to_s, usergroup_id.to_s, "--autodelete" ) if retval != 0 if stderror.empty? return "Error removing user / group" else return stderror.join("\n").strip end end return "" end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
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_before_authenticating credentials[0].downcase! end user = sorcery_adapter.find_by_credentials(credentials) unless user return authentication_response(failure: :invalid_login, &block) end set_encryption_attributes unless user.valid_password?(credentials[1]) return authentication_response(user: user, failure: :invalid_password, &block) end if user.respond_to?(:active_for_authentication?) && !user.active_for_authentication? return authentication_response(user: user, failure: :inactive, &block) end @sorcery_config.before_authenticate.each do |callback| success, reason = user.send(callback) unless success return authentication_response(user: user, failure: reason, &block) end end authentication_response(user: user, return_value: user, &block) end
0
Ruby
CWE-307
Improper Restriction of Excessive Authentication Attempts
The software does not implement sufficient measures to prevent multiple failed authentication attempts within in a short time frame, making it more susceptible to brute force attacks.
https://cwe.mitre.org/data/definitions/307.html
vulnerable
def start Log.add_info(request, params.inspect) return unless request.post? tmpl_folder, tmpl_q_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_RESEARCH) if tmpl_q_folder.nil? ary = TemplatesHelper.setup_tmpl_folder tmpl_q_folder = ary[4] end items = Folder.get_items_admin(tmpl_q_folder.id, 'xorder ASC') if items.nil? or items.empty? render(:text => t('research.create_page_first')) return else ApplicationHelper.delete_file_safe(Research.get_pages) items.each_with_index do |item, idx| desc = item.description if desc.nil? or desc.empty? render(:text => t('research.specify_page_content') + item.title.to_s) return end q_hash = Research.find_q_codes(desc) q_hash.each do |q_code, q_param| desc = Research.replaceCtrl(desc, q_code, q_param) end FileUtils.mkdir_p(Research.page_dir) file_name = sprintf('_q%02d.html.erb', idx+1) path = File.join(Research.page_dir, file_name) ApplicationHelper.f_ensure_exist(path) mode = ApplicationHelper.f_chmod(0666, path) begin f = File.open(path, 'w') f.write(desc) f.close rescue => evar logger.fatal(evar.to_s) end ApplicationHelper.f_chmod(mode, path) end end render(:text => '') rescue => evar Log.add_error(request, evar) render(:text => evar.to_s) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def update_attachment_info Log.add_info(request, params.inspect) return unless request.post? attachment = Attachment.find(params[:attachment_id]) # Getting Item at first for the case of resetting the db connection by an error. @item = Item.find(attachment.item_id) unless @item.check_user_auth(@login_user, 'w', true) raise t('msg.need_to_be_owner') end if !params[:attachment][:file].nil? and params[:attachment][:file].size == 0 params[:attachment].delete(:file) end unless attachment.update_attributes(params.require(:attachment).permit(Attachment::PERMIT_BASE)) @attachment = attachment render(:partial => 'ajax_item_attachment', :layout => false) return end @item = Item.find(attachment.item_id) @item.update_attribute(:updated_at, Time.now) render(:partial => 'ajax_item_attachment', :layout => false) rescue => evar Log.add_error(request, evar) @attachment = Attachment.new @attachment.errors.add_to_base(evar.to_s[0, 256]) render(:partial => 'ajax_item_attachment', :layout => false) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def set_member_and_redirect(member) set_member member Member::ActivityLog.create( cur_site: @cur_site, cur_member: member, activity_type: "login", remote_addr: remote_addr, user_agent: request.user_agent) ref = URI::decode(params[:ref] || flash[:ref] || "") ref = redirect_url if ref.blank? flash.discard(:ref) redirect_to ref end
0
Ruby
CWE-601
URL Redirection to Untrusted Site ('Open Redirect')
A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.
https://cwe.mitre.org/data/definitions/601.html
vulnerable
it "stores the options provided" do session.options.should eq(options) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def set_corosync_conf(params, request, session) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end if params[:corosync_conf] != nil and params[:corosync_conf].strip != "" Cfgsync::CorosyncConf.backup() Cfgsync::CorosyncConf.from_text(params[:corosync_conf]).save() return 200, "Succeeded" else $logger.info "Invalid corosync.conf file" return 400, "Failed" end end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
it "stores the database" do collection.database.should eq database end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def from_data(data) id = allocate id.instance_variable_set :@data, data id end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def update_config Log.add_info(request, params.inspect) @yaml = ApplicationHelper.get_config_yaml unless params[:desktop].nil? or params[:desktop].empty? @yaml[:desktop] = Hash.new if @yaml[:desktop].nil? params[:desktop].each do |key, val| @yaml[:desktop][key] = val end ApplicationHelper.save_config_yaml(@yaml) end flash[:notice] = t('msg.update_success') render(:partial => 'ajax_user_before_login', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def get_wizard(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end wizard = PCSDWizard.getWizard(params["wizard"]) if wizard != nil return erb wizard.collection_page else return "Error finding Wizard - #{params["wizard"]}" end end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
it "returns all other known hosts" do cluster.sync_server(server).should =~ ["localhost:61085", "localhost:61086", "localhost:61084"] end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def self.get_account_roots_for(user) return nil if user.nil? if user.kind_of?(User) user_id = user.id else user_id = user.to_s end SqlHelper.validate_token([user_id]) con = [] con << "(user_id=#{user_id})" con << "(xtype='#{MailFolder::XTYPE_ACCOUNT_ROOT}')" order_by = 'xorder ASC, id ASC' return MailFolder.where(con.join(' and ')).order(order_by).to_a end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def more? @cursor_id != 0 end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "removes the first matching document" do session.should_receive(:with, :consistency => :strong). and_yield(session) session.should_receive(:execute).with do |delete| delete.flags.should eq [:remove_first] delete.selector.should eq query.operation.selector end query.remove end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
it "should warn when matching against IP addresses" do add_rule("allow 10.1.1.1") @auth.should allow(request) @logs.should be_any {|log| log.level == :warning and log.message =~ /Authentication based on IP address is deprecated/} end
1
Ruby
CWE-287
Improper Authentication
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
safe
it "should not display completed tasks" do task_1 = FactoryGirl.create(:task, :user_id => current_user.id, :name => "Your first task", :bucket => "due_asap", :assigned_to => current_user.id) task_2 = FactoryGirl.create(:task, :user_id => current_user.id, :name => "Completed task", :bucket => "due_asap", :completed_at => 1.days.ago, :completed_by => current_user.id, :assigned_to => current_user.id) get :index assigns[:my_tasks].should == [task_1] end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def reset_q_ctrl Log.add_info(request, params.inspect) return unless request.post? Research.trim_config_yaml nil settings render(:partial => 'ajax_q_ctrls') rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_q_ctrls') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def users Log.add_info(request, params.inspect) con = [] unless params[:keyword].blank? key_array = params[:keyword].split(nil) key_array.each do |key| con << SqlHelper.get_sql_like([:name, :email, :fullname, :address, :organization], key) end end @group_id = nil if !params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxSelKeeper].split(':').last elsif !params[:group_id].blank? @group_id = params[:group_id] end SqlHelper.validate_token([@group_id]) unless @group_id.nil? con << SqlHelper.get_sql_like([:groups], "|#{@group_id}|") end include_research = false filter_status = params[:filter_status] unless filter_status.blank? SqlHelper.validate_token([filter_status]) case filter_status when Research::U_STATUS_IN_ACTON.to_s, Research::U_STATUS_COMMITTED.to_s con << "((Research.user_id=User.id) and (Research.status=#{filter_status}))" include_research = true when (-1).to_s researches = Research.where(nil).to_a except_users = [] unless researches.nil? researches.each do |research| except_users << research.user_id end end unless except_users.empty? con << '(User.id not in (' + except_users.join(',') + '))' end else ; end end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def supplied_type_mismatch? supplied_media_type.present? && !media_types_from_name.include?(supplied_media_type) end
1
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
def next(time = nil) @mutex.lock begin count = @counter = (@counter + 1) % 0xFFFFFF ensure @mutex.unlock rescue nil end generate(time || ::Time.new.to_i, count) end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def crop_command target = @attachment.instance if target.cropping?(@attachment.name) begin w = Integer(target.send :"#{@attachment.name}_crop_w") h = Integer(target.send :"#{@attachment.name}_crop_h") x = Integer(target.send :"#{@attachment.name}_crop_x") y = Integer(target.send :"#{@attachment.name}_crop_y") ["-crop", "#{w}x#{h}+#{x}+#{y}"] rescue Paperclip.log("[papercrop] #{@attachment.name} crop w/h/x/y were non-integer") return end end end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def filename_extension File.extname(@name.to_s.downcase).sub(/^\./, '').to_sym end
0
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
it "sanitizes Pathname param key" do cl = subject.build_command_line("true", Pathname.new("/usr/bin/ruby") => nil) expect(cl).to eq "true /usr/bin/ruby" end
0
Ruby
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
it "drops the current database" do session.with(database: "moped_test_2") do |session| session.drop.should eq("dropped" => "moped_test_2", "ok" => 1) end end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def replica_set_credentials [ENV["MONGOHQ_REPL_USER"], ENV["MONGOHQ_REPL_PASS"]] end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def self.prepare_rdoc root debug, verbose = false, false prepare_script = Pathname.new(Rails.root) + "script/rdoc_prepare_script.rb" if prepare_script.executable? dirs = Environment.puppetEnvs.values.join(":").split(":").uniq.sort.join(" ") puts "Running #{prepare_script} #{dirs}" if debug location = %x{#{prepare_script} #{dirs}} if $? == 0 root = location.chomp puts "Relocated modules to #{root}" if verbose end else puts "No executable #{prepare_script} found so using the uncopied module sources" if verbose end root end def as_json(options={}) super({:only => [:name, :id], :include => [:lookup_keys]}) end 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 indirect = HostgroupClass.where(:hostgroup_id => hostgroup.path_ids).pluck(:puppetclass_id).uniq return { :conditions => "1=0" } if direct.blank? && indirect.blank? puppet_classes = (direct + indirect).uniq { :conditions => "puppetclasses.id IN(#{puppet_classes.join(',')})" } end def self.value_to_sql(operator, value) return value if operator !~ /LIKE/i return value.tr_s('%*', '%') if (value ~ /%|\*/) return "%#{value}%" end end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it "has an empty list of servers" do cluster.servers.should be_empty end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it "executes the operation on the master node" do session.should_receive(:socket_for).with(:write). and_return(socket) socket.should_receive(:execute).with(operation) session.execute(operation) end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def add_constraint_rule_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end if params["c_type"] == "loc" retval, error = add_location_constraint_rule( session, params["res_id"], params["rule"], params["score"], params["force"], !params['disable_autocorrect'] ) else return [400, "Unknown constraint type: #{params["c_type"]}"] end if retval == 0 return [200, "Successfully added constraint"] else return [400, "Error adding constraint: #{error}"] end end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def generate(time, counter = 0) [time, @machine_id, Process.pid, counter << 8].pack("N NX lXX NX") end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def load consistency = session.consistency @options[:flags] |= [:slave_ok] if consistency == :eventual reply, @node = session.context.with_node do |node| [node.query(@database, @collection, @selector, @options), node] end @limit -= reply.count if limited? @cursor_id = reply.cursor_id reply.documents end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def sign(*); 'fake_sig'; end
1
Ruby
CWE-347
Improper Verification of Cryptographic Signature
The software does not verify, or incorrectly verifies, the cryptographic signature for data.
https://cwe.mitre.org/data/definitions/347.html
safe
def update_images_order Log.add_info(request, params.inspect) return unless request.post? order_ary = params[:images_order] item = Item.find(params[:id]) item.images_without_content.each do |img| class << img def record_timestamps; false; end end img.update_attribute(:xorder, order_ary.index(img.id.to_s) + 1) class << img remove_method(:record_timestamps) end end render(:text => '') rescue => evar Log.add_error(request, evar) render(:text => evar.to_s) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def limited? @query_op.limit > 0 end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def check_owner return if params[:id].blank? 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') redirect_to(:controller => 'desktop', :action => 'show') end end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "should reject a critical extension that isn't on the whitelist" do @request.stubs(:request_extensions).returns [{ "oid" => "banana", "value" => "yumm", "critical" => true }] expect { @ca.check_internal_signing_policies(@name, @request, false) }.to raise_error( Puppet::SSL::CertificateAuthority::CertificateSigningError, /request extensions that are not permitted/ ) end
1
Ruby
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
safe
def self.get_tree(folder_tree, conditions, parent, admin) if parent.instance_of?(Folder) tree_id = parent.id.to_s else tree_id = parent.to_s parent = nil if tree_id != '0' begin parent = Folder.find(tree_id) rescue end return folder_tree if parent.nil? end end group_obj_cache = {} folder_tree[tree_id] = [] if !parent.nil? and (parent.xtype == Folder::XTYPE_GROUP) Group.get_childs(parent.owner_id, false, true).each do |group| group_obj_cache[group.id] = group con = Marshal.load(Marshal.dump(conditions)) unless conditions.nil? if con.nil? con = '' else con << ' and ' end con << "(xtype='#{Folder::XTYPE_GROUP}') and (owner_id=#{group.id})" begin group_folder = Folder.where(con).first rescue => evar Log.add_error(nil, evar) end unless group_folder.nil? folder_tree[tree_id] << group_folder end end end con = Marshal.load(Marshal.dump(conditions)) unless conditions.nil? if con.nil? con = '' else con << ' and ' end con << "parent_id=#{tree_id.to_i}" folder_tree[tree_id] += Folder.where(con).order('xorder ASC, id ASC').to_a delete_ary = [] folder_tree[tree_id].each do |folder| if !admin and (folder.xtype == Folder::XTYPE_SYSTEM) delete_ary << folder next end if (tree_id == '0') and (folder.xtype == Folder::XTYPE_GROUP) group = Group.find_with_cache(folder.owner_id, group_obj_cache) unless group.nil? if group.parent_id != 0 delete_ary << folder next end end end folder_tree = Folder.get_tree(folder_tree, conditions, folder, admin) end folder_tree[tree_id] -= delete_ary return folder_tree end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "with dofollowify disabled, links should be nofollowed" do @blog.dofollowify = false @blog.save expect(nofollowify_links('<a href="http://myblog.net">my blog</a>')). to eq('<a href="http://myblog.net" rel="nofollow">my blog</a>') end
0
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable