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 group Log.add_info(request, params.inspect) date_s = params[:date] if date_s.blank? @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') else ...
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 params super rescue Rack::Utils::ParameterTypeError, Rack::Utils::InvalidParameterError => e raise BadRequest, "Invalid query parameters: #{e.message}" 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 stub_jwks stub_request(:get, 'https://samples.auth0.com/.well-known/jwks.json') .to_return( headers: { 'Content-Type' => 'application/json' }, body: jwks.to_json, status: 200 ) end
0
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
vulnerable
it "should return :file if the request key is fully qualified" do @request.expects(:key).returns File.expand_path('/foo') @object.select(@request).should == :file 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 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 test_create_maintenance_project_and_maintained_project User.current = users( :king ) maintenance_project = Project.new(:name => 'Maintenance:Project') assert_equal true, maintenance_project.set_project_type('maintenance') assert_equal 'maintenance', maintenance_project.project_type() # Create...
1
Ruby
CWE-275
Permission Issues
Weaknesses in this category are related to improper assignment or handling of permissions.
https://cwe.mitre.org/data/definitions/275.html
safe
it "should return a 403 if a user attempts to get at the _diagnostics path" do get "/message-bus/_diagnostics" last_response.status.must_equal 403 end
0
Ruby
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of t...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
it "updates the selector to mongo's advanced selector" do query.sort(a: 1) query.operation.selector.should eq( "$query" => selector, "$orderby" => { a: 1 } ) 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 "sets the generation time" do time = Time.at((Time.now.utc - 64800).to_i).utc Moped::BSON::ObjectId.new(nil, time).generation_time.should == time 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.safe_load input ::YAML.safe_load(input, WHITELISTED_CLASSES, WHITELISTED_SYMBOLS, true) end
1
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
safe
def rs256_decode_key(kid) jwks_x5c = jwks_key(:x5c, kid) if jwks_x5c.nil? raise OmniAuth::Auth0::TokenValidationError.new("Could not find a public key for Key ID (kid) '#{kid}''") end jwks_public_cert(jwks_x5c.first) end
0
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
vulnerable
def select_terminus(request) # We rely on the request's parsing of the URI. # Short-circuit to :file if it's a fully-qualified path or specifies a 'file' protocol. return PROTOCOL_MAP["file"] if Puppet::Util.absolute_path?(request.key) return PROTOCOL_MAP["file"] if request.protocol == "file" # ...
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 self.get_comment_of(item_id, user_id) SqlHelper.validate_token([item_id, user_id]) begin comment = Comment.where("(user_id=#{user_id.to_i}) and (item_id=#{item_id.to_i}) and (xtype='#{Comment::XTYPE_DIST_ACK}')").first rescue => evar Log.add_error(nil, evar) end return comment ...
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_verify_duplicate_file FileUtils.mkdir_p 'lib' FileUtils.touch 'lib/code.rb' build = Gem::Package.new @gem build.spec = @spec build.setup_signer open @gem, 'wb' do |gem_io| Gem::Package::TarWriter.new gem_io do |gem| build.add_metadata gem build.add_contents gem ...
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 ensure_connected # Don't run the reconnection login if we're already inside an # +ensure_connected+ block. return yield if Threaded.executing? :connection Threaded.begin :connection retry_on_failure = true begin connect unless connected? yield rescue E...
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 test_bad_early_options assert_raise HgCommandArgumentError do @adapter.diff('sources/welcome_controller.rb', '--config=alias.rhdiff=!xterm') end assert_raise HgCommandArgumentError do @adapter.entries('--debugger') end assert_raise HgCommandArgumentError do ...
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
it "stores the collection name" do collection.name.should eq :users 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 'should not update roles' do expect { spree_put :update, { :user => { :spree_role_ids => [role.id] } }}.to raise_exception(ActiveModel::MassAssignmentSecurity::Error) 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 update return unless access_granted?(params[:id]) id = params[:article][:id] || params[:id] @article = Article.find(id) if params[:article][:draft] fetch_fresh_or_existing_draft_for_article else @article = Article.find(@article.parent_id) unless @article.parent_id.nil? end ...
0
Ruby
CWE-732
Incorrect Permission Assignment for Critical Resource
The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.
https://cwe.mitre.org/data/definitions/732.html
vulnerable
it "initializes with the strings bytes" do Moped::BSON::ObjectId.should_receive(:new).with(bytes) Moped::BSON::ObjectId.from_string "4e4d66343b39b68407000001" 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 quote_column_name(name) #:nodoc: %Q("#{name}") 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 taxable_ids(loc = which_location, org = which_organization, inner_method = which_ancestry_method) if SETTINGS[:locations_enabled] && loc.present? inner_ids_loc = if Location.ignore?(self.to_s) self.unscoped.pluck("#{table_name}.id") else ...
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 get_mail_attachments Log.add_info(request, params.inspect) email_id = params[:id] email = Email.find_by_id(email_id) if email.nil? or email.user_id != @login_user.id render(:text => '') return end download_name = "mail_attachments#{email.id}.zip" zip_file = email.zip_att...
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 user_with_viewer_rights_should_fail_to_edit_a_domain setup_users get :edit, {:id => @model.id} assert @response.status == '403 Forbidden' 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 test_update_valid Subnet.any_instance.stubs(:valid?).returns(true) put :update, {:id => @model, :subnet => {:network => '192.168.100.10'}}, set_session_user assert_equal '192.168.100.10', Subnet.unscoped.find(@model).network assert_redirected_to subnets_url 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 generation_time Time.at(@data.pack("C4").unpack("N")[0]).utc 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 "executes a distinct command" do database.should_receive(:command).with( distinct: collection.name, key: "name", query: selector ).and_return("values" => [ "durran", "bernerd" ]) query.distinct(:name) 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 initialize(database, command) super database, :$cmd, command, limit: -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
it "creates an index with a generated name" do indexes.create(key) indexes[key]["name"].should eq "location.latlong_2d_name_1_age_-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 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...
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 "removes all matching documents" do users.insert(documents) users.find(scope: scope).remove_all users.find(scope: scope).count.should eq 0 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 RelaxNG string_or_io RelaxNG.new(string_or_io) end
0
Ruby
CWE-611
Improper Restriction of XML External Entity Reference
The software processes an XML document that can contain XML entities with URIs that resolve to documents outside of the intended sphere of control, causing the product to embed incorrect documents into its output.
https://cwe.mitre.org/data/definitions/611.html
vulnerable
def index valid_http_methods :get, :post # 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 params[:pr...
1
Ruby
CWE-434
Unrestricted Upload of File with Dangerous Type
The software allows the attacker to upload or transfer files of dangerous types that can be automatically processed within the product's environment.
https://cwe.mitre.org/data/definitions/434.html
safe
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...
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_avail_resource_agents(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end agents = getResourceAgents(session) return JSON.generate(agents) 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 self.get_tmpl_folder tmpl_folder = Folder.where("folders.name='#{TMPL_ROOT}'").first if tmpl_folder.nil? ary = self.setup_tmpl_folder unless ary.nil? or ary.empty? tmpl_folder = ary[0] tmpl_system_folder = ary[1] tmpl_workflows_folder = ary[2] tmpl_local_fol...
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 digest_name; 'SHA512'; 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 spec_summary entry, spec summary = truncate_text(spec.summary, "the summary for #{spec.full_name}") entry << "\n\n" << format_text(summary, 68, 4) 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 realpath file File.realpath file end
1
Ruby
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of t...
https://cwe.mitre.org/data/definitions/22.html
safe
def initialize(session) @session = session 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 close_clients_for(server) Moped.logger.debug "replica_set: closing open clients on #{server.port}" @clients.reject! do |client| port = client.addr(false)[1] if port == server.port client.close true else false 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 get_attachment Log.add_info(request, params.inspect) attach = Attachment.find(params[:id]) if attach.nil? redirect_to(THETIS_RELATIVE_URL_ROOT + '/404.html') return end parent_item = attach.item || ((attach.comment.nil?) ? nil : attach.comment.item) if parent_item.nil? or !pa...
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 'does not log in with incorrect two factor' do post "/session/email-login/#{email_token.token}", params: { second_factor_token: "0000", second_factor_method: UserSecondFactor.methods[:totp] } expect(response.status).to eq(200) ...
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def self.get_default_for(user_id, xtype=nil) SqlHelper.validate_token([user_id, xtype]) con = [] con << "(user_id=#{user_id})" con << '(is_default=1)' con << "(xtype='#{xtype}')" unless xtype.blank? where = '' unless con.nil? or con.empty? where = 'where ' + con.join(' and ') ...
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 check_member return if params[:id].blank? or @login_user.nil? if Item.find(params[:id]).user_id != @login_user.id Log.add_check(request, '[check_member]'+request.to_s) flash[:notice] = t('team.need_to_be_member') 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
def self.update_for(user_id, fiscal_year, num) SqlHelper.validate_token([user_id, fiscal_year]) if num <= 0 con = [] con << "(user_id=#{user_id})" con << "(year=#{fiscal_year})" PaidHoliday.destroy_all(con.join(' and ')) return end paid_holiday = PaidHoliday.get_for(us...
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 reactions_given params.require(:username) user = fetch_user_from_params(include_inactive: current_user.try(:staff?) || (current_user && SiteSetting.show_inactive_accounts)) raise Discourse::NotFound unless guardian.can_see_profile?(user) reaction_users = DiscourseReactions::ReactionUser...
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 dup session = super session.instance_variable_set :@options, options.dup if defined? @current_database session.send(:remove_instance_variable, :@current_database) end session 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 create_fixed_clamp_code(nbits, signed) if nbits == 1 && signed == :signed raise "signed bitfield must have more than one bit" end if signed == :signed max = (1 << (nbits - 1)) - 1 min = -(max + 1) else min = 0 max = (1 << nbits...
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 verify_cert_key_pair(cert, key) errors = [] cert_modulus = nil key_modulus = nil stdout, stderr, retval = run_cmd_options( PCSAuth.getSuperuserSession(), { 'stdin' => cert, }, '/usr/bin/openssl', 'x509', '-modulus', '-noout' ) if retval != 0 errors << "Invalid certificate: #{s...
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 get_more(*args) raise NotImplementedError, "#get_more cannot be called on Context; it must be called directly on a node" 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 "returns the new session" do session.stub(with: new_session) session.new(new_options).should eql new_session 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 ==(other) resolved_address == other.resolved_address 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 with_taxonomy_scope(loc = Location.current, org = Organization.current, inner_method = :subtree_ids) scope = block_given? ? yield : where(nil) return scope unless Taxonomy.enabled_taxonomies.present? self.which_ancestry_method = inner_method self.which_location = Location.expand(l...
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
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 { @...
0
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
vulnerable
def update_groups_order Log.add_info(request, params.inspect) return unless request.post? order_ary = params[:groups_order] groups = Group.get_childs(params[:id], false, false) # groups must be ordered by xorder ASC. groups.sort! { |id_a, id_b| idx_a = order_ary.index(id_a) id...
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 "inserts the document" do session.should_receive(:execute).with do |insert| insert.documents.should eq [{a: 1}] end collection.insert(a: 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_label options, f, attr label_size = options.delete(:label_size) || "col-md-2" required_mark = check_required(options, f, attr) label = options[:label] == :none ? '' : options.delete(:label) label ||= ((clazz = f.object.class).respond_to?(:gettext_translation_for_attribute_name) && s_(c...
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
it "renders email addresses in the body" do comment = build_stubbed(:comment, body: "foo@example.com") expect(comment.generate_html(:body)).to match(/mailto:/) 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 "only aquires the socket once" do session.cluster.should_receive(:socket_for). with(:read).once.and_return(mock(Moped::Socket)) session.send(:socket_for, :read) session.send(:socket_for, :read) 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 "activates user invited via email with a token" do invite = Fabricate(:invite, invited_by: Fabricate(:admin), email: 'walter.white@email.com', emailed_status: Invite.emailed_status_types[:sent]) user = InviteRedeemer.create_user_from_invite(invite: invite, email: invite.email, username: 'walter', nam...
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 get_path Log.add_info(request, params.inspect) if params[:thetisBoxSelKeeper].blank? @group_path = '/' + t('paren.unknown') render(:partial => 'ajax_group_path', :layout => false) return end @selected_id = params[:thetisBoxSelKeeper].split(':').last SqlHelper.validate_token...
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 delete_holidays Log.add_info(request, params.inspect) return unless request.post? holidays = params[:holidays] unless holidays.nil? SqlHelper.validate_token([holidays]) holidays.each do |schedule_id| Schedule.destroy(schedule_id) end end @holidays = Schedule.ge...
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 not warn when matches against IP addresses fail" do add_rule("allow 10.1.1.2") @auth.should_not allow(request) @logs.should_not 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
def escape_for_shell Mail::ShellEscape.escape_for_shell(self) 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 "syncs each seed node" do server = Moped::Server.allocate Moped::Server.should_receive(:new).with("127.0.0.1:27017").and_return(server) cluster.should_receive(:sync_server).with(server).and_return([]) cluster.sync 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 write(*args) raise Errors::ConnectionFailure, "Socket connection was closed by remote host" unless alive? super 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.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...
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 drop_file 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 my_folder = @login_user.get_my_folder if my_folder.nil? render(:text => 'ERROR:' + t('folder.canno...
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 remove_all_persons check_write_access! self.package_user_role_relationships.delete_all end
1
Ruby
CWE-275
Permission Issues
Weaknesses in this category are related to improper assignment or handling of permissions.
https://cwe.mitre.org/data/definitions/275.html
safe
def resource_master(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end unless params[:resource_id] return [400, 'resource_id has to be specified.'] end _, stderr, retval = run_cmd( session, PCS, 'resource', 'master', params[...
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 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...
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 exclude_from_group Log.add_info(request, params.inspect) if params[:group_id].nil? or params[:group_id].empty? render(:partial => 'ajax_groups', :layout => false) return end group_id = params[:group_id] begin @user = User.find(params[:id]) unless @user.nil? i...
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 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 execute...
0
Ruby
CWE-732
Incorrect Permission Assignment for Critical Resource
The product specifies permissions for a security-critical resource in a way that allows that resource to be read or modified by unintended actors.
https://cwe.mitre.org/data/definitions/732.html
vulnerable
def initialize(file, name) @file = file @name = name 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 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 ...
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 from_time(time) from_data @@generator.generate(time.to_i) 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 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...
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 "delegates to the current database" do database = mock(Moped::Database) session.should_receive(:current_database).and_return(database) database.should_receive(:drop) session.drop 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 split_header self.fields = raw_source.split(HEADER_SPLIT) end
1
Ruby
CWE-93
Improper Neutralization of CRLF Sequences ('CRLF Injection')
The software uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.
https://cwe.mitre.org/data/definitions/93.html
safe
it "stores the collection" do query.collection.should eq collection 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 "handles Symbol keys" do cl = subject.build("true", :abc => "def") expect(cl).to eq "true --abc def" 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 self.find_term(user_id, start_date, end_date) SqlHelper.validate_token([user_id]) start_s = start_date.strftime(Schedule::SYS_DATE_FORM) end_s = end_date.strftime(Schedule::SYS_DATE_FORM) con = "(user_id=#{user_id.to_i}) and (date >= '#{start_s}') and (date <= '#{end_s}')" ary = Timecard.wh...
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_titles_order Log.add_info(request, params.inspect) return unless request.post? titles = params[:titles_order] org_order = User.get_config_titles org_order = [] if org_order.nil? User.save_config_titles(titles) idx = 0 titles.each do |title| if title != org_order[i...
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 with_secondary(retry_on_failure = true, &block) available_nodes = nodes.shuffle!.partition(&:secondary?).flatten while node = available_nodes.shift begin return yield node.apply_auth(auth) rescue Errors::ConnectionFailure # That node's no good, so let's try the n...
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 log_operations(logger, ops, duration) prefix = " MOPED: #{address} " indent = " "*prefix.length runtime = (" (%.1fms)" % duration) if ops.length == 1 logger.debug prefix + ops.first.log_inspect + runtime else first, *middle, last = ops logger.debug pref...
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.count_ack_users(item_id) SqlHelper.validate_token([item_id]) return Comment.where("(item_id=#{item_id.to_i}) and (xtype='#{Comment::XTYPE_DIST_ACK}')").count 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.reminders(options={}) days = options[:days] || 7 project = options[:project] ? Project.find(options[:project]) : nil tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil target_version_id = options[:version] ? Version.named(options[:version]).pluck(:id) : nil if options[:ve...
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 approve_account_if_needed if invited_user.present? && reviewable_user = ReviewableUser.find_by(target: invited_user, status: Reviewable.statuses[:pending]) reviewable_user.perform( invite.invited_by, :approve_user, send_email: false, approved_by_invite: true ) e...
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 limited? @limited 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
detectMimeType(filename) { if (!filename) { return defaultMimeType; } let parsed = path.parse(filename); let extension = (parsed.ext.substr(1) || parsed.name || '') .split('?') .shift() .trim() .toLowerCase(); let v...
0
Ruby
CWE-88
Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')
The software constructs a string for a command to executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string.
https://cwe.mitre.org/data/definitions/88.html
vulnerable
def remove_acl_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::GRANT) return 403, 'Permission denied' end if params["item"] == "permission" retval = remove_acl_permission(session, params["acl_perm_id"]) elsif params["item"] == "usergroup" retval = remove_acl_u...
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 session.with(consistency: :strong) do |session| session.context.remove operation.database, operation.collection, operation.selector, flags: [:remove_first] 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 self.get_for(group_id, include_parents=false, enabled=nil) SqlHelper.validate_token([group_id]) con = [] #con << "(disabled=#{!enabled})" unless enabled.nil? if include_parents group_con = '(group_id is null)' unless group_id.nil? or group_id.to_s == '0' group_obj_cache = {...
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 'supports group' do topic = Fabricate(:topic, created_at: 3.months.ago) post = Fabricate(:post, raw: 'hi this is a test 123 123', topic: topic) group = Group.create!(name: "Like_a_Boss") GroupUser.create!(user_id: post.user_id, group_id: group.id) expect(Search.execute('group:like...
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 test_should_sanitize_with_trailing_space raw = "display:block; " expected = "display: block;" assert_equal expected, sanitize_css(raw) 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 current_user User.except_hidden.find_by_login(self.user) 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 create Log.add_info(request, params.inspect) return unless request.post? SqlHelper.validate_token([params[:groups], params[:teams]]) if params[:groups].blank? params[:equipment][:groups] = nil else params[:equipment][:groups] = '|' + params[:groups].join('|') + '|' 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 "creates an index" do indexes.create(key, background: true) indexes[key]["background"].should eq true 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 process_cors(env) resource, error = match_resource(env) if resource Result.hit(env) cors = resource.to_headers(env) cors else Result.miss(env, error) nil end end
0
Ruby
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of t...
https://cwe.mitre.org/data/definitions/22.html
vulnerable