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.get_childs(klass, node_id, recursive, ret_obj) SqlHelper.validate_token([node_id]) array = [] if recursive tree = klass.get_tree(Hash.new, nil, node_id) return array if tree.nil? tree.each do |parent_id, childs| if ret_obj array |= childs else ...
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "executes the operation on the master node" do session.should_receive(:socket_for).with(:write). and_return(socket) socket.should_receive(:execute).with(operation) session.execute(operation) end
0
Ruby
CWE-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_for(user_id, fiscal_year=nil) SqlHelper.validate_token([user_id, fiscal_year]) begin con = [] con << "(user_id=#{user_id.to_i})" if fiscal_year.nil? return PaidHoliday.where(con).order('year ASC').to_a else con << "(year=#{fiscal_year.to_i})" retu...
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def reset_users Log.add_info(request, params.inspect) count = 0 unless params[:check_user].nil? params[:check_user].each do |user_id, value| if value == '1' begin Research.destroy_all('user_id=' + user_id.to_s) count += 1 rescue => evar ...
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 category_preferences_export return enum_for(:category_preferences_export) unless block_given? CategoryUser .where(user_id: @current_user.id) .select(:category_id, :notification_level, :last_seen_at) .each do |cu| yield [ cu.category_id, piped_cate...
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 output_versions output, versions versions.each do |gem_name, matching_tuples| matching_tuples = matching_tuples.sort_by { |n,_| n.version }.reverse platforms = Hash.new { |h,version| h[version] = [] } matching_tuples.each do |n, _| platforms[n.version] << n.platform if n.platform ...
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 on_moved Log.add_info(request, params.inspect) location_id = params[:id] if location_id.nil? or location_id.empty? location = Location.get_for(@login_user) if location.nil? location = Location.new location.user_id = @login_user.id end else begin lo...
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 record(node, operations) key = if node.primary? :primary elsif node.secondary? :secondary else :other 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 "logs out" do lambda do session.command dbStats: 1 end.should_not raise_exception session.logout lambda do session.command dbStats: 1 end.should raise_exception(Moped::Errors::OperationFailure) 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 should be a subclass of Base" do Puppet::FileServing::Metadata.superclass.should equal(Puppet::FileServing::Base) end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
def self.destroy(host) if host =~ Regexp.union(/[#{SEPARATOR}]/, /\A\.\.?\Z/) raise ArgumentError, "Invalid node name #{host.inspect}" end dir = File.join(Puppet[:reportdir], host) if File.exists?(dir) Dir.entries(dir).each do |file| next if ['.','..'].include?(file) file...
1
Ruby
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of t...
https://cwe.mitre.org/data/definitions/22.html
safe
it "returns the master connection" do cluster.socket_for(:read).should eq socket end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def get_tokens(params, request, session) # pcsd runs as root thus always returns hacluster's tokens if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end return [200, JSON.generate(read_tokens)] 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 initialize(nodes = 3) @nodes = nodes.times.map { Node.new(self) } @manager = ConnectionManager.new(@nodes) @mongo = TCPSocket.new "127.0.0.1", 27017 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_ally_request_link(uniqueid, data) link = "/profile?uid=#{data[:uid]}" link_html = "<a href=\"#{link}\">#{data[:user]}</a>" # rubocop:disable Layout/LineLength "<div id=\"#{uniqueid}\"><div>#{t('notifications.ally.sent_html', link_to_user: link_html)}</div>#{request_actions(data[:user_id])}</di...
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 first session.simple_query(operation) 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 each documents = query @query_op documents.each { |doc| yield doc } while more? return kill if limited? && @get_more_op.limit <= 0 documents = query @get_more_op documents.each { |doc| yield doc } end end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def paginate_by_sql(model, sql, per_page, options={}) if options[:count].blank? total = model.count_by_sql_wrapping_select_query(sql) else if options[:count].is_a?(Integer) total = options[:count] #else # total = model.count_by_sql(options[:count]) end end SqlHe...
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 empty Log.add_info(request, params.inspect) @folder_id = params[:id] mail_account_id = params[:mail_account_id] SqlHelper.validate_token([mail_account_id]) trash_folder = MailFolder.get_for(@login_user, mail_account_id, MailFolder::XTYPE_TRASH) mail_folder = MailFolder.find(@folder_id) ...
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def mime_magic_content_type(new_file) content_type = nil File.open(new_file.path) do |fd| content_type = Marcel::MimeType.for(fd) end content_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 test_jail_classes_should_have_limited_methods expected = ["new", "methods", "name", "inherited", "method_added", "inspect", "allow", "allowed?", "allowed_methods", "init_allowed_methods", "<", # < needed in Rails Object#subclasses_of "ancestors", "==" # ancestor...
0
Ruby
CWE-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 replica_set_session(auth = true) session = Moped::Session.new replica_set_seeds, database: replica_set_database session.login *replica_set_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
it "sets the generation time" do time = Time.at((Time.now.utc - 64800).to_i).utc Moped::BSON::ObjectId.from_time(time).generation_time.should == time 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 logout session.context.logout(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
it 'should return a second factor prompt' do get "/session/email-login/#{email_token.token}" expect(response.status).to eq(200) response_body = CGI.unescapeHTML(response.body) expect(response_body).to include(I18n.t( "login.second_factor_title" ...
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_carried_over(user_id, year) SqlHelper.validate_token([user_id, year]) yaml = ApplicationHelper.get_config_yaml unless yaml[:timecard].nil? paidhld_carry_over = yaml[:timecard]['paidhld_carry_over'] end return 0 if paidhld_carry_over.nil? or paidhld_carry_over.empty? or paidhl...
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 from_string(string) unless legal?(string) raise Invalid.new("'#{string}' is an invalid ObjectId.") end from_data([ string ].pack("H*")) 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 send_password Log.add_info(request, params.inspect) mail_addr = params[:thetisBoxEdit] SqlHelper.validate_token([mail_addr], ['@-']) begin users = User.where("email='#{mail_addr}'").to_a rescue => evar end if users.nil? or users.empty? Log.add_error(request, evar) f...
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 build_command_line(command, params = nil) return command.to_s if params.nil? || params.empty? "#{command} #{assemble_params(sanitize(params))}" 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 _call(env) unless ALLOWED_VERBS.include? env["REQUEST_METHOD"] return fail(405, "Method Not Allowed") end path_info = Utils.unescape(env["PATH_INFO"]) parts = path_info.split SEPS parts.inject(0) do |depth, part| case part when '', '.' depth ...
0
Ruby
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of t...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def one_time_password otp_username = $redis.get "otp_#{params[:token]}" if otp_username && user = User.find_by_username(otp_username) log_on_user(user) $redis.del "otp_#{params[:token]}" return redirect_to path("/") else @error = I18n.t('user_api_key.invalid_token') end r...
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def set_admin User.current = users(:admin) 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 __bson_dump__(io, key) io << Types::OBJECT_ID io << key io << NULL_BYTE io << data.pack('C12') end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def test_clone get :clone, {:id => hostgroups(:common)}, set_session_user assert_template 'new' 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 generate(type, str) case type when :md5 attribute_value = '{MD5}' + Base64.encode64(Digest::MD5.digest(str)).chomp! when :sha attribute_value = '{SHA}' + Base64.encode64(Digest::SHA1.digest(str)).chomp! when :ssha srand; salt = (rand * 1000).to_i.to_s ...
0
Ruby
CWE-916
Use of Password Hash With Insufficient Computational Effort
The software generates a hash for a password, but it uses a scheme that does not provide a sufficient level of computational effort that would make password cracking attacks infeasible or expensive.
https://cwe.mitre.org/data/definitions/916.html
vulnerable
def self.authenticate(attrs) return nil if attrs.nil? or attrs[:name].nil? or attrs[:password].nil? name = attrs[:name] password = attrs[:password] SqlHelper.validate_token([name]) pass_md5 = UsersHelper.generate_digest_pass(name, password) return User.where("(name='#{name}') and (pass_md...
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_folders_order Log.add_info(request, params.inspect) @folder_id = params[:id] if @folder_id == '0' @folders = MailFolder.get_account_roots_for(@login_user) else mail_folder = MailFolder.find(@folder_id) if mail_folder.user_id == @login_user.id @folders = MailFolder.g...
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 command(database, cmd, options = {}) operation = Protocol::Command.new(database, cmd, options) process(operation) do |reply| result = reply.documents[0] raise Errors::OperationFailure.new( operation, result ) if result["ok"] != 1 || result["err"] || result["errmsg...
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 lookup_server(client) port = client.addr(false)[1] @servers.find do |server| server.to_io && server.to_io.addr[1] == port 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
it "updates a hostgroup with a parent parameter, allows empty values" do child = FactoryGirl.create(:hostgroup, :parent => @base) as_admin do assert_equal "original", child.parameters["x"] end post :update, {"id" => child.id, "hostgroup" => {"name" => child.name, ...
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 check_mail_owner return if params[:id].blank? 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) ...
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 down? @down_at 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 connect(host, port, timeout) @sock = TCPSocket.connect host, port, timeout end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
it 'returns success' do get "/session/email-login/#{email_token.token}" expect(response).to redirect_to("/") end
0
Ruby
CWE-287
Improper Authentication
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
it 'does not parse scientific notation' do expect(Raven::OkJson.decode("[123e090]")).to eq ["123e090"] end
1
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
safe
def week Log.add_info(request, params.inspect) date_s = params[:date] if date_s.blank? @date = Date.today else @date = Date.parse(date_s) end params[:display] = 'week' 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 valid_back_url?(back_url) !!validate_back_url(back_url) end
1
Ruby
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
safe
def login(database, username, password) cluster.auth[database.to_s] = [username, password] end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def create Log.add_info(request, params.inspect) return unless request.post? my_wf_folder = WorkflowsHelper.get_my_wf_folder(@login_user.id) tmpl_item = Item.find(params[:select_workflow]) item = tmpl_item.copy(@login_user.id, my_wf_folder.id) attrs = ActionController::Parameters.new({tit...
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def add_location_constraint( session, resource, node, score, force=false, autocorrect=true ) if node == "" return "Bad node" end if score == "" nodescore = node else nodescore = node + "=" + score end cmd = [PCS, "constraint", "location", resource, "prefers", nodescore] cmd << '--force' if...
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.destroy_by_user(user_id, add_con=nil) SqlHelper.validate_token([user_id]) con = "user_id=#{user_id}" con << " and (#{add_con})" unless add_con.nil? or add_con.empty? emails = Email.where(con).to_a emails.each do |email| email.destroy 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 select_official_titles Log.add_info(request, params.inspect) @user = User.find(params[:user_id]) unless params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxSelKeeper].split(':').last end SqlHelper.validate_token([@group_id]) if @group_id.nil? @official_titles = Off...
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def setup FactoryGirl.create(:host) 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 "raises no exception" do lambda do cluster.sync_server server end.should_not raise_exception 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 secondaries servers.select(&:secondary?) 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 "creates a new cursor" do cursor = mock(Moped::Cursor, next: nil) Moped::Cursor.should_receive(:new). with(session, query.operation).and_return(cursor) query.each 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 "fetches more" do users.insert(102.times.map { Hash["scope" => scope] }) stats = Support::Stats.collect do users.find(scope: scope).entries end stats[node_for_reads].grep(Moped::Protocol::GetMore).count.should eq 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 "approves pending record" do reviewable = ReviewableUser.needs_review!(target: Fabricate(:user, email: invite.email), created_by: invite.invited_by) reviewable.status = Reviewable.statuses[:pending] reviewable.save! invite_redeemer.redeem reviewable.reload expec...
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
it "should escape the return path address" do Mail.defaults do delivery_method :exim end mail = Mail.new do to 'to@test.lindsaar.net' from '"from+suffix test"@test.lindsaar.net' subject 'Can\'t set the return-path' message_id '<1234@test.lindsaar.net>' ...
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 "drops the index that matches the key" do indexes[name: 1].should be_nil 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 __bson_load__(io) new io.read(12).unpack('C*') 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 choose :rest when the Settings name isn't 'puppet'" do @request.stubs(:protocol).returns "puppet" # We have to stub this because we can't set name Puppet.settings.stubs(:value).with(:name).returns "foo" @object.select(@request).should == :rest 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 "returns the same hash" do Moped::BSON::ObjectId.new(bytes).hash.should eq Moped::BSON::ObjectId.new(bytes).hash 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 "parses yaml" do YAML.should_receive(:load).with('body') subject.send(:yaml) 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
it "should fail when a protocol other than :puppet or :file is used" do @request.stubs(:protocol).returns "http" proc { @object.select_terminus(@request) }.should raise_error(ArgumentError) 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 replica_set_database ENV["MONGOHQ_REPL_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
it "respects #skip" do users.find(scope: scope).skip(1).one.should eq documents.last 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) @mail_folder = MailFolder.find(params[:id]) unless params[:thetisBoxEdit].nil? or params[:thetisBoxEdit].empty? @mail_folder.name = params[:thetisBoxEdit] @mail_folder.save end render(:partial => 'ajax_folder_name', :layout => false) ...
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 rename Log.add_info(request, params.inspect) return unless request.post? @group = Group.find(params[:id]) unless params[:thetisBoxEdit].blank? @group.rename(params[:thetisBoxEdit]) end render(:partial => 'ajax_group_name', :layout => false) rescue => evar Log.add_error(reque...
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 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) ...
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 load_object if @user.update(user_params) if params[:user][:password].present? # this logic needed b/c devise wants to log us out after password changes Spree.user_class.reset_password_by_token(params[:user]) if Spree::Auth::Config[:signout_after_password_change] ...
1
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
safe
def install! Moped::Node.class_eval <<-EOS alias _logging logging def logging(operations, &block) Support::Stats.record(self, operations) _logging(operations, &block) end EOS 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_workflows Log.add_info(request, params.inspect) @group_id = (params[:id] || '0') # '0' for ROOT SqlHelper.validate_token([@group_id]) ary = TemplatesHelper.get_tmpl_folder unless ary.nil? or ary.empty? @tmpl_workflows_folder = ary[2] end session[:group_id] = params[:id] ...
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def self.get_for_group(group_id) SqlHelper.validate_token([group_id]) if group_id.nil? con = 'group_id is null' else con = "group_id=#{group_id.to_i}" end Location.do_expire(con) return Location.where(con).to_a end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def update(database, collection, selector, change, options = {}) with_node do |node| if safe? node.pipeline do node.update(database, collection, selector, change, options) node.command("admin", { getlasterror: 1 }.merge(safety)) end e...
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def insert(database, collection, documents) process Protocol::Insert.new(database, collection, documents) 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_pacemaker_version() begin stdout, stderror, retval = run_cmd( PCSAuth.getSuperuserSession, PACEMAKERD, "-$" ) rescue stdout = [] end if retval == 0 match = /(\d+)\.(\d+)\.(\d+)/.match(stdout.join()) if match return match[1..3].collect { | x | x.to_i } end end retu...
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 add_to_group Log.add_info(request, params.inspect) if params[:thetisBoxSelKeeper].nil? or params[:thetisBoxSelKeeper].empty? render(:partial => 'ajax_groups', :layout => false) return end group_id = params[:thetisBoxSelKeeper].split(':').last unless group_id == '0' # '0' for ROO...
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 "should get a 200 with html for an authorized user" do def @bus.is_admin_lookup proc { |_| true } end get "/message-bus/_diagnostics" last_response.status.must_equal 200 end
0
Ruby
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of t...
https://cwe.mitre.org/data/definitions/22.html
vulnerable
it "stores the list of seeds" do cluster.seeds.should eq ["127.0.0.1:27017", "127.0.0.1:27018"] 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 do_project_release( params ) User.current ||= User.find_by_login(params[:user]) check_write_access! packages.each do |pkg| pkg.project.repositories.each do |repo| next if params[:repository] and params[:repository] != repo.name repo.release_targets.each do |releasetarget| ...
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 get_users if params[:action] == 'get_users' Log.add_info(request, params.inspect) end @group_id = params[:id] =begin # @users = Group.get_users(params[:id]) =end # FEATURE_PAGING_IN_TREE >>> con = ['User.id > 0'] unless @group_id.nil? if @group_id == '0' con << "((gr...
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 ==(other) resolved_address == other.resolved_address 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 'fails when local logins is disabled' do SiteSetting.enable_local_logins = false get "/session/email-login/#{email_token.token}" expect(response.status).to eq(500) end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def test_edit get :edit, {:id => hostgroups(:common)}, 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 resource_form(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end cib_dom = get_cib_dom(session) @cur_resource = get_resource_by_id(params[:resource], cib_dom) @groups = get_resource_groups(cib_dom) @version = params[:version] ...
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 auth(params, request, session) token = PCSAuth.validUser(params['username'],params['password'], true) # If we authorized to this machine, attempt to authorize everywhere node_list = [] if token and params["bidirectional"] params.each { |k,v| if k.start_with?("node-") node_list.push(v) ...
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 auth_node_configured? 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
it "returns a session with the provided options" do safe = session.with(safe: true) safe.options[:safe].should eq true end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def test_crlf_injection smtp = Net::SMTP.new 'localhost', 25 smtp.instance_variable_set :@socket, FakeSocket.new assert_raise(ArgumentError) do smtp.mailfrom("foo\r\nbar") end assert_raise(ArgumentError) do smtp.mailfrom("foo\rbar") end assert_raise(Argum...
1
Ruby
CWE-93
Improper Neutralization of CRLF Sequences ('CRLF Injection')
The software uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.
https://cwe.mitre.org/data/definitions/93.html
safe
def ajax_move_mails Log.add_info(request, params.inspect) folder_id = params[:thetisBoxSelKeeper].split(':').last mail_folder = MailFolder.find_by_id(folder_id) if folder_id == '0' \ or mail_folder.nil? \ or mail_folder.user_id != @login_user.id flash[:notice] = 'ERROR:' + t('m...
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 "adds the server to the list" do cluster.sync_server server cluster.servers.should include server 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 private_messages_for(user, type) options = @options options.reverse_merge!(per_page: per_page_setting) result = Topic.includes(:allowed_users) result = result.includes(:tags) if SiteSetting.tagging_enabled if type == :group result = result.joins( "INNER JOIN top...
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
def ajax_move_users Log.add_info(request, params.inspect) return unless request.post? org_group_id = params[:id] group_id = params[:thetisBoxSelKeeper].split(':').last SqlHelper.validate_token([org_group_id, group_id]) unless params[:check_user].blank? count = 0 params[:check_u...
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 remote_add_node(params, request, session, all=false) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end auto_start = false if params[:auto_start] and params[:auto_start] == "1" auto_start = true end if params[:new_nodename] != nil node = params[...
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def assemble_params(sanitized_params) sanitized_params.collect do |pair| pair_joiner = pair.first.to_s.end_with?("=") ? "" : " " pair.flatten.compact.join(pair_joiner) end.join(" ") 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 ffi_lib(*names) raise LoadError.new("library names list must not be empty") if names.empty? lib_flags = defined?(@ffi_lib_flags) ? @ffi_lib_flags : FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL ffi_libs = names.map do |name| if name == FFI::CURRENT_PROCESS ...
0
Ruby
CWE-426
Untrusted Search Path
The application searches for critical resources using an externally-supplied search path that can point to resources that are not under the application's direct control.
https://cwe.mitre.org/data/definitions/426.html
vulnerable
def load_file(filename) Gem.load_yaml yaml_errors = [ArgumentError] yaml_errors << Psych::SyntaxError if defined?(Psych::SyntaxError) return {} unless filename and File.exist? filename begin content = YAML.load(File.read(filename)) unless content.kind_of? Hash warn "Failed t...
0
Ruby
CWE-502
Deserialization of Untrusted Data
The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
def resource_ungroup(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end unless params[:group_id] return [400, 'group_id has to be specified.'] end _, stderr, retval = run_cmd( session, PCS, 'resource', 'ungroup', params[:...
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def ==(other) @host == other.host && @port == other.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