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 query Log.add_info(request, '') # Not to show passwords. unless @login_user.admin?(User::AUTH_ZEPTAIR) render(:text => 'ERROR:' + t('msg.need_to_be_admin')) return end target_user = nil user_id = params[:user_id] zeptair_id = params[:zeptair_id] group_id = params[:group_id] SqlHelper.validate_token([user_id, zeptair_id, group_id]) unless user_id.blank? target_user = User.find(user_id) end unless zeptair_id.blank? target_user = User.where("zeptair_id=#{zeptair_id}").first end if target_user.nil? if group_id.blank? sql = 'select distinct Item.* from items Item, attachments Attachment' sql << " where Item.xtype='#{Item::XTYPE_ZEPTAIR_POST}' and Item.id=Attachment.item_id" sql << ' order by Item.user_id ASC' else group_ids = [group_id] if params[:recursive] == 'true' group_ids += Group.get_childs(group_id, true, false) end groups_con = [] group_ids.each do |grp_id| groups_con << SqlHelper.get_sql_like(['User.groups'], "|#{grp_id}|") end sql = 'select distinct Item.* from items Item, attachments Attachment, users User' sql << " where Item.xtype='#{Item::XTYPE_ZEPTAIR_POST}' and Item.id=Attachment.item_id" sql << " and (Item.user_id=User.id and (#{groups_con.join(' or ')}))" sql << ' order by Item.user_id ASC' end @post_items = Item.find_by_sql(sql) else @post_item = ZeptairPostHelper.get_item_for(target_user) end rescue => evar Log.add_error(request, evar) render(:text => 'ERROR:' + t('msg.system_error')) 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 "sets the query operation's fields" do query.select(a: 1) query.operation.fields.should eq(a: 1) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it "limits the query" do session.should_receive(:query) do |query| query.limit.should eq(-1) reply end session.simple_query(query) 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 "without params" do cl = subject.build("true") expect(cl).to eq "true" 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 html_message key = CGI.escape_html titleize(keys.last) path = CGI.escape_html keys.join('.') %(<span class="translation_missing" title="translation missing: #{path}">#{key}</span>) end def keys @keys ||= I18n.normalize_keys(locale, key, options[:scope]).tap do |keys| keys << 'no key' if keys.size < 2 end end def message "translation missing: #{keys.join('.')}" end alias :to_s :message def to_exception MissingTranslationData.new(locale, key, options) end protected # TODO : remove when #html_message is removed def titleize(key) key.to_s.gsub('_', ' ').gsub(/\b('?[a-z])/) { $1.capitalize } end 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
it 'logs in correctly' do post "/session/email-login/#{email_token.token}", params: { second_factor_token: ROTP::TOTP.new(user_second_factor.data).now, second_factor_method: UserSecondFactor.methods[:totp] } expect(response).to redirect_to("/") end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def secondary? @secondary 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 split_header self.fields = unfolded_header.split(CRLF) 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 self.strict_oct(str) return str.oct if str =~ /\A[0-7]*\z/ raise ArgumentError, "#{str.inspect} is not an octal string" end
1
Ruby
CWE-835
Loop with Unreachable Exit Condition ('Infinite Loop')
The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.
https://cwe.mitre.org/data/definitions/835.html
safe
def auth_credentials [ENV["MONGOHQ_SINGLE_USER"], ENV["MONGOHQ_SINGLE_PASS"]] end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def test_bad_early_options assert_nil @adapter.diff('sources/welcome_controller.rb', '--config=alias.rhdiff=!xterm') assert_raise HgCommandArgumentError do @adapter.entries('--debugger') end assert_raise HgCommandAborted do @adapter.revisions(nil, nil, nil, limit: '--repo=otherrepo') end assert_raise HgCommandAborted do @adapter.nodes_in_branch('default', limit: '--repository=otherrepo') end assert_raise HgCommandAborted do @adapter.nodes_in_branch('-Rotherrepo') end end
1
Ruby
NVD-CWE-noinfo
null
null
null
safe
it "converts the comment markup to HTML" do expect(comment.generate_html(:body)).to match(%r{<em>italic</em>}) expect(comment.generate_html(:body)).to match(%r{<strong>bold</strong>}) end
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 filename_from_header return nil unless file.meta.include? 'content-disposition' match = file.meta['content-disposition'].match(/filename=(?:"([^"]+)"|([^";]+))/) return nil unless match match[1].presence || match[2].presence end
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 delete_map Log.add_info(request, params.inspect) group_id = params[:group_id] SqlHelper.validate_token([group_id]) @office_map = OfficeMap.get_for_group(group_id, false) begin @office_map.destroy rescue => evar Log.add_error(request, evar) end @office_map = OfficeMap.get_for_group(group_id, false) flash[:notice] = t('msg.delete_success') render(:partial => 'groups/ajax_group_map', :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 remove_all delete = Protocol::Delete.new( operation.database, operation.collection, operation.selector ) session.with(consistency: :strong) do |session| session.execute delete 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 "returns the right category group permission for a staff user ordered by ascending group name" do json = described_class.new(category, scope: Guardian.new(admin), root: false).as_json expect(json[:group_permissions]).to eq([ { permission_type: CategoryGroup.permission_types[:readonly], group_name: group.name }, { permission_type: CategoryGroup.permission_types[:full], group_name: private_group.name }, { permission_type: CategoryGroup.permission_types[:full], group_name: user_group.name }, { permission_type: CategoryGroup.permission_types[:readonly], group_name: 'everyone' }, ]) end
0
Ruby
CWE-276
Incorrect Default Permissions
During installation, installed file permissions are set to allow anyone to modify those files.
https://cwe.mitre.org/data/definitions/276.html
vulnerable
def within_bounding_box(sw_lat, sw_lng, ne_lat, ne_lng, lat_attr, lon_attr) spans = "#{lat_attr} BETWEEN #{sw_lat} AND #{ne_lat} AND " # handle box that spans 180 longitude if sw_lng.to_f > ne_lng.to_f spans + "(#{lon_attr} BETWEEN #{sw_lng} AND 180 OR " + "#{lon_attr} BETWEEN -180 AND #{ne_lng})" else spans + "#{lon_attr} BETWEEN #{sw_lng} AND #{ne_lng}" 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 get_group_users Log.add_info(request, params.inspect) @group_id = nil if !params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxSelKeeper].split(':').last elsif !params[:group_id].blank? @group_id = params[:group_id] end SqlHelper.validate_token([@group_id]) submit_url = url_for(:controller => 'send_mails', :action => 'get_group_users') render(:partial => 'common/select_users', :layout => false, :locals => {:target_attr => :email, :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 seed # Authorisation is disabled usually when run from a rake db:* task User.current = FactoryGirl.build(:user, :admin => true, :organizations => [], :locations => []) load File.expand_path('../../../../db/seeds.rb', __FILE__) end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def message %Q{ --------------------------------------------------------------------- Moped runs specs for authentication and replica sets against MongoHQ. If you want to run these specs and need the credentials, contact durran at gmail dot com. --------------------------------------------------------------------- } 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_folder_items Log.add_info(request, params.inspect) unless params[:thetisBoxSelKeeper].nil? or params[:thetisBoxSelKeeper].empty? @folder_id = params[:thetisBoxSelKeeper].split(':').last end begin if Folder.check_user_auth(@folder_id, @login_user, 'r', true) @items = Folder.get_items(@login_user, @folder_id) end rescue => evar Log.add_error(request, evar) end submit_url = url_for(:controller => 'schedules', :action => 'get_folder_items') render(:partial => 'common/select_items', :layout => false, :locals => {:target_attr => :id, :submit_url => submit_url}) 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.on_desktop?(user, xtype, target_id) return false if user.nil? or xtype.nil? or target_id.nil? SqlHelper.validate_token([xtype, target_id]) con = "(user_id=#{user.id}) and (xtype='#{xtype}') and (target_id=#{target_id})" begin toy = Toy.where(con).first rescue => evar Log.add_error(nil, evar) end return (!toy.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 protected! if not PCSAuth.loginByToken(session, cookies) and not PCSAuth.isLoggedIn(session) # If we're on /managec/<cluster_name>/main we redirect match_expr = "/managec/(.*)/(.*)" mymatch = request.path.match(match_expr) on_managec_main = false if mymatch and mymatch.length >= 3 and mymatch[2] == "main" on_managec_main = true end if request.path.start_with?('/remote') or (request.path.match(match_expr) and not on_managec_main) or '/run_pcs' == request.path or '/clusters_overview' == request.path or request.path.start_with?('/permissions_') then $logger.info "ERROR: Request without authentication" halt [401, '{"notauthorized":"true"}'] else session[:pre_login_path] = request.path redirect '/login' end end end
0
Ruby
CWE-352
Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
https://cwe.mitre.org/data/definitions/352.html
vulnerable
it "queries a slave node" do session.should_receive(:socket_for).with(:read). and_return(socket) 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 self.get_for_group(group_id, category=nil) SqlHelper.validate_token([group_id, category]) con = [] con << "(group_id=#{group_id.to_i})" con << "(category='#{category}')" unless category.nil? settings = Setting.where(con.join(' and ')).to_a return nil if settings.nil? or settings.empty? hash = Hash.new settings.each do |setting| hash[setting.xkey] = setting.xvalue end return hash 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 truncate_text(text, description, max_length = 100_000) raise ArgumentError, "max_length must be positive" unless max_length > 0 return text if text.size <= max_length "Truncating #{description} to #{max_length.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse} characters:\n" + text[0, max_length] 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 rename Log.add_info(request, params.inspect) @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 => 'ajax_folder_name', :layout => false) return end unless params[:thetisBoxEdit].nil? or params[:thetisBoxEdit].empty? @folder.name = params[:thetisBoxEdit] @folder.save end render(:partial => 'ajax_folder_name', :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 "without params" 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
def get_auth_groups 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 @groups = Group.where(nil).to_a session[:folder_id] = folder_id render(:partial => 'ajax_auth_groups', :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
it "runs the command on the current database" do session.with(database: "moped_test_2") do |session| session.command(dbStats: 1)["db"].should eq "moped_test_2" 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 self.get_tmpl_subfolder(name) SqlHelper.validate_token([name]) tmpl_folder = Folder.where(name: TMPL_ROOT).first unless tmpl_folder.nil? name_quot = SqlHelper.quote(name) con = "(parent_id=#{tmpl_folder.id}) and (name=#{name_quot})" begin child = Folder.where(con).first rescue => evar Log.add_error(nil, evar) end end return [tmpl_folder, child] 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 login(username, password) session.context.login(name, username, password) 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_more reply = @node.get_more @database, @collection, @cursor_id, @limit @limit -= reply.count if limited? @cursor_id = reply.cursor_id reply.documents end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
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-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 "should pass the provided CSR as the CSR" do Puppet::SSL::CertificateFactory.expects(:build).with do |*args| args[1] == @request 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 self.search_by_params(key, operator, value) key_name = key.sub(/^.*\./,'') opts = {:conditions => "name = '#{key_name}' and value #{operator} '#{value_to_sql(operator, value)}'", :order => :priority} p = Parameter.all(opts) return {:conditions => '1 = 0'} if p.blank? max = p.first.priority negate_opts = {:conditions => "name = '#{key_name}' and NOT(value #{operator} '#{value_to_sql(operator, value)}') and priority > #{max}", :order => :priority} n = Parameter.all(negate_opts) conditions = param_conditions(p) negate = param_conditions(n) conditions += " AND " unless conditions.blank? || negate.blank? conditions += " NOT(#{negate})" unless negate.blank? return {:conditions => conditions} 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 filename_from_uri CGI.unescape(File.basename(file.base_uri.path)) 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
it "limits the query" do users.insert(documents) users.find(scope: scope).limit(1).to_a.should eq [documents.first] 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 "inserts the document" do session.should_receive(:execute).with do |insert| insert.documents.should eq [{a: 1}] end collection.insert(a: 1) end
0
Ruby
CWE-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 "yields each document" do users.insert(documents) users.find(scope: scope).each.with_index do |document, index| document.should eq documents[index] 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_login_should_not_redirect_to_another_host post :login, :username => 'jsmith', :password => 'jsmith', :back_url => 'http://test.foo/fake' assert_redirected_to '/my/page' end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def process(operation, &callback) if Threaded.executing? :pipeline queue.push [operation, callback] else flush([[operation, callback]]) 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 new @item = Item.new if params[:folder_id].blank? my_folder = @login_user.get_my_folder if my_folder.nil? @item.folder_id = 0 else @item.folder_id = my_folder.id end else @item.folder_id = params[:folder_id].to_i end @item.xtype= Item::XTYPE_INFO @item.layout = 'C' render(:action => 'edit') 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 all records matching selector with change" do query.should_receive(:update).with(change, [:multi]) query.update_all change 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 test_parse_memory_nil assert_raises(ArgumentError) do @parser.parse_memory(nil) end end
0
Ruby
CWE-241
Improper Handling of Unexpected Data Type
The software does not handle or incorrectly handles when a particular element is not the expected type, e.g. it expects a digit (0-9) but is provided with a letter (A-Z).
https://cwe.mitre.org/data/definitions/241.html
vulnerable
def show_tree Log.add_info(request, params.inspect) if !@login_user.nil? and @login_user.admin?(User::AUTH_FOLDER) @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]) @folder_tree = Folder.get_tree_by_group_for_admin(@group_id || '0') else @folder_tree = Folder.get_tree_for(@login_user) end end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it 'does not log in with incorrect backup code' do post "/session/email-login/#{email_token.token}", params: { second_factor_token: "0000", second_factor_method: UserSecondFactor.methods[:backup_codes] } expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)).to include(I18n.t( "login.invalid_second_factor_code" )) 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 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
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_update_invalid put :update, {:id => hostgroups(:common), :hostgroup => { :name => '' }}, set_session_user assert_template 'edit' 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.from(stream) header = stream.read 512 empty = (header == "\0" * 512) fields = header.unpack UNPACK_FORMAT new :name => fields.shift, :mode => strict_oct(fields.shift), :uid => strict_oct(fields.shift), :gid => strict_oct(fields.shift), :size => strict_oct(fields.shift), :mtime => strict_oct(fields.shift), :checksum => strict_oct(fields.shift), :typeflag => fields.shift, :linkname => fields.shift, :magic => fields.shift, :version => strict_oct(fields.shift), :uname => fields.shift, :gname => fields.shift, :devmajor => strict_oct(fields.shift), :devminor => strict_oct(fields.shift), :prefix => fields.shift, :empty => empty end
1
Ruby
CWE-835
Loop with Unreachable Exit Condition ('Infinite Loop')
The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.
https://cwe.mitre.org/data/definitions/835.html
safe
def rename 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 => 'ajax_folder_name', :layout => false) return end unless params[:thetisBoxEdit].blank? @folder.name = params[:thetisBoxEdit] @folder.save end render(:partial => 'ajax_folder_name', :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
it "updates the document" do users.find(scope: scope).upsert("$inc" => { counter: 1 }) users.find(scope: scope).one["counter"].should eq 2 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.call(path, arguments, destinations, mail) IO.popen("#{path} #{arguments} #{destinations}", "w+") do |io| io.puts mail.encoded.to_lf io.flush 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 to_io @server 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 html_message key = keys.last.to_s.gsub('_', ' ').gsub(/\b('?[a-z])/) { $1.capitalize } %(<span class="translation_missing" title="translation missing: #{keys.join('.')}">#{key}</span>)
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 "should use the provided CSR's content as the issuer" do Puppet::SSL::CertificateFactory.expects(:build).with do |*args| args[2].subject == "myhost" 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 get_more(*args) raise NotImplementedError, "#get_more cannot be called on Context; it must be called directly on a node" 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 check_image_content_type!(new_file) if image?(new_file) magic_type = mime_magic_content_type(new_file) if magic_type != new_file.content_type raise CarrierWave::IntegrityError, "has MIME type mismatch" end 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
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-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 "only aquires the socket once" do session.cluster.should_receive(:socket_for). with(:read).once.and_return(mock(Moped::Socket)) session.send(:socket_for, :read) session.send(:socket_for, :read) end
0
Ruby
CWE-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 initialize(string) super("'#{string}' is not a valid object id.") end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def initialize(values) self.settings = { :location => '/usr/sbin/exim', :arguments => '-i -t' }.merge(values) 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 command(command) operation = Protocol::Command.new(name, command) result = session.with(consistency: :strong) do |session| session.simple_query(operation) end raise Errors::OperationFailure.new( operation, result ) unless result["ok"] == 1.0 result 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 auth @auth ||= {} 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 initialize(session, query_operation) @session = session @database = query_operation.database @collection = query_operation.collection @selector = query_operation.selector @cursor_id = 0 @limit = query_operation.limit @limited = @limit > 0 @options = { request_id: query_operation.request_id, flags: query_operation.flags, limit: query_operation.limit, skip: query_operation.skip, fields: query_operation.fields } 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 "stores the cluster" do session.cluster.should be_a(Moped::Cluster) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def check_mail_owner return if params[:id].nil? or params[:id].empty? or @login_user.nil? begin owner_id = Email.find(params[:id]).user_id rescue owner_id = -1 end if !@login_user.admin?(User::AUTH_MAIL) and owner_id != @login_user.id Log.add_check(request, '[check_mail_owner]'+request.to_s) flash[:notice] = t('msg.need_to_be_owner') redirect_to(:controller => 'desktop', :action => 'show') 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 "raises a connection error" do lambda do replica_set.with_primary do |node| node.command "admin", ping: 1 end end.should raise_exception(Moped::Errors::ConnectionFailure) 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(user_id, category=nil) SqlHelper.validate_token([user_id, category]) con = [] con << "(user_id=#{user_id.to_i})" con << "(category='#{category}')" unless category.nil? settings = Setting.where(con.join(' and ')).to_a return nil if settings.nil? or settings.empty? hash = Hash.new settings.each do |setting| hash[setting.xkey] = setting.xvalue end return hash 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 edit Log.add_info(request, params.inspect) date_s = params[:date] if date_s.nil? or date_s.empty? @date = Date.today date_s = @date.strftime(Schedule::SYS_DATE_FORM) else @date = Date.parse(date_s) end if params[:user_id].nil? @selected_user = @login_user else @selected_user = User.find(params[:user_id]) end @timecard = Timecard.get_for(@selected_user.id, date_s) if @selected_user == @login_user @schedules = Schedule.get_user_day(@login_user, @date) end if !params[:display].nil? and params[:display].split('_').first == 'group' @group_id = params[:display].split('_').last 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 inner_ids(taxonomy, taxonomy_class, inner_method) return unscoped.pluck("#{table_name}.id") if taxonomy_class.ignore?(to_s) return inner_select(taxonomy, inner_method) if taxonomy.present? return [] unless User.current.present? # Any available taxonomy to the current user return unscoped.pluck("#{table_name}.id") if User.current.admin? taxonomy_relation = taxonomy_class.to_s.underscore.pluralize any_context_taxonomies = User.current. taxonomy_and_child_ids(:"#{taxonomy_relation}") unscoped.joins(TAXONOMY_JOIN_TABLE). where("#{TAXONOMY_JOIN_TABLE}.taxonomy_id" => any_context_taxonomies). pluck(:id) 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 'should write the public key to disk if its the first time its been seen' do @plugin.stubs(:lookup_config_option).with('learn_public_keys').returns('1') @plugin.stubs(:lookup_config_option).with('publickey_dir').returns('ssh/pkd') File.stubs(:directory?).with('ssh/pkd').returns(true) File.stubs(:exists?).with('ssh/pkd/rspec_pub.pem').returns(false) file = mock File.expects(:open).with('ssh/pkd/rspec_pub.pem', 'w').yields(file) file.expects(:puts).with('ssh-rsa abcd') @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
def initialize_copy(_) @nodes = @nodes.map &:dup 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_configs(params, request, session) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end if not $cluster_name or $cluster_name.empty? return JSON.generate({'status' => 'not_in_cluster'}) end if params[:cluster_name] != $cluster_name return JSON.generate({'status' => 'wrong_cluster_name'}) end out = { 'status' => 'ok', 'cluster_name' => $cluster_name, 'configs' => {}, } Cfgsync::get_configs_local.each { |name, cfg| out['configs'][cfg.class.name] = { 'type' => 'file', 'text' => cfg.text, } } return JSON.generate(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
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: scope }, "$explain" => true, "$orderby" => { _id: 1 } ) end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it 'should only print each format once with an exception' do lambda do @klass.format :foobar end.should raise_error(HTTParty::UnsupportedFormat, "':foobar' Must be one of: html, json, plain, xml") 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 new Log.add_info(request, params.inspect) mail_account_id = params[:mail_account_id] if mail_account_id.blank? account_xtype = params[:mail_account_xtype] SqlHelper.validate_token([account_xtype]) @mail_account = MailAccount.get_default_for(@login_user.id, account_xtype) else @mail_account = MailAccount.find(mail_account_id) if @mail_account.user_id != @login_user.id flash[:notice] = 'ERROR:' + t('msg.need_to_be_owner') render(:partial => 'common/flash_notice', :layout => false) return end end if $thetis_config[:menu]['disp_user_list'] == '1' unless params[:to_user_ids].blank? @email = Email.new to_addrs = [] @user_obj_cache ||= {} params[:to_user_ids].each do |user_id| user = User.find_with_cache(user_id, @user_obj_cache) user_emails = user.get_emails_by_type(nil) user_emails.each do |user_email| disp = EmailsHelper.format_address_exp(user.get_name, user_email, false) entry_val = "#{disp}" # "#{disp}#{Email::ADDR_ORDER_SEPARATOR}#{user.get_xorder(@group_id)}" to_addrs << entry_val end end @email.to_addresses = to_addrs.join(Email::ADDRESS_SEPARATOR) end end 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
def is_a_copy?(folder_obj_cache=nil) return false if self.source_id.nil? # Exclude those created from system templates. begin src_item = Item.find(self.source_id) rescue => evar src_item = nil end if src_item.nil? return true else return !src_item.in_system_folder?(folder_obj_cache) 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 connected? connection.connected? 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 add_constraint_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end case params["c_type"] when "loc" retval, error = add_location_constraint( session, params["res_id"], params["node_id"], params["score"], params["force"], !params['disable_autocorrect'] ) when "ord" resA = params["res_id"] resB = params["target_res_id"] actionA = params['res_action'] actionB = params['target_action'] if params["order"] == "before" resA, resB = resB, resA actionA, actionB = actionB, actionA end retval, error = add_order_constraint( session, resA, resB, actionA, actionB, params["score"], true, params["force"], !params['disable_autocorrect'] ) when "col" resA = params["res_id"] resB = params["target_res_id"] score = params["score"] if params["colocation_type"] == "apart" if score.length > 0 and score[0] != "-" score = "-" + score elsif score == "" score = "-INFINITY" end end retval, error = add_colocation_constraint( session, resA, resB, score, params["force"], !params['disable_autocorrect'] ) else return [400, "Unknown constraint type: #{params['c_type']}"] 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) begin @item = Item.find(params[:id]) rescue => evar @item = nil Log.add_error(request, evar) end end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it 'activates user when must_approve_users? is enabled' do SiteSetting.must_approve_users = true invite.invited_by = Fabricate(:admin) user = invite.redeem expect(user.approved?).to eq(true) end
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
def 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
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 status_reply reply = Moped::Protocol::Reply.new reply.count = 1 reply.documents = [status] reply 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 authorized?(request) terminus = get_terminus(request) if terminus.respond_to?(:authorized?) terminus.authorized?(request) else true end end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def wf_issue Log.add_info(request, params.inspect) begin @item = Item.find(params[:id]) @workflow = @item.workflow rescue => evar Log.add_error(request, evar) end attrs = ActionController::Parameters.new({status: Workflow::STATUS_ACTIVE, issued_at: Time.now}) @workflow.update_attributes(attrs.permit(Workflow::PERMIT_BASE)) @orders = @workflow.get_orders render(:partial => 'ajax_workflow', :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 save_page Log.add_info(request, params.inspect) # Next page pave_val = params[:page].to_i + 1 @page = sprintf('%02d', pave_val) page_num = Dir.glob(File.join(Research.page_dir, "_q[0-9][0-9].html.erb")).length unless params[:research].nil? params[:research].each do |key, value| if value.instance_of?(Array) value.compact! value.delete('') if value.empty? params[:research][key] = nil else params[:research][key] = value.join("\n") + "\n" end end end end if params[:research_id].nil? or params[:research_id].empty? @research = Research.new(params.require(:research).permit(Research::PERMIT_BASE)) @research.status = Research::U_STATUS_IN_ACTON @research.update_attribute(:user_id, @login_user.id) else @research = Research.find(params[:research_id]) @research.update_attributes(params.require(:research).permit(Research::PERMIT_BASE)) end if pave_val <= page_num render(:action => 'edit_page') else tmpl_folder, tmpl_q_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_RESEARCH) if tmpl_q_folder.nil? ary = TemplatesHelper.setup_tmpl_folder tmpl_q_folder = ary[4] end items = Folder.get_items_admin(tmpl_q_folder.id, 'xorder ASC') @q_caps_h = {} unless items.nil? items.each do |item| desc = item.description next if desc.nil? or desc.empty? hash = Research.select_q_caps(desc) hash.each do |key, val| @q_caps_h[key] = val end end end render(:action => 'confirm') end rescue => evar Log.add_error(request, evar) @page = '01' render(:action => 'edit_page') 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 initialize(locale, key, options = nil) @key, @locale, @options = key, locale, options.dup || {} options.each { |k, v| self.options[k] = v.inspect if v.is_a?(Proc) } end def html_message key = keys.last.to_s.gsub('_', ' ').gsub(/\b('?[a-z])/) { $1.capitalize } %(<span class="translation_missing" title="translation missing: #{keys.join('.')}">#{key}</span>) end def keys @keys ||= I18n.normalize_keys(locale, key, options[:scope]).tap do |keys| keys << 'no key' if keys.size < 2 end end def message "translation missing: #{keys.join('.')}" 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 make_rs256_token(payload = nil) payload = { sub: 'abc123' } if payload.nil? JWT.encode payload, rsa_private_key, 'RS256', kid: jwks_kid 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 self.find_q_codes(html) q_hash = {} # |q_code, q_param| return q_hash if html.nil? all = Research.get_q_codes q_codes = html.scan(/[$](q\d{2}_\d{2})/) unless q_codes.nil? yaml = Research.get_config_yaml q_codes.each do |q_code_a| q_code = q_code_a.first if all.include?(q_code) if yaml[q_code].nil? q_hash[q_code] = nil else q_hash[q_code] = Marshal.load(Marshal.dump(yaml[q_code])) end end end end return q_hash 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 enable_cluster(session) stdout, stderror, retval = run_cmd(session, PCS, "cluster", "enable") return false if retval != 0 return true 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 test_should_not_fall_for_xss_image_hack_with_uppercase_tags assert_sanitized %(<IMG """><SCRIPT>alert("XSS")</SCRIPT>">), "<img>\"&gt;" 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 diff(path, identifier_from, identifier_to=nil) hg_args = %w|rhdiff| if identifier_to hg_args << "-r#{hgrev(identifier_to)}" << "-r#{hgrev(identifier_from)}" else hg_args << "-c#{hgrev(identifier_from)}" end unless path.blank? p = scm_iconv(@path_encoding, 'UTF-8', path) hg_args << '--' << CGI.escape(hgtarget(p)) end diff = [] hg *hg_args do |io| io.each_line do |line| diff << line end end diff rescue HgCommandAborted nil # means not found end
1
Ruby
NVD-CWE-noinfo
null
null
null
safe
def escape_javascript(javascript) javascript = javascript.to_s if javascript.empty? result = "" else result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"'])/u, JS_ESCAPE_MAP) end javascript.html_safe? ? result.html_safe : result end
0
Ruby
CWE-80
Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
The software receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.
https://cwe.mitre.org/data/definitions/80.html
vulnerable
def destroy Log.add_info(request, params.inspect) return unless request.post? begin Item.destroy(params[:id]) rescue => evar Log.add_error(request, evar) end if params[:from_action].nil? render(:text => params[:id]) else params.delete(:controller) params.delete(:action) params.delete(:id) flash[:notice] = t('msg.delete_success') params[:action] = params[:from_action] redirect_to(params) 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 logout(database) auth.delete(database.to_s) 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 hiccup @set.manager.close_clients_for(self) end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def diff @diff ||= begin @paths = case options[:source] when 'strings' [tempfile(string1), tempfile(string2)] when 'files' [string1, string2] end if WINDOWS # don't use open3 on windows cmd = sprintf '"%s" %s %s', diff_bin, diff_options.join(' '), @paths.map { |s| %("#{s}") }.join(' ') diff = `#{cmd}` else diff = Open3.popen3(diff_bin, *(diff_options + @paths)) { |i, o, e| o.read } end diff.force_encoding('ASCII-8BIT') if diff.respond_to?(:valid_encoding?) && !diff.valid_encoding? if diff =~ /\A\s*\Z/ && !options[:allow_empty_diff] diff = case options[:source] when 'strings' then string1 when 'files' then File.read(string1) end.gsub(/^/, " ") end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def cluster_status_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end cluster_name = $cluster_name # If node is not in a cluster, return empty data if not cluster_name or cluster_name.empty? overview = { :cluster_name => nil, :error_list => [], :warning_list => [], :quorate => nil, :status => 'unknown', :node_list => [], :resource_list => [], } return JSON.generate(overview) end cluster_nodes = get_nodes().flatten status = cluster_status_from_nodes(session, cluster_nodes, cluster_name) unless status return 403, 'Permission denied' end 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 self.get_tree(folder_tree, conditions, parent, admin) if parent.instance_of?(Folder) tree_id = parent.id.to_s else tree_id = parent.to_s parent = nil if tree_id != '0' begin parent = Folder.find(tree_id) rescue end return folder_tree if parent.nil? end end group_obj_cache = {} folder_tree[tree_id] = [] if !parent.nil? and (parent.xtype == Folder::XTYPE_GROUP) Group.get_childs(parent.owner_id, false, true).each do |group| group_obj_cache[group.id] = group con = Marshal.load(Marshal.dump(conditions)) unless conditions.nil? if con.nil? con = '' else con << ' and ' end con << "(xtype='#{Folder::XTYPE_GROUP}') and (owner_id=#{group.id})" begin group_folder = Folder.where(con).first rescue => evar Log.add_error(nil, evar) end unless group_folder.nil? folder_tree[tree_id] << group_folder end end end con = Marshal.load(Marshal.dump(conditions)) unless conditions.nil? if con.nil? con = '' else con << ' and ' end con << "parent_id=#{tree_id}" folder_tree[tree_id] += Folder.where(con).order('xorder ASC, id ASC').to_a delete_ary = [] folder_tree[tree_id].each do |folder| if !admin and (folder.xtype == Folder::XTYPE_SYSTEM) delete_ary << folder next end if (tree_id == '0') and (folder.xtype == Folder::XTYPE_GROUP) group = Group.find_with_cache(folder.owner_id, group_obj_cache) unless group.nil? if group.parent_id != 0 delete_ary << folder next end end end folder_tree = Folder.get_tree(folder_tree, conditions, folder, admin) end folder_tree[tree_id] -= delete_ary return folder_tree end
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