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 file_list io # :nodoc: header = String.new read_until_dashes io do |line| header << line end Gem::SafeYAML.safe_load header 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 valid_back_url?(back_url) if CGI.unescape(back_url).include?('..') return false end begin uri = URI.parse(back_url) rescue URI::InvalidURIError return false end if uri.host.present? && uri.host != request.host return false end if uri.path.match(%r{/(login...
0
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
vulnerable
def begin(name) stack(name).push true 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 create Log.add_info(request, params.inspect) return unless request.post? parent_id = params[:selectedFolderId] if params[:thetisBoxEdit].blank? @mail_folder = nil else @mail_folder = MailFolder.new @mail_folder.name = params[:thetisBoxEdit] @mail_folder.parent_id = p...
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 'is possible to specify a custom formatter' do get '/' expect(last_response.body).to eq('{:custom_formatter=>"rain!"}') 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.get_comment_of(item_id, user_id) SqlHelper.validate_token([item_id, user_id]) begin comment = Comment.where("(user_id=#{user_id}) and (item_id=#{item_id}) and (xtype='#{Comment::XTYPE_DIST_ACK}')").first rescue => evar Log.add_error(nil, evar) end return comment 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 render_with_explicit_escaped_template render :template => "test/hello_w*rld" 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_next_revision(user_id, source_id) SqlHelper.validate_token([user_id, source_id]) copied_items = Item.where("user_id=#{user_id.to_i} and source_id=#{source_id.to_i}").order('created_at DESC').to_a rev = 0 copied_items.each do |item| rev_ary = item.title.scan(/[#](\d\d\d)$/) ...
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_resource_utilization(params, reqest, session) unless allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end unless params[:resource_id] and params[:name] return 400, 'resource_id and name are required' end res_id = params[:resource_id] name = params[:nam...
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 more? @cursor_id != 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 self.update_xorder(title, order) if title.nil? con = nil else con = ['title=?', title] end SqlHelper.validate_token([order]) User.update_all("xorder=#{order.to_i}", con) 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_edit get :edit, {:id => Hostgroup.first}, 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 self.search_by_puppetclass(key, operator, value) conditions = sanitize_sql_for_conditions(["puppetclasses.name #{operator} ?", value_to_sql(operator, value)]) hosts = Host.my_hosts.all(:conditions => conditions, :joins => :puppetclasses, :select => 'DISTINCT hosts.id').map(&: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 'parses zero-leading exponent numbers correctly' do expect(Raven::OkJson.decode("[123e090]")).to eq [123000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000] end
0
Ruby
CWE-399
Resource Management Errors
Weaknesses in this category are related to improper management of system resources.
https://cwe.mitre.org/data/definitions/399.html
vulnerable
def get_cib(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end cib, stderr, retval = run_cmd(session, CIBADMIN, "-Ql") if retval != 0 if not pacemaker_running? return [400, '{"pacemaker_not_running":true}'] end return ...
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 test_full_sanitize_allows_turning_off_encoding_special_chars assert_equal '&amp;', full_sanitize('&') assert_equal '&', full_sanitize('&', encode_special_chars: false) 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 "sets slave_ok on the query flags" do session.stub(socket_for: socket) socket.should_receive(:execute) do |query| query.flags.should include :slave_ok end session.query(query) 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 test_create_valid AuthSourceLdap.any_instance.stubs(:valid?).returns(true) post :create, {:auth_source_ldap => {:name => AuthSourceLdap.unscoped.first.name}}, set_session_user assert_redirected_to auth_source_ldaps_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 resource_unclone(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', 'unclone', para...
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_path Log.add_info(request, params.inspect) if params[:thetisBoxSelKeeper].nil? or params[:thetisBoxSelKeeper].empty? @folder_path = '/' + t('paren.unknown') render(:partial => 'ajax_folder_path', :layout => false) return end @selected_id = params[:thetisBoxSelKeeper].split(...
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 insert(documents) documents = [documents] unless documents.is_a? Array insert = Protocol::Insert.new(database.name, name, documents) database.session.with(consistency: :strong) do |session| session.execute insert 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 restrict_user_fields?(user) user.trust_level == TrustLevel[0] && anonymous? 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 self.delete_statistics_group(group_id) yaml = Research.get_config_yaml if yaml.nil? or yaml[:statistics].nil? return [] end groups = yaml[:statistics][:groups] return [] if groups.nil? ary = groups.split('|') ary.delete group_id.to_s ary.compact! ary.delete('') ...
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 private_messages_for(user, type) options = @options options.reverse_merge!(per_page: per_page_setting) result = Topic.includes(:allowed_users) result = result.includes(:tags) if SiteSetting.tagging_enabled if type == :group result = result.joins( "INNER JOIN top...
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 "raises a connection failure exception" do cluster.sync_server(server).should be_empty 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 self.update_for(user_id, fiscal_year, num) SqlHelper.validate_token([user_id, fiscal_year]) if num <= 0 con = [] con << "(user_id=#{user_id.to_i})" con << "(year=#{fiscal_year.to_i})" PaidHoliday.destroy_all(con.join(' and ')) return end paid_holiday = PaidHoliday....
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 should include the IndirectionHooks module in its indirection" do Puppet::FileServing::Content.indirection.singleton_class.included_modules.should include(Puppet::FileServing::IndirectionHooks) 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
it "drops the collection" do database.should_receive(:command).with(drop: :users) collection.drop 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 perform_accept_invitation params.require(:id) params.permit(:email, :username, :name, :password, :timezone, :email_token, user_custom_fields: {}) invite = Invite.find_by(invite_key: params[:id]) if invite.present? begin attrs = { username: params[:username], 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 change_team_status Log.add_info(request, params.inspect) return unless request.post? SqlHelper.validate_token([params[:status]]) team_id = params[:team_id] begin team = Team.find(team_id) team.update_status(params[:status]) @item = team.item flash[:notice] = t('msg...
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 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...
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 get_terminus(request) indirection.terminus(select(request)) 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 self.get_tmpl_subfolder(name) SqlHelper.validate_token([name]) tmpl_folder = Folder.where("folders.name='#{TMPL_ROOT}'").first unless tmpl_folder.nil? con = "(parent_id=#{tmpl_folder.id}) and (name='#{name}')" begin child = Folder.where(con).first rescue => evar Lo...
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 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}" ...
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def spec.validate; 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 updated_ajax @user = current_site.users.find(params[:user_id]) render inline: @user.update(params.require(:password).permit!) ? "" : @user.errors.full_messages.join(', ') end
0
Ruby
CWE-613
Insufficient Session Expiration
According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization."
https://cwe.mitre.org/data/definitions/613.html
vulnerable
def list Log.add_info(request, params.inspect) con = [] @group_id = nil if !params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxSelKeeper].split(':').last elsif !params[:group_id].blank? @group_id = params[:group_id] end unless @group_id.nil? if @group_id == '...
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 false" do session.should_not be_safe 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 executing?(name) !stack(name).empty? 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 "connects and yields the secondary node" do Time.stub(:new).and_return(Time.now + 10) replica_set.with_secondary do |node| node.command "admin", ping: 1 @secondaries.map(&:address).should include node.address 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 destroy Log.add_info(request, params.inspect) return unless request.post? @folder = Folder.find(params[:id]) unless Folder.check_user_auth(@folder.id, @login_user, 'w', true) flash[:notice] = 'ERROR:' + t('folder.need_auth_to_modify') render(:partial => 'common/flash_notice', :layou...
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 show_summary Log.add_info(request, params.inspect) mail_account_id = params[:id] SqlHelper.validate_token([mail_account_id]) begin @mail_account = MailAccount.find(mail_account_id) rescue => evar Log.add_error(request, evar) redirect_to(:controller => 'login', :action => 'l...
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 closed? !@server || @server.closed? 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_crm_mon_dom(session) begin stdout, _, retval = run_cmd( session, CRM_MON, '--one-shot', '-r', '--as-xml' ) if retval == 0 return REXML::Document.new(stdout.join("\n")) end rescue $logger.error 'Failed to parse crm_mon.' end return nil 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 "should accept #{name.inspect}" do csr = Puppet::SSL::CertificateRequest.new(name) csr.generate(@signing_key) @ca.check_internal_signing_policies(name, csr, false) 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 set_auth_groups Log.add_info(request, params.inspect) @folder = Folder.find(params[:id]) if Folder.check_user_auth(@folder.id, @login_user, 'w', true) read_groups = [] write_groups = [] groups_auth = params[:groups_auth] unless groups_auth.nil? groups_auth.each do |au...
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 extract_tar_gz io, destination_dir, pattern = "*" # :nodoc: open_tar_gz io do |tar| tar.each do |entry| next unless File.fnmatch pattern, entry.full_name, File::FNM_DOTMATCH destination = install_location entry.full_name, destination_dir FileUtils.rm_rf destination mkd...
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
def with_node if consistency == :eventual cluster.with_secondary do |node| yield node end else cluster.with_primary do |node| yield node 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
it 'returns success' do get "/session/email-login/#{email_token.token}" expect(response).to redirect_to("/") end
0
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
vulnerable
def delete_default_break Log.add_info(request, params.inspect) return unless request.post? unless params[:org_start].nil? org_start = UtilDateTime.parse(params[:org_start]).to_time yaml = ApplicationHelper.get_config_yaml unless yaml[:timecard].nil? or yaml[:timecard]['default_breaks...
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 group Log.add_info(request, params.inspect) date_s = params[:date] if date_s.blank? @date = Date.today else @date = Date.parse(date_s) end @group_id = params[:id] SqlHelper.validate_token([@group_id, params[:id]]) group_users = Group.get_users(params[:id]) @user_...
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 "returns a new Query" do Moped::Query.should_receive(:new). with(collection, selector).and_return(query) collection.find(selector).should eq query 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 "stores the selector" do query.selector.should eq selector 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 "doesn't recognize #index" do { :get => "/users" }.should_not be_routable 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_maintenance_project(project) check_write_access! if project.class == Project self.maintenance_project_id = project.id self.save! return true elsif project.class == String prj = Project.find_by_name(project) if prj self.maintenance_project_id = prj.id ...
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 "doesn't try to set flags" do session.stub(socket_for: socket) expect { session.query(query) }.not_to raise_exception 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 self.trim(user_id, mail_account_id, max) SqlHelper.validate_token([user_id, mail_account_id]) begin count = Email.where("mail_account_id=#{mail_account_id}").count if count > max #logger.fatal("[INFO] Email.trim(user_id:#{user_id}, mail_account_id:#{mail_account_id}, max:#{max})") ov...
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 test_destroy auth_source_ldap = AuthSourceLdap.first User.where(:auth_source_id => auth_source_ldap.id).update_all(:auth_source_id => nil) delete :destroy, {:id => auth_source_ldap}, set_session_user assert_redirected_to auth_source_ldaps_url assert !AuthSourceLdap.exists?(auth_source_ldap.id)...
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 from_string(string) raise Errors::InvalidObjectId.new(string) unless legal?(string) data = "" 12.times { |i| data << string[i*2, 2].to_i(16) } from_data data 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_folders_order Log.add_info(request, params.inspect) @folder_id = params[:id] @group_id = params[:group_id] SqlHelper.validate_token([@folder_id, @group_id]) if @folder_id != '0' @folder = Folder.find(@folder_id) end @folders = Folder.get_childs_for(@login_user, @folder_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
def delete_attachment Log.add_info(request, '') # Not to show passwords. return unless request.post? target_user = nil user_id = params[:user_id] zeptair_id = params[:zeptair_id] attachment_id = params[:attachment_id] SqlHelper.validate_token([user_id, zeptair_id, attachment_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 "requires an account with mail" do as_admin do @user = FactoryGirl.create(:user) end get :index, {}, set_session_user.merge(:user => @user.id) assert_response :redirect assert_redirected_to edit_user_path(@user) assert_equal "An email address is required, please update...
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 add_comment Log.add_info(request, params.inspect) return unless request.post? unless params[:comment][:file].nil? attach_params = { :file => params[:comment][:file] } params[:comment].delete(:file) end @comment = Comment.new(params.require(:comment).permit(Comment::PERMIT_BASE))...
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_security_policy_checksum_missing skip 'openssl is missing' unless defined?(OpenSSL::SSL) @spec.cert_chain = [PUBLIC_CERT.to_pem] @spec.signing_key = PRIVATE_KEY build = Gem::Package.new @gem build.spec = @spec build.setup_signer FileUtils.mkdir 'lib' FileUtils.touch ...
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 create_info_block(options) return nil unless options assignments = options.map { |k, v| "img.#{k} = #{v}" } code = "lambda { |img| " + assignments.join(";") + "}" eval code end
0
Ruby
CWE-94
Improper Control of Generation of Code ('Code Injection')
The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
https://cwe.mitre.org/data/definitions/94.html
vulnerable
def self.get_from_name(user_name) SqlHelper.validate_token([user_name]) begin user = User.where("name='#{user_name}'").first rescue => evar Log.add_error(nil, evar) end return user 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 "does not re-sync the cluster" do cluster.should_receive(:sync).never cluster.socket_for :write 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 run_auth_requests(session, nodes_to_send, nodes_to_auth, username, password, force=false, local=true) data = {} nodes_to_auth.each_with_index { |node, index| data["node-#{index}"] = node } data['username'] = username data['password'] = password data['bidirectional'] = 1 if not local data['force'] ...
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 "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-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 self.get_childs(klass, node_id, recursive, ret_obj) SqlHelper.validate_token([node_id]) array = [] if recursive tree = klass.get_tree(Hash.new, nil, node_id) return array if tree.nil? tree.each do |parent_id, childs| if ret_obj array |= childs 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 test_jail_classes_should_have_limited_methods expected = ["new", "methods", "name", "inherited", "method_added", "inspect", "allow", "allowed?", "allowed_methods", "init_allowed_methods", "<", # < needed in Rails Object#subclasses_of "ancestors", "==" # ancestor...
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 first session.simple_query(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
it "should pass the next serial as the serial number" do Puppet::SSL::CertificateFactory.expects(:build).with do |*args| args[3] == @serial end.returns "my real cert" @ca.sign(@name, :ca, @request) end
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 destroy_header_menu Log.add_info(request, params.inspect) return unless request.post? @yaml = ApplicationHelper.get_config_yaml unless params[:org_name].nil? or @yaml[:general]['header_menus'].nil? @yaml[:general]['header_menus'].each do |header_menu| if header_menu[0] == params[:...
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 key; 'key'; 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
it "doesn't recognize #index" do { :get => "/users" }.should_not be_routable 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
it "raises an OperationFailure exception" do session.stub(socket_for: socket) socket.stub(execute: reply) expect { session.execute(operation) }.to raise_exception(Moped::Errors::OperationFailure) 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 render_step(the_step, options = {}) if the_step.nil? || the_step.to_s == Wicked::FINISH_STEP redirect_to_finish_wizard options else render the_step, options 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
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 = r...
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 secondary? @secondary 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 "should fail when a protocol other than :puppet or :file is used" do @request.stubs(:protocol).returns "http" proc { @object.select(@request) }.should raise_error(ArgumentError) 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 deliver!(mail) envelope_from = mail.return_path || mail.sender || mail.from_addrs.first return_path = "-f " + '"' + envelope_from.escape_for_shell + '"' if envelope_from arguments = [settings[:arguments], return_path].compact.join(" ") self.class.call(settings[:location], arguments, ma...
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_index_should_show_visible_custom_fields_only Issue.destroy_all field_attributes = {:field_format => 'string', :is_for_all => true, :is_filter => true, :trackers => Tracker.all} @fields = [] @fields << (@field1 = IssueCustomField.create!(field_attributes.merge(:name => 'Field 1', :visible => t...
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 process # We don't want any tracking back in the fs. Unlikely, but there # you go. client = self.host.gsub("..",".") dir = File.join(Puppet[:reportdir], client) if ! FileTest.exists?(dir) FileUtils.mkdir_p(dir) FileUtils.chmod_R(0750, dir) end # Now store the report. ...
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
def self.count_completed_users(item_id) SqlHelper.validate_token([item_id]) ack_msg = ZeptairDistHelper.completed_ack_message(item_id) return Comment.where("(item_id=#{item_id.to_i}) and (xtype='#{Comment::XTYPE_DIST_ACK}') and (message='#{ack_msg}')").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 allowed_for_local_cluster(session, action) pcs_config = PCSConfig.new(Cfgsync::PcsdSettings.from_file('{}').text()) return pcs_config.permissions_local.allows?( session[:username], session[:usergroups], action ) 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_for(user, mail_account_id, xtype) return nil if user.nil? or mail_account_id.blank? if user.kind_of?(User) user_id = user.id else user_id = user.to_s end SqlHelper.validate_token([user_id, mail_account_id, xtype]) con = [] con << "(user_id=#{user_id})" con ...
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.load_yaml return if @yaml_loaded return unless defined?(gem) test_syck = ENV['TEST_SYCK'] # Only Ruby 1.8 and 1.9 have syck test_syck = false unless /^1\./ =~ RUBY_VERSION unless test_syck begin gem 'psych', '>= 1.2.1' rescue Gem::LoadError # It's OK if ...
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
def self.get_for(user_id, fiscal_year=nil) SqlHelper.validate_token([user_id, fiscal_year]) begin con = [] con << "(user_id=#{user_id})" if fiscal_year.nil? return PaidHoliday.where(con).order('year ASC').to_a else con << "(year=#{fiscal_year})" return PaidHol...
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 new if params[:action] == 'new' Log.add_info(request, params.inspect) end return unless request.post? render(:action => 'edit', :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
it "connects and yields a secondary node" do replica_set.with_secondary do |node| @secondaries.map(&:address).should include node.address 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 check_owner return if params[:id].blank? or @login_user.nil? begin owner_id = Location.find(params[:id]).user_id rescue owner_id = -1 end if !@login_user.admin?(User::AUTH_LOCATION) and owner_id != @login_user.id Log.add_check(request, '[check_owner]'+request.to_s) fl...
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 setup_user @request.session[:user] = users(:one).id users(:one).roles = [Role.default, Role.find_by_name('Viewer')] 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 initialize(session, query_operation) @session = session @query_op = query_operation.dup @get_more_op = Protocol::GetMore.new( @query_op.database, @query_op.collection, 0, @query_op.limit ) @kill_cursor_op = Protocol::KillCursors.new([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 require_smart_proxy_or_login(features = nil) features = features.call if features.respond_to?(:call) allowed_smart_proxies = features.blank? ? SmartProxy.all : SmartProxy.with_features(*features) if !Setting[:restrict_registered_smart_proxies] || auth_smart_proxy(allowed_smart_proxies, Setting[:requi...
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 executing?(name) !stack(name).empty? 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 self.get_my_folder(user_id) SqlHelper.validate_token([user_id]) return Folder.where("(owner_id=#{user_id}) and (xtype='#{Folder::XTYPE_USER}')").first 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 include_allowed?(target, reader) doc = reader.document return false if doc.safe >= ::Asciidoctor::SafeMode::SECURE return false if doc.attributes.fetch('max-include-depth', 64).to_i < 1 return false if target_uri?(target) && !doc.attributes.key?('allow-uri-read') true end
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 "updates to a mongo advanced selector" do stats = Support::Stats.collect do users.find(scope: scope).sort(_id: 1).explain end operation = stats[node_for_reads].grep(Moped::Protocol::Query).last operation.selector.should eq( "$query" => { scope:...
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 "sets the :database option" do session.use :admin session.options[:database].should eq(:admin) 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