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 self.parse_csv_row(row, book, idxs, user) imp_id = (idxs[0].nil? or row[idxs[0]].nil?)?(nil):(row[idxs[0]].strip) SqlHelper.validate_token([imp_id]) unless imp_id.blank? org_address = Address.find_by_id(imp_id) end if org_address.nil? address = Address.new else address = org_address end address.id = imp_id attr_names = [ :name, :name_ruby, :nickname, :screenname, :email1, :email2, :email3, :postalcode, :address, :tel1_note, :tel1, :tel2_note, :tel2, :tel3_note, :tel3, :fax, :url, :organization, :title, :memo, :xorder, :groups, :teams ] attr_names.each_with_index do |attr_name, idx| row_idx = idxs[idx+1] break if row_idx.nil? val = (row[row_idx].nil?)?(nil):(row[row_idx].strip) address.send(attr_name.to_s + '=', val) end if (address.groups == Address::EXP_IMP_FOR_ALL) \ or (book == Address::BOOK_COMMON and address.groups.blank? and address.teams.blank?) address.groups = nil address.teams = nil address.owner_id = 0 elsif !address.groups.blank? or !address.teams.blank? address.owner_id = 0 else address.owner_id = user.id end return address end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def to_s @@string_format % data.unpack("C12") 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 set_attachment Log.add_info(request, params.inspect) return unless request.post? created = false if params[:id].blank? @item = Item.new_info(0) @item.attributes = params.require(:item).permit(Item::PERMIT_BASE) @item.user_id = @login_user.id @item.title = t('paren.no_title') [:attachment0, :attachment1].each do |attach| next if params[attach].nil? or params[attach][:file].nil? or params[attach][:file].size == 0 @item.save! created = true break end else @item = Item.find(params[:id]) end modified = false item_attachments = @item.attachments_without_content [:attachment0, :attachment1].each do |attach| next if params[attach].nil? or params[attach][:file].nil? or params[attach][:file].size == 0 attachment = Attachment.create(params[attach], @item, item_attachments.length) modified = true item_attachments << attachment end if modified and !created @item.update_attribute(:updated_at, Time.now) end render(:partial => 'ajax_item_attachment', :layout => false) rescue => evar Log.add_error(request, evar) @attachment = Attachment.new @attachment.errors.add_to_base(evar.to_s[0, 256]) render(:partial => 'ajax_item_attachment', :layout => false) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def resource_status(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end resource_id = params[:resource] @resources,@groups = getResourcesGroups(session) location = "" res_status = "" @resources.each {|r| if r.id == resource_id if r.failed res_status = "Failed" elsif !r.active res_status = "Inactive" else res_status = "Running" end if r.nodes.length != 0 location = r.nodes[0].name break end end } status = {"location" => location, "status" => res_status} return JSON.generate(status) 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 match?(name, ip) if ip? if pattern.include?(IPAddr.new(ip)) Puppet.deprecation_warning "Authentication based on IP address is deprecated; please use certname-based rules instead" true else false end else matchname?(name) end 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 demote @primary = false @secondary = true hiccup 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 a new session" do session.with(new_options).should_not eql session 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 get_more(database, collection, cursor_id, limit) process Protocol::GetMore.new(database, collection, cursor_id, limit) 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 schedule_all 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 if @login_user.nil? or params[:display].nil? or params[:display] == 'all' params[:display] = 'all' con = EquipmentHelper.get_scope_condition_for(@login_user) else display_type = params[:display].split('_').first display_id = params[:display].split('_').last case display_type when 'group' if @login_user.get_groups_a(true).include?(display_id) con = SqlHelper.get_sql_like([:groups], "|#{display_id}|") end when 'team' if @login_user.get_teams_a.include?(display_id) con = SqlHelper.get_sql_like([:teams], "|#{display_id}|") end end end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it "doesn't log in the user when not approved" do SiteSetting.must_approve_users = true get "/session/email-login/#{email_token.token}" expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)).to include( I18n.t("login.not_approved") ) end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def reconnect @servers = servers.map { |server| Server.new(server.address) } 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 "raises a connection error" do lambda do node.ensure_connected do node.command("admin", ping: 1) end end.should raise_exception(Moped::Errors::ConnectionFailure) 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_clamp_code(nbits, signed) if signed == :signed max = (1 << (nbits - 1)) - 1 min = -(max + 1) else max = (1 << nbits) - 1 min = 0 end "val = (val < #{min}) ? #{min} : (val > #{max}) ? #{max} : val" 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.search_by_user(key, operator, value) key_name = key.sub(/^.*\./,'') condition = sanitize_sql_for_conditions(["? #{operator} ?", key_name, value_to_sql(operator, value)]) users = User.all(:conditions => condition) hosts = users.map(&:hosts).flatten opts = hosts.empty? ? "< 0" : "IN (#{hosts.map(&:id).join(',')})" return {:conditions => " hosts.id #{opts} " } 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 initialize @sock = nil @request_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
it 'supports passing read options to RMagick' do expect_any_instance_of(::Magick::Image::Info).to receive(:density=).with(10) expect_any_instance_of(::Magick::Image::Info).to receive(:size=).with("200x200") instance.manipulate! :read => { :density => 10, :size => %{"200x200"} } 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 query(operation) reply = session.query operation @get_more_op.limit -= reply.count if limited? @get_more_op.cursor_id = reply.cursor_id @kill_cursor_op.cursor_ids = [reply.cursor_id] reply.documents 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 meeting_link(uniqueid, data) notification = t( "notifications.meeting.#{data[:type]}", name: data[:user], group_name: data[:group], meeting_name: data[:typename] ) link = specific_meeting_link(data[:type], data[:typeid], data[:group_id]) notification_link(uniqueid, link, notification) 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 check_action_permission!(skip_source = nil) super(skip_source) # only perform the following check, if we are called from # BsRequest.permission_check_change_state! (that is, if # skip_source is set to true). Always executing this check # would be a regression, because this code is also executed # if a new request is created (which could fail if User.current # cannot modify the source_package). return unless skip_source target_project = Project.get_by_name(self.target_project) return unless target_project && target_project.is_a?(Project) target_package = target_project.packages.find_by_name(self.target_package) initialize_devel_package = target_project.find_attribute('OBS', 'InitializeDevelPackage') return if target_package || !initialize_devel_package opts = { follow_project_links: false } source_package = Package.get_by_project_and_name!(source_project, self.source_package, opts) return if User.current.can_modify?(source_package) msg = 'No permission to initialize the source package as a devel package' raise PostRequestNoPermission, msg end
1
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
safe
def remote_remove_nodes(params, request, session) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end count = 0 out = "" node_list = [] options = [] while params["nodename-" + count.to_s] node_list << params["nodename-" + count.to_s] count = count + 1 end options << "--force" if params["force"] cur_node = get_current_node_name() if i = node_list.index(cur_node) node_list.push(node_list.delete_at(i)) end # stop the nodes at once in order to: # - prevent resources from moving pointlessly # - get possible quorum loss warning stop_params = node_list + options stdout, stderr, retval = run_cmd( session, PCS, "cluster", "stop", *stop_params ) if retval != 0 return [400, stderr.join] end node_list.each {|node| retval, output = remove_node(session, node, true) out = out + output.join("\n") } config = PCSConfig.new(Cfgsync::PcsdSettings.from_file('{}').text()) if config.get_nodes($cluster_name) == nil or config.get_nodes($cluster_name).length == 0 return [200,"No More Nodes"] end return out 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.execute_action_move(mail_filter, email, val) mail_folder_id = val SqlHelper.validate_token([mail_folder_id]) begin mail_folder = MailFolder.find(mail_folder_id) rescue => evar end if !mail_folder.nil? and (mail_folder.user_id == email.user_id) email.update_attribute(:mail_folder_id, mail_folder_id) end return true end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def test_login_with_suburi_should_not_redirect_to_another_suburi @relative_url_root = Redmine::Utils.relative_url_root Redmine::Utils.relative_url_root = '/redmine' back_urls = [ 'http://test.host/', 'http://test.host/fake', 'http://test.host/fake/issues', 'http://test.host/redmine/../fake', 'http://test.host/redmine/../fake/issues', 'http://test.host/redmine/%2e%2e/fake' ] back_urls.each do |back_url| post :login, :username => 'jsmith', :password => 'jsmith', :back_url => back_url assert_redirected_to '/my/page' end ensure Redmine::Utils.relative_url_root = @relative_url_root end
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 initialize(seeds, options = {}) @cluster = Cluster.new(seeds) @options = options @options[:consistency] ||= :eventual 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 get_corosync_conf_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end return get_corosync_conf() 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 not display completed tasks" do task_1 = FactoryGirl.create(:task, :user_id => current_user.id, :name => "Your first task", :bucket => "due_asap", :assigned_to => current_user.id) task_2 = FactoryGirl.create(:task, :user_id => current_user.id, :name => "Completed task", :bucket => "due_asap", :completed_at => 1.days.ago, :completed_by => current_user.id, :assigned_to => current_user.id) get :index assigns[:my_tasks].should == [task_1] end
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 ajax_delete_mails Log.add_info(request, params.inspect) folder_id = params[:id] mail_account_id = params[:mail_account_id] unless params[:check_mail].blank? mail_folder = MailFolder.find(folder_id) trash_folder = MailFolder.get_for(@login_user, mail_account_id, MailFolder::XTYPE_TRASH) count = 0 params[:check_mail].each do |email_id, value| next if value != '1' begin email = Email.find(email_id) rescue => evar end next if email.nil? or (email.user_id != @login_user.id) if trash_folder.nil? \ or folder_id == trash_folder.id.to_s \ or mail_folder.get_parents(false).include?(trash_folder.id.to_s) email.destroy flash[:notice] ||= t('msg.delete_success') else begin email.update_attribute(:mail_folder_id, trash_folder.id) flash[:notice] ||= t('msg.moved_to_trash') rescue => evar Log.add_error(request, evar) email.destroy flash[:notice] ||= t('msg.delete_success') end end count += 1 end end get_mails 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 "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-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.run!(reset: false) # :nodoc: if check! super else Null end end
1
Ruby
NVD-CWE-noinfo
null
null
null
safe
def auth_session(auth = true) session = Moped::Session.new auth_seeds, database: auth_database session.login *auth_credentials if auth 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 get_auth_teams Log.add_info(request, params.inspect) folder_id = params[:id] SqlHelper.validate_token([folder_id]) begin @folder = Folder.find(folder_id) rescue @folder = nil end target_user_id = (@login_user.admin?(User::AUTH_TEAM))?(nil):(@login_user.id) @teams = Team.get_for(target_user_id, true) session[:folder_id] = folder_id render(:partial => 'ajax_auth_teams', :layout => false) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def tok(s) case s[0] when ?{ then ['{', s[0,1], s[0,1]] when ?} then ['}', s[0,1], s[0,1]] when ?: then [':', s[0,1], s[0,1]] when ?, then [',', s[0,1], s[0,1]] when ?[ then ['[', s[0,1], s[0,1]] when ?] then [']', s[0,1], s[0,1]] when ?n then nulltok(s) when ?t then truetok(s) when ?f then falsetok(s) when ?" then strtok(s) when Spc, ?\t, ?\n, ?\r then [:space, s[0,1], s[0,1]] else numtok(s) end end def nulltok(s); s[0,4] == 'null' ? [:val, 'null', nil] : [] end def truetok(s); s[0,4] == 'true' ? [:val, 'true', true] : [] end def falsetok(s); s[0,5] == 'false' ? [:val, 'false', false] : [] end def numtok(s) m = /-?([1-9][0-9]+|[0-9])([.][0-9]+)?([eE][+-]?[0-9]+)?/.match(s) if m && m.begin(0) == 0 if !m[2] && !m[3] [:val, m[0], Integer(m[0])] elsif m[2] [:val, m[0], Float(m[0])] else [:val, m[0], Integer(m[1])*(10**m[3][1..-1].to_i(10))] end else [] end end def strtok(s) m = /"([^"\\]|\\["\/\\bfnrt]|\\u[0-9a-fA-F]{4})*"/.match(s) if ! m raise Error, "invalid string literal at #{abbrev(s)}" end [:str, m[0], unquote(m[0])] 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 calculated_content_type @calculated_content_type ||= type_from_file_command.chomp 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 munge_name(name) # LAK:NOTE http://snurl.com/21zf8 [groups_google_com] # Change to name.downcase.split(".",-1).reverse for FQDN support name.downcase.split(".").reverse 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 media_type_mismatch? ! supplied_file_media_types.include?(calculated_media_type) 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 get_group_equipment Log.add_info(request, params.inspect) @group_id = nil if !params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxSelKeeper].split(':').last elsif !params[:group_id].blank? @group_id = params[:group_id] end SqlHelper.validate_token([@group_id]) submit_url = url_for(:controller => 'schedules', :action => 'get_group_equipment') render(:partial => 'common/select_equipment', :layout => false, :locals => {:target_attr => :id, :submit_url => submit_url}) 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 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-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_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 'lib/code.rb' File.open @gem, 'wb' do |gem_io| Gem::Package::TarWriter.new gem_io do |gem| build.add_metadata gem build.add_contents gem # write bogus data.tar.gz to foil signature bogus_data = Gem.gzip 'hello' gem.add_file_simple 'data.tar.gz', 0444, bogus_data.length do |io| io.write bogus_data end # pre rubygems 2.0 gems do not add checksums end end Gem::Security.trust_dir.trust_cert PUBLIC_CERT package = Gem::Package.new @gem package.security_policy = Gem::Security::HighSecurity e = assert_raises Gem::Security::Exception do package.verify end assert_equal 'invalid signature', e.message refute package.instance_variable_get(:@spec), '@spec must not be loaded' assert_empty package.instance_variable_get(:@files), '@files must empty' 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 media_types_from_name @media_types_from_name ||= content_types_from_name.collect(&:media_type) end
1
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
def address "#{@host}:#{@port}" 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 test_upload_binaries ActionController::IntegrationTest::reset_auth post "/build/home:Iggy/10.2/i586/TestPack", nil assert_response 401 prepare_request_with_user "adrian", "so_alone" post "/build/home:Iggy/10.2/i586/TestPack", nil assert_response 403 prepare_request_with_user "king", "sunflower" post "/build/home:Iggy/10.2/i586/TestPack", nil assert_response 400 # actually a success, it reached the backend assert_tag :tag => "status", :attributes => { :code => "400", :origin => "backend" } # check not supported methods post "/build/home:Iggy/10.2/i586/_repository", nil assert_response 404 assert_tag :tag => "status", :attributes => { :code => "unknown_package" } put "/build/home:Iggy/10.2/i586/TestPack", nil assert_response 400 assert_tag :tag => "status", :attributes => { :code => "invalid_http_method" } delete "/build/home:Iggy/10.2/i586/TestPack" assert_response 400 assert_tag :tag => "status", :attributes => { :code => "invalid_http_method" } 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 ajax_delete_items Log.add_info(request, params.inspect) unless params[:check_item].blank? is_admin = @login_user.admin?(User::AUTH_ITEM) count = 0 params[:check_item].each do |item_id, value| if value == '1' begin item = Item.find(item_id) next if !is_admin and item.user_id != @login_user.id item.destroy rescue => evar item = nil Log.add_error(request, evar) end count += 1 end end flash[:notice] = t('item.deleted', :count => count) end get_items end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def set_auth_teams Log.add_info(request, params.inspect) @folder = Folder.find(params[:id]) if Folder.check_user_auth(@folder.id, @login_user, 'w', true) read_teams = [] write_teams = [] teams_auth = params[:teams_auth] unless teams_auth.nil? teams_auth.each do |auth_param| user_id = auth_param.split(':').first auths = auth_param.split(':').last.split('+') if auths.include?('r') read_teams << user_id end if auths.include?('w') write_teams << user_id end end end @folder.set_read_teams read_teams @folder.set_write_teams write_teams @folder.save flash[:notice] = t('msg.register_success') else flash[:notice] = 'ERROR:' + t('folder.need_auth_to_modify') end target_user_id = (@login_user.admin?(User::AUTH_TEAM))?(nil):(@login_user.id) @teams = Team.get_for(target_user_id, true) render(:partial => 'ajax_auth_teams', :layout => false) rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_auth_teams', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def update_config Log.add_info(request, params.inspect) return unless request.post? yaml = ApplicationHelper.get_config_yaml unless params[:timecard].blank? yaml[:timecard] = Hash.new if yaml[:timecard].nil? params[:timecard].each do |key, val| yaml[:timecard][key] = val end ApplicationHelper.save_config_yaml(yaml) end @yaml_timecard = yaml[:timecard] @yaml_timecard = Hash.new if @yaml_timecard.nil? flash[:notice] = t('msg.update_success') render(:action => 'configure') 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 get_corosync_version() begin stdout, stderror, retval = run_cmd( PCSAuth.getSuperuserSession, COROSYNC, "-v" ) rescue stdout = [] end if retval == 0 match = /version\D+(\d+)\.(\d+)\.(\d+)/.match(stdout.join()) if match return match[1..3].collect { | x | x.to_i } end 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
def edit Log.add_info(request, params.inspect) address_id = params[:id] begin @address = Address.find(address_id) rescue => evar @address = nil Log.add_error(request, evar) redirect_to(:controller => 'login', :action => 'logout') return end render(:layout => (!request.xhr?)) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def self.validate_token(tokens, extra_chars=nil) if extra_chars.nil? extra_chars = '' else extra_chars = Regexp.escape(extra_chars.join()) end regexp = Regexp.new("^[ ]*[a-zA-Z0-9_.@\\-#{extra_chars}]+[ ]*$") [tokens].flatten.each do |token| next if token.blank? if token.to_s.match(regexp).nil? raise("[ERROR] SqlHelper.validate_token failed: #{token}") end end end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def self.get_for(user_id, date) begin con = "(user_id=#{user_id}) and (date='#{date}')" return Timecard.where(con).first rescue end return nil end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
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
it "sets the query operation's limit field" do query.limit(5) query.operation.limit.should eq 5 end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def self.get_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 ') end mail_accounts = MailAccount.find_by_sql('select * from mail_accounts ' + where + ' order by xorder ASC, title ASC') if mail_accounts.nil? or mail_accounts.empty? return nil else return mail_accounts.first 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 update_attachments_order Log.add_info(request, params.inspect) return unless request.post? order_ary = params[:attachments_order] item = Item.find(params[:id]) item.attachments_without_content.each do |attach| class << attach def record_timestamps; false; end end attach.update_attribute(:xorder, order_ary.index(attach.id.to_s) + 1) class << attach remove_method(:record_timestamps) end end render(:text => '') rescue => evar Log.add_error(request, evar) render(:text => evar.to_s) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "with params as empty Hash" do cl = subject.build_command_line("true", {}) expect(cl).to eq "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 "sets the slave ok flag" do stats = Support::Stats.collect do session.with(consistency: :eventual)[:users].find(scope: scope).one end query = stats[:secondary].grep(Moped::Protocol::Query).first query.flags.should include :slave_ok end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
it "does not drop other indexes" do indexes[age: -1].should_not be_nil 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 setup raise Puppet::Error.new("Puppet master is not supported on Microsoft Windows") if Puppet.features.microsoft_windows? # Handle the logging settings. if options[:debug] or options[:verbose] if options[:debug] Puppet::Util::Log.level = :debug else Puppet::Util::Log.level = :info end unless Puppet[:daemonize] or options[:rack] Puppet::Util::Log.newdestination(:console) options[:setdest] = true end end Puppet::Util::Log.newdestination(:syslog) unless options[:setdest] exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs? Puppet.settings.use :main, :master, :ssl, :metrics # Cache our nodes in yaml. Currently not configurable. Puppet::Node.indirection.cache_class = :yaml Puppet::FileServing::Content.indirection.terminus_class = :file_server Puppet::FileServing::Metadata.indirection.terminus_class = :file_server # Configure all of the SSL stuff. if Puppet::SSL::CertificateAuthority.ca? Puppet::SSL::Host.ca_location = :local Puppet.settings.use :ca Puppet::SSL::CertificateAuthority.instance else Puppet::SSL::Host.ca_location = :none end end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
it "removes all matching documents" do session.should_receive(:with, :consistency => :strong). and_yield(session) session.should_receive(:execute).with do |delete| delete.flags.should eq [] delete.selector.should eq query.operation.selector end query.remove_all 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_acl_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::GRANT) return 403, 'Permission denied' end if params["item"] == "permission" retval = add_acl_permission( session, params["role_id"], params["type"], params["xpath_id"], params["query_id"] ) elsif (params["item"] == "user") or (params["item"] == "group") retval = add_acl_usergroup( session, params["role_id"], params["item"], params["usergroup"] ) else retval = "Error: Unknown adding request" end if retval == "" return [200, "Successfully added permission to role"] else return [ 400, retval.include?("cib_replace failed") ? "Error adding permission" : retval ] end end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def crop_command target = @attachment.instance if target.cropping?(@attachment.name) w = target.send :"#{@attachment.name}_crop_w" h = target.send :"#{@attachment.name}_crop_h" x = target.send :"#{@attachment.name}_crop_x" y = target.send :"#{@attachment.name}_crop_y" ["-crop", "#{w}x#{h}+#{x}+#{y}"] end end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it "removes the first matching document" do session.should_receive(:with, :consistency => :strong). and_yield(session) session.should_receive(:execute).with do |delete| delete.flags.should eq [:remove_first] delete.selector.should eq query.operation.selector end query.remove end
0
Ruby
CWE-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 raise an error if the image fails an integrity check when downloaded" do stub_request(:get, "www.example.com/test.jpg").to_return(body: File.read(file_path("test.jpg"))) expect(running { @instance.remote_image_url = "http://www.example.com/test.jpg" }).to raise_error(CarrierWave::IntegrityError) end
0
Ruby
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
def node_standby(params, request, session) if params[:name] code, response = send_request_with_token( session, params[:name], 'node_standby', true, {"node"=>params[:name]} ) # data={"node"=>params[:name]} for backward compatibility with older versions of pcs/pcsd else if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end $logger.info "Standby Node" stdout, stderr, retval = run_cmd(session, PCS, "cluster", "standby") return stdout end end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def legal?(str) !!str.match(/^[0-9a-f]{24}$/i) 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 send_request_with_token(session, node, request, post=false, data={}, remote=true, raw_data=nil, timeout=30, additional_tokens={}) token = additional_tokens[node] || get_node_token(node) $logger.info "SRWT Node: #{node} Request: #{request}" if not token $logger.error "Unable to connect to node #{node}, no token available" return 400,'{"notoken":true}' end cookies_data = { 'token' => token, } return send_request( session, node, request, post, data, remote, raw_data, timeout, cookies_data ) 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 get_acls(session, cib_dom=nil) unless cib_dom cib_dom = get_cib_dom(session) return {} unless cib_dom end acls = { 'role' => {}, 'group' => {}, 'user' => {}, 'target' => {} } cib_dom.elements.each('/cib/configuration/acls/*') { |e| type = e.name[4..-1] if e.name == 'acl_role' role_id = e.attributes['id'] desc = e.attributes['description'] acls[type][role_id] = {} acls[type][role_id]['description'] = desc ? desc : '' acls[type][role_id]['permissions'] = [] e.elements.each('acl_permission') { |p| p_id = p.attributes['id'] p_kind = p.attributes['kind'] val = '' if p.attributes['xpath'] val = "xpath #{p.attributes['xpath']}" elsif p.attributes['reference'] val = "id #{p.attributes['reference']}" else next end acls[type][role_id]['permissions'] << "#{p_kind} #{val} (#{p_id})" } elsif ['acl_target', 'acl_group'].include?(e.name) id = e.attributes['id'] acls[type][id] = [] e.elements.each('role') { |r| acls[type][id] << r.attributes['id'] } end } acls['user'] = acls['target'] return acls 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 set_image Log.add_info(request, params.inspect) created = false if params[:id].nil? or params[:id].empty? @item = Item.new_info(0) @item.attributes = params[:item] @item.user_id = @login_user.id @item.title = t('paren.no_title') [:image0, :image1].each do |img| next if params[img].nil? or params[img][:file].size == 0 @item.save! created = true break end else @item = Item.find(params[:id]) end modified = false item_images = @item.images_without_content [:image0, :image1].each do |img| next if params[img].nil? or params[img][:file].nil? or params[img][:file].size == 0 image = Image.new image.item_id = @item.id image.file = params[img][:file] image.title = params[img][:title] image.memo = params[img][:memo] image.xorder = item_images.length image.save! modified = true item_images << image end if modified and !created @item.update_attribute(:updated_at, Time.now) end render(:partial => 'ajax_item_image', :layout => false) rescue => evar Log.add_error(request, evar) @image = Image.new @image.errors.add_to_base(evar.to_s[0, 256]) render(:partial => 'ajax_item_image', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def unfold(string) string.gsub(/#{CRLF}#{WSP}+/, ' ').gsub(/#{WSP}+/, ' ') end
0
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
vulnerable
def test_update_invalid AuthSourceLdap.any_instance.stubs(:valid?).returns(false) put :update, {:id => AuthSourceLdap.first, :auth_source_ldap => {:name => AuthSourceLdap.first.name} }, 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
it "allows/disable marshalling" do store = Redis::Store::Factory.create :marshalling => false store.instance_variable_get(:@marshalling).must_equal(false) store.instance_variable_get(:@options)[:raw].must_equal(true) end
0
Ruby
CWE-502
Deserialization of Untrusted Data
The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
it 'should not overwrite an existing file if overwrite_stored_key is not set' do @plugin.stubs(:lookup_config_option).with('learn_public_keys').returns('1') @plugin.stubs(:lookup_config_option).with('publickey_dir').returns('ssh/pkd') @plugin.stubs(:lookup_config_option).with('overwrite_stored_keys', 'n').returns('n') File.stubs(:directory?).with('ssh/pkd').returns(true) File.stubs(:exists?).with('ssh/pkd/rspec_pub.pem').returns(true) File.stubs(:read).with('ssh/pkd/rspec_pub.pem').returns('ssh-rsa dcba') Log.expects(:warn) File.expects(:open).never @plugin.send(:write_key_to_disk, 'ssh-rsa abcd', 'rspec') 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 "does not raise error if record is not pending" do reviewable = ReviewableUser.needs_review!(target: Fabricate(:user, email: invite.email), created_by: invite.invited_by) reviewable.status = Reviewable.statuses[:ignored] reviewable.save! invite_redeemer.redeem reviewable.reload expect(reviewable.status).to eq(Reviewable.statuses[:ignored]) end
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
def opposite_direction direction.to_sym == :asc ? :desc : :asc 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 nodes # Find the nodes that were down but are ready to be refreshed, or those # with stale connection information. needs_refresh, available = @nodes.partition do |node| (node.down? && node.down_at < (Time.new - @options[:down_interval])) || node.needs_refresh?(Time.new - @options[:refresh_interval]) end # Refresh those nodes. available.concat refresh(needs_refresh) # Now return all the nodes that are available. available.reject &:down? end
1
Ruby
CWE-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 sanitize_value(value) case value when Array then value.collect { |i| i.to_s.shellescape } when NilClass then value else value.to_s.shellescape 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
it "should be a subclass of Base" do Puppet::FileServing::Metadata.superclass.should equal(Puppet::FileServing::Base) 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 'does not include user or group archived messages' do UserArchivedMessage.archive!(user.id, group_message) UserArchivedMessage.archive!(user.id, private_message) topics = TopicQuery.new(nil).list_private_messages_all(user).topics expect(topics).to eq([]) GroupArchivedMessage.archive!(user_2.id, group_message) topics = TopicQuery.new(nil).list_private_messages_all(user_2).topics expect(topics).to contain_exactly(private_message) end
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
it "handles Symbol keys with tailing '='" do cl = subject.build_command_line("true", :abc= => "def") expect(cl).to eq "true --abc=def" end
0
Ruby
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
def destroy_workflow Log.add_info(request, params.inspect) Item.find(params[:id]).destroy @tmpl_folder, @tmpl_workflows_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_WORKFLOWS) @group_id = params[:group_id] if @group_id.nil? or @group_id.empty? @group_id = '0' # '0' for ROOT end render(:partial => 'groups/ajax_group_workflows', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def spoofed? if has_name? && has_extension? && media_type_mismatch? && mapping_override_mismatch? Paperclip.log("Content Type Spoof: Filename #{File.basename(@name)} (#{supplied_file_content_types}), content type discovered from file command: #{calculated_content_type}. See documentation to allow this combination.") true end 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 accept to_io.accept 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 update_groups_order Log.add_info(request, params.inspect) order_ary = params[:groups_order] Research.set_statistics_groups order_ary render(:text => '') 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 verify_active_session if !request.post? && params[:status].blank? && User.exists?(session[:user].presence) warning _("You have already logged in") redirect_back_or_to hosts_path return end 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 authorized?(request) origin_host = request.get_header("HTTP_HOST")&.slice(VALID_ORIGIN_HOST, 1) || "" forwarded_host = request.x_forwarded_host&.slice(VALID_FORWARDED_HOST, 1) || "" @permissions.allows?(origin_host) && (forwarded_host.blank? || @permissions.allows?(forwarded_host)) end
0
Ruby
CWE-601
URL Redirection to Untrusted Site ('Open Redirect')
A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks.
https://cwe.mitre.org/data/definitions/601.html
vulnerable
def test_ordering User.current = users( :Iggy ) #project is given as axml axml = Xmlhash.parse( "<project name='home:Iggy'> <title>Iggy's Home Project</title> <description>dummy</description> <repository name='images'> <arch>local</arch> <arch>i586</arch> <arch>x86_64</arch> </repository> </project>" ) @project.update_from_xml(axml) xml = @project.render_axml # validate i586 is in the middle assert_xml_tag xml, :tag => :arch, :content => 'i586', :after => { :tag => :arch, :content => 'local' } assert_xml_tag xml, :tag => :arch, :content => 'i586', :before => { :tag => :arch, :content => 'x86_64' } # now verify it's not happening randomly #project is given as axml axml = Xmlhash.parse( "<project name='home:Iggy'> <title>Iggy's Home Project</title> <description>dummy</description> <repository name='images'> <arch>i586</arch> <arch>x86_64</arch> <arch>local</arch> </repository> </project>" ) @project.update_from_xml(axml) xml = @project.render_axml # validate x86_64 is in the middle assert_xml_tag xml, :tag => :arch, :content => 'x86_64', :after => { :tag => :arch, :content => 'i586' } assert_xml_tag xml, :tag => :arch, :content => 'x86_64', :before => { :tag => :arch, :content => 'local' } 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 self.validate_token(tokens, extra_chars=nil) if extra_chars.nil? extra_chars = '' else extra_chars = Regexp.escape(extra_chars.join()) end regexp = Regexp.new("^[ ]*[a-zA-Z0-9_#{extra_chars}]+[ ]*$") [tokens].flatten.each do |token| next if token.blank? if token.to_s.match(regexp).nil? \ and token.to_s.match(/^[ ]*\d+-\d+-\d+[ ]*$/).nil? raise("[ERROR] SqlHelper.validate_token failed: #{token}") end 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 verify_spec_name return if spec.name =~ Gem::Specification::VALID_NAME_PATTERN raise Gem::InstallError, "#{spec} has an invalid name" 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_primary(retry_on_failure = true, &block) if node = nodes.find(&:primary?) begin node.ensure_primary do return yield node.apply_auth(auth) end rescue Errors::ConnectionFailure, Errors::ReplicaSetReconfigured # Fall through to the code below if our connection was dropped or the # node is no longer the primary. end end if retry_on_failure # We couldn't find a primary node, so refresh the list and try again. refresh with_primary(false, &block) else raise Errors::ConnectionFailure, "Could not connect to a primary node for replica set #{inspect}" 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 build(command, params = nil) return command.to_s if params.nil? || params.empty? "#{command} #{assemble_params(sanitize(params))}" 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 private_message_reset_new topic_query = TopicQuery.new(current_user) if params[:topic_ids].present? unless Array === params[:topic_ids] raise Discourse::InvalidParameters.new( "Expecting topic_ids to contain a list of topic ids" ) end topic_scope = topic_query .private_messages_for(current_user, :all) .where("topics.id IN (?)", params[:topic_ids].map(&:to_i)) else params.require(:inbox) inbox = params[:inbox].to_s filter = private_message_filter(topic_query, inbox) topic_query.options[:limit] = false topic_scope = topic_query.filter_private_message_new(current_user, filter) end topic_ids = TopicsBulkAction.new( current_user, topic_scope.pluck(:id), type: "dismiss_topics" ).perform! render json: success_json.merge(topic_ids: topic_ids) end
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
def cat(path, identifier=nil) p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path)) hg 'rhcat', '-r', CGI.escape(hgrev(identifier)), hgtarget(p) do |io| io.binmode io.read end rescue HgCommandAborted nil # means not found end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def update_zept_allowed Log.add_info(request, params.inspect) return unless request.post? user = User.find(params[:id]) zept_allowed = params[:zept_allowed] if zept_allowed == 'true' unless user.allowed_zept_connect? user.update_attribute(:zeptair_id, User::ZEPTID_PLACE_HOLDER) end else if user.allowed_zept_connect? user.update_attribute(:zeptair_id, nil) post_item = ZeptairPostHelper.get_item_for(user, false) post_item.destroy unless post_item.nil? end end render(:text => '') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def do_execute Log.add_info(request, params.inspect) return unless request.post? mail_account = MailAccount.find(params[:mail_account_id]) mail_folder = MailFolder.find(params[:mail_folder_id]) if mail_account.user_id != @login_user.id \ or mail_folder.user_id != @login_user.id render(:text => t('msg.need_to_be_owner')) return end mail_filters = MailFilter.get_for(mail_account.id, true, MailFilter::TRIGGER_MANUAL) emails = MailFolder.get_mails(mail_folder.id, mail_folder.user_id) filter_next = true emails.each do |email| mail_filters.each do |filter| filter_next = filter.execute(email) break unless filter_next end break unless filter_next end render(:text => '') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "returns the count" do database.stub(command: { "n" => 4 }) query.count.should eq 4 end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def team_organize Log.add_info(request, params.inspect) team_id = params[:team_id] unless team_id.blank? begin @team = Team.find(team_id) rescue @team = nil ensure if @team.nil? flash[:notice] = t('msg.already_deleted', :name => Team.model_name.human) return end end users = @team.get_users_a end team_members = params[:team_members] SqlHelper.validate_token([team_members]) created = false modified = false if team_members.nil? or team_members.empty? unless team_id.blank? # @team must not be nil. @team.save if modified = @team.clear_users end else if team_members != users if team_id.blank? item = Item.find(params[:id]) created = true @team = Team.new @team.name = item.title @team.item_id = params[:id] @team.status = Team::STATUS_STANDBY else @team.clear_users end @team.add_users(team_members) @team.save @team.remove_application(team_members) modified = true end end if created @team.create_team_folder end @item = @team.item if modified flash[:notice] = t('msg.register_success') end render(:partial => 'ajax_team_info', :layout => false) rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_team_info', :layout => false) end
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 first limit(-1).each.first end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def 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 = {} group = Group.find_with_cache(group_id, group_obj_cache) group_ids = group.get_parents(false, group_obj_cache) group_ids << group_id group_con << " or (group_id in (#{group_ids.join(',')}))" end con << '(' + group_con + ')' else con << "(group_id=#{group_id.to_i})" end order_by = 'order by xorder ASC, id ASC' #order_by = 'order by disabled ASC, xorder ASC, id ASC' sql = 'select * from official_titles where ' + con.join(' and ') + ' ' + order_by return OfficialTitle.find_by_sql(sql) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def check_owner return if params[:id].blank? or @login_user.nil? mail_account = MailAccount.find(params[:id]) if !@login_user.admin?(User::AUTH_MAIL) and mail_account.user_id != @login_user.id Log.add_check(request, '[check_owner]'+request.to_s) flash[:notice] = t('msg.need_to_be_owner') redirect_to(:controller => 'desktop', :action => 'show') end end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def get_path Log.add_info(request, params.inspect) if params[:thetisBoxSelKeeper].nil? or params[:thetisBoxSelKeeper].empty? @group_path = '/' + t('paren.unknown') render(:partial => 'ajax_group_path', :layout => false) return end @selected_id = params[:thetisBoxSelKeeper].split(':').last @group_path = Group.get_path(@selected_id) render(:partial => 'ajax_group_path', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def edit_timecard Log.add_info(request, params.inspect) date_s = params[:date] if date_s.nil? or date_s.empty? @date = Date.today date_s = @date.strftime(Schedule::SYS_DATE_FORM) else @date = Date.parse(date_s) end @timecard = Timecard.get_for(@login_user.id, date_s) render(:partial => 'timecard', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it 'returns all campaigns belonging to the inbox to administrators' do # create a random campaign create(:campaign, account: account) get "/api/v1/accounts/#{account.id}/inboxes/#{inbox.id}/campaigns", headers: administrator.create_new_auth_token, as: :json expect(response).to have_http_status(:success) body = JSON.parse(response.body, symbolize_names: true) expect(body.first[:id]).to eq(campaign.display_id) expect(body.length).to eq(1) 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 get_data_center_from_api_key(api_key) # Return an empty string for invalid API keys so Gibbon hits the main endpoint data_center = "" if api_key && api_key["-"] # Add a period since the data_center is a subdomain and it keeps things dry data_center = "#{api_key.split('-').last}." end data_center end
0
Ruby
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable