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 create_local Log.add_info(request, params.inspect) return unless request.post? @tmpl_folder, @tmpl_local_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_LOCAL) unless @tmpl_local_folder.nil? item = Item.new_info(@tmpl_local_folder.id) item.title = t('template.new') item.user_id = 0 item.save! else Log.add_error(request, nil, '/'+TemplatesHelper::TMPL_ROOT+'/'+TemplatesHelper::TMPL_LOCAL+' NOT found!') end render(:partial => 'ajax_local', :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 find(request) get_terminus(request).find(request) end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
it 'returns success' do get "/session/email-login/#{email_token.token}" expect(response).to redirect_to("/") end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def ensure_connected # Don't run the reconnection login if we're already inside an # +ensure_connected+ block. return yield if Threaded.executing? :connection Threaded.begin :connection retry_on_failure = true begin connect unless connected? yield rescue Errors::ReplicaSetReconfigured # Someone else wrapped this in an #ensure_primary block, so let the # reconfiguration exception bubble up. raise rescue Errors::OperationFailure, Errors::AuthenticationFailure, Errors::QueryFailure # These exceptions are "expected" in the normal course of events, and # don't necessitate disconnecting. raise rescue Errors::ConnectionFailure disconnect if retry_on_failure # Maybe there was a hiccup -- try reconnecting one more time retry_on_failure = false retry else # Nope, we failed to connect twice. Flag the node as down and re-raise # the exception. down! raise end rescue # Looks like we got an unexpected error, so we'll clean up the connection # and re-raise the exception. disconnect raise $!.extend(Errors::SocketError) end ensure Threaded.end :connection
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_quorum_info(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end if ISRHEL6 stdout_status, stderr_status, retval = run_cmd( PCSAuth.getSuperuserSession, CMAN_TOOL, "status" ) stdout_nodes, stderr_nodes, retval = run_cmd( PCSAuth.getSuperuserSession, CMAN_TOOL, "nodes", "-F", "id,type,votes,name" ) if stderr_status.length > 0 return stderr_status.join elsif stderr_nodes.length > 0 return stderr_nodes.join else return stdout_status.join + "\n---Votes---\n" + stdout_nodes.join end else stdout, stderr, retval = run_cmd( PCSAuth.getSuperuserSession, COROSYNC_QUORUMTOOL, "-p", "-s" ) # retval is 0 on success if node is not in partition with quorum # retval is 1 on error OR on success if node has quorum if stderr.length > 0 return stderr.join else return stdout.join end end end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def reset_users Log.add_info(request, params.inspect) return unless request.post? count = 0 unless params[:check_user].nil? params[:check_user].each do |user_id, value| if value == '1' SqlHelper.validate_token([user_id]) begin Research.destroy_all("user_id=#{user_id.to_i}") count += 1 rescue => evar Log.add_error(request, evar) end end end end if count > 0 flash[:notice] = t('msg.status_of')+ count.to_s + t('user.status_reset') end redirect_to(:controller => 'researches', :action => 'users') rescue => evar Log.add_error(request, evar) render(:text => evar.to_s) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def test_escape_backtick assert_equal "\\`", escape_javascript("`") end
1
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
safe
def write(*args) raise Errors::ConnectionFailure, "Socket connection was closed by remote host" unless alive? super 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_update_invalid Medium.any_instance.stubs(:valid?).returns(false) put :update, {:id => Medium.first, :medium => {:name => nil}}, set_session_user assert_template 'edit' end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
def update_fence_device(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end $logger.info "Updating fence device" $logger.info params param_line = getParamList(params) $logger.info param_line if not params[:resource_id] out, stderr, retval = run_cmd( session, PCS, "stonith", "create", params[:name], params[:resource_type], *param_line ) if retval != 0 return JSON.generate({"error" => "true", "stderr" => stderr, "stdout" => out}) end return "{}" end if param_line.length != 0 out, stderr, retval = run_cmd( session, PCS, "stonith", "update", params[:resource_id], *param_line ) if retval != 0 return JSON.generate({"error" => "true", "stderr" => stderr, "stdout" => out}) end end return "{}" 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_mailfrom sock = FakeSocket.new smtp = Net::SMTP.new 'localhost', 25 smtp.instance_variable_set :@socket, sock assert smtp.mailfrom("[email protected]").success? assert_equal "MAIL FROM:<[email protected]>\r\n", sock.write_io.string end
1
Ruby
CWE-93
Improper Neutralization of CRLF Sequences ('CRLF Injection')
The software uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.
https://cwe.mitre.org/data/definitions/93.html
safe
it 'fails when local logins via email is disabled' do SiteSetting.enable_local_logins_via_email = false get "/session/email-login/#{email_token.token}" expect(response.status).to eq(404) 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_team_folder(team_id) SqlHelper.validate_token([team_id]) begin return Folder.where("(owner_id=#{team_id.to_i}) and (xtype='#{Folder::XTYPE_TEAM}')").first rescue => evar Log.add_error(nil, evar) return nil end end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def update_q_ctrl Log.add_info(request, params.inspect) item_id = params[:item_id] q_code = params[:q_code] q_param = params[:q_param] cap = params[:caption] yaml = Research.get_config_yaml type = q_param.split(':').first vals = q_param[type.length+1 .. -1] yaml[q_code] = {:item_id => item_id, :type => type, :values => vals, :caption => cap.to_s } Research.save_config_yaml yaml render(:text => '') rescue => evar Log.add_error(request, evar) render(:text => evar.to_s) 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.trim(user_id, mail_account_id, max) SqlHelper.validate_token([user_id, mail_account_id]) begin count = Email.where("mail_account_id=#{mail_account_id}").count if count > max #logger.fatal("[INFO] Email.trim(user_id:#{user_id}, mail_account_id:#{mail_account_id}, max:#{max})") over_num = count - max emails = [] # First, empty Trashbox user = User.find(user_id) trashbox = MailFolder.get_for(user, mail_account_id, MailFolder::XTYPE_TRASH) trash_nodes = [trashbox.id.to_s] trash_nodes += MailFolder.get_childs(trash_nodes.first, true, false) con = "mail_folder_id in (#{trash_nodes.join(',')})" emails = Email.where(con).order('updated_at ASC').limit(over_num).to_a # Now, remove others if emails.length < over_num over_num -= emails.length emails += Email.where("mail_account_id=#{mail_account_id}").order('updated_at ASC').limit(over_num).to_a end emails.each do |email| email.destroy end end rescue 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 status { "ismaster" => @primary, "secondary" => @secondary, "hosts" => @set.nodes.map(&:address), "me" => address, "maxBsonObjectSize" => 16777216, "ok" => 1.0 } 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 be a subclass of Base" do Puppet::FileServing::Content.superclass.should equal(Puppet::FileServing::Base) end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def self.get_comment_of(item_id, user_id) SqlHelper.validate_token([item_id, user_id]) begin comment = Comment.where("(user_id=#{user_id}) and (item_id=#{item_id}) and (xtype='#{Comment::XTYPE_DIST_ACK}')").first rescue => evar Log.add_error(nil, evar) end return comment end
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 install_location filename, destination_dir # :nodoc: raise Gem::Package::PathError.new(filename, destination_dir) if filename.start_with? '/' destination_dir = File.realpath destination_dir if File.respond_to? :realpath destination_dir = File.expand_path destination_dir destination = File.join destination_dir, filename destination = File.realpath destination if File.respond_to? :realpath destination = File.expand_path destination raise Gem::Package::PathError.new(destination, destination_dir) unless destination.start_with? destination_dir + '/' destination.untaint destination 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 the restricted directory.
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def test_render_with_explicit_unescaped_template assert_raise(ActionView::MissingTemplate) { get :render_with_explicit_unescaped_template } get :render_with_explicit_escaped_template assert_equal "Hello w*rld!", @response.body 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 :test_render_parse_nil_param do assert_raises(ArgumentError) { parser.parse_memory(nil) } 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 auth_node_configured? ENV["MONGOHQ_SINGLE_PASS"] 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 proxy(client, mongo) incoming_message = client.read(16) length, op_code = incoming_message.unpack("l<x8l<") incoming_message << client.read(length - 16) if op_code == OP_QUERY && ismaster_command?(incoming_message) # Intercept the ismaster command and send our own reply. client.write status_reply else # This is a normal command, so proxy it to the real mongo instance. mongo.write incoming_message if op_code == OP_QUERY || op_code == OP_GETMORE outgoing_message = mongo.read(4) length, = outgoing_message.unpack('l<') outgoing_message << mongo.read(length - 4) client.write outgoing_message end end end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def self.parse_csv_row(row, book, idxs, user) imp_id = (idxs[0].nil? or row[idxs[0]].nil?)?(nil):(row[idxs[0]].strip) SqlHelper.validate_token([imp_id]) unless imp_id.blank? org_address = Address.find_by_id(imp_id) end if org_address.nil? address = Address.new else address = org_address end address.id = imp_id attr_names = [ :name, :name_ruby, :nickname, :screenname, :email1, :email2, :email3, :postalcode, :address, :tel1_note, :tel1, :tel2_note, :tel2, :tel3_note, :tel3, :fax, :url, :organization, :title, :memo, :xorder, :groups, :teams ] attr_names.each_with_index do |attr_name, idx| row_idx = idxs[idx+1] break if row_idx.nil? val = (row[row_idx].nil?)?(nil):(row[row_idx].strip) address.send(attr_name.to_s + '=', val) end if (address.groups == Address::EXP_IMP_FOR_ALL) \ or (book == Address::BOOK_COMMON and address.groups.blank? and address.teams.blank?) address.groups = nil address.teams = nil address.owner_id = 0 elsif !address.groups.blank? or !address.teams.blank? address.owner_id = 0 else address.owner_id = user.id end return address end
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 "removes the stored credentials" do cluster.logout :admin cluster.auth.should be_empty 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 deliver!(mail) envelope_from = mail.return_path || mail.sender || mail.from_addrs.first return_path = "-f " + '"' + envelope_from.escape_for_shell + '"' if envelope_from arguments = [settings[:arguments], return_path].compact.join(" ") self.class.call(settings[:location], arguments, mail.destinations.collect(&:escape_for_shell).join(" "), mail) 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_configs_cluster(nodes, cluster_name) data = { 'cluster_name' => cluster_name, } $logger.debug 'Fetching configs from the cluster' threads = [] node_configs = {} nodes.each { |node| threads << Thread.new { code, out = send_request_with_token( @session, node, 'get_configs', false, data ) if 200 == code begin parsed = JSON::parse(out) if 'ok' == parsed['status'] and cluster_name == parsed['cluster_name'] node_configs[node], _ = Cfgsync::sync_msg_to_configs(parsed) end rescue JSON::ParserError end end } } threads.each { |t| t.join } return node_configs 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 disconnect auth.clear connection.disconnect 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 on_moved Log.add_info(request, params.inspect) return unless request.post? location_id = params[:id] SqlHelper.validate_token([location_id]) if location_id.blank? location = Location.get_for(@login_user) if location.nil? location = Location.new location.user_id = @login_user.id end else begin location = Location.find(location_id) rescue location = nil end end unless location.nil? group_id = params[:group_id] group_id = nil if group_id.empty? SqlHelper.validate_token([group_id]) attrs = ActionController::Parameters.new({group_id: group_id, x: params[:x], y: params[:y]}) location.update_attributes(attrs.permit(Location::PERMIT_BASE)) end render(:text => (location.nil?)?'':location.id.to_s) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def initialize(hosts, options) @options = { down_interval: 30, refresh_interval: 300 }.merge(options) @seeds = hosts @nodes = hosts.map { |host| Node.new(host) } 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 connect connection.connect ip_address, port, timeout @down_at = nil refresh rescue Timeout::Error raise Errors::ConnectionFailure, "Timed out connection to Mongo on #{address}" rescue Errno::ECONNREFUSED raise Errors::ConnectionFailure, "Could not connect to Mongo on #{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
def _unmarshal(val, options) unmarshal?(val, options) ? Marshal.load(val) : val end
0
Ruby
CWE-502
Deserialization of Untrusted Data
The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
it "sets the object id's data" do Moped::BSON::ObjectId.new(bytes).data.should == bytes 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 api_endpoint(uri) host = uri.host begin res = @dns.getresource "_rubygems._tcp.#{host}", Resolv::DNS::Resource::IN::SRV rescue Resolv::ResolvError => e verbose "Getting SRV record failed: #{e}" uri else target = res.target.to_s.strip if /\.#{Regexp.quote(host)}\z/ =~ target return URI.parse "#{uri.scheme}://#{target}#{uri.path}" end uri end end
0
Ruby
CWE-346
Origin Validation Error
The software does not properly verify that the source of data or communication is valid.
https://cwe.mitre.org/data/definitions/346.html
vulnerable
def set_cluster_conf(params, request, session) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end if params[:cluster_conf] != nil and params[:cluster_conf].strip != "" Cfgsync::ClusterConf.backup() Cfgsync::ClusterConf.from_text(params[:cluster_conf]).save() return 200, 'Updated cluster.conf...' else $logger.info "Invalid cluster.conf file" return 400, 'Failed to update cluster.conf...' end end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def add_order_constraint( session, resourceA, resourceB, actionA, actionB, score, symmetrical=true, force=false, autocorrect=true ) sym = symmetrical ? "symmetrical" : "nonsymmetrical" if score != "" score = "score=" + score end command = [ PCS, "constraint", "order", actionA, resourceA, "then", actionB, resourceB, score, sym ] command << '--force' if force command << '--autocorrect' if autocorrect stdout, stderr, retval = run_cmd(session, *command) return retval, stderr.join(' ') end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def self.get_for(mail_account_id, enabled=nil, trigger=nil) return [] if mail_account_id.nil? SqlHelper.validate_token([mail_account_id, trigger]) con = [] con << "(mail_account_id=#{mail_account_id.to_i})" con << "(enabled=#{(enabled)?(1):(0)})" unless enabled.nil? con << SqlHelper.get_sql_like([:triggers], "|#{trigger}|") unless trigger.nil? return MailFilter.where(con.join(' and ')).order('(xorder is null) ASC, xorder ASC, id ASC').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
it "stores whether the connection is direct" do cluster.direct.should be_true end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def read_config(self, config, **kwargs): self.recaptcha_private_key = config.get("recaptcha_private_key") self.recaptcha_public_key = config.get("recaptcha_public_key") self.enable_registration_captcha = config.get( "enable_registration_captcha", False ) self.recaptcha_siteverify_api = config.get( "recaptcha_siteverify_api", "https://www.recaptcha.net/recaptcha/api/siteverify", ) self.recaptcha_template = self.read_templates( ["recaptcha.html"], autoescape=True )[0]
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 "doesn't try to set flags" do session.stub(socket_for: socket) expect { session.query(query) }.not_to 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 is_a_copy?(folder_obj_cache=nil) return false if self.source_id.nil? # Exclude those created from system templates. src_item = Item.find_by_id(self.source_id) if src_item.nil? return true else return !src_item.in_system_folder?(folder_obj_cache) 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 url_valid?(url) url = begin URI.parse(url) rescue StandardError false end url.is_a?(URI::HTTP) || url.is_a?(URI::HTTPS) 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 create_profile_sheet Log.add_info(request, params.inspect) return unless request.post? user_id = params[:id] @user = User.find(user_id) @item = @user.create_profile_sheet @user.update_attribute(:item_id, @item.id) render(:partial => 'ajax_profile_sheet', :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 "should reject a subjectAltName for a non-DNS value" do @request.stubs(:subject_alt_names).returns ['DNS:foo', 'email:[email protected]'] expect { @ca.check_internal_signing_policies(@name, @request, true) }.to raise_error( Puppet::SSL::CertificateAuthority::CertificateSigningError, /subjectAltName outside the DNS label space/ ) 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 rename Log.add_info(request, params.inspect) return unless request.post? @mail_folder = MailFolder.find(params[:id]) unless params[:thetisBoxEdit].blank? @mail_folder.name = params[:thetisBoxEdit] @mail_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
def self.find_by_sql_with_limit(sql, offset, limit) sql = sanitize_sql(sql) add_limit!(sql, {:limit => limit, :offset => offset}) find_by_sql(sql) 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_equipment Log.add_info(request, params.inspect) @group_id = nil if !params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxSelKeeper].split(':').last elsif !params[:group_id].nil? and !params[:group_id].empty? @group_id = params[:group_id] end submit_url = url_for(:controller => 'schedules', :action => 'get_group_equipment') render(:partial => 'common/select_equipment', :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 update_by_ajax Log.add_info(request, params.inspect) return unless request.post? cat_h = {:desktop => User::AUTH_DESKTOP, :user => User::AUTH_USER, :log => User::AUTH_LOG} yaml = ApplicationHelper.get_config_yaml cat_h.keys.each do |cat| next if params[cat].blank? unless @login_user.admin?(cat_h[cat]) render(:text => t('msg.need_to_be_admin')) return end yaml[cat] ||= {} params[cat].each do |key, val| yaml[cat][key] = val end end ApplicationHelper.save_config_yaml(yaml) render(:text => '') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "changes the current database" do session.use "moped_test_2" session.command(dbStats: 1)["db"].should eq "moped_test_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
it "yields all indexes on the collection" do indexes.to_a.should eq \ session[:"system.indexes"].find(ns: "moped_test.users").to_a 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 "instructs the cluster to reconnect" do session.stub(with: new_session) new_session.cluster.should_receive(:reconnect) session.new(new_options) 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 connection @connection ||= Connection.new 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 limited? @query_op.limit > 0 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_execute_details_cleans_text spec_fetcher do |fetcher| fetcher.spec 'a', 2 do |s| s.summary = 'This is a lot of text. ' * 4 s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"] s.homepage = "http://a.example.com/\x03" end fetcher.legacy_platform end @cmd.handle_options %w[-r -d] use_ui @ui do @cmd.execute end expected = <<-EOF *** REMOTE GEMS *** a (2) Authors: Abraham Lincoln ., . Hirohito Homepage: http://a.example.com/. This is a lot of text. This is a lot of text. This is a lot of text. This is a lot of text. pl (1) Platform: i386-linux Author: A User Homepage: http://example.com this is a summary EOF assert_equal expected, @ui.output assert_equal '', @ui.error end
1
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
safe
it "should find a user by first name and last name" do @cur_user.stub(:pref).and_return(:activity_user => 'Billy Elliot') controller.instance_variable_set(:@current_user, @cur_user) User.should_receive(:where).with("(upper(first_name) LIKE upper('%Billy%') AND upper(last_name) LIKE upper('%Elliot%')) OR (upper(first_name) LIKE upper('%Elliot%') AND upper(last_name) LIKE upper('%Billy%'))").and_return([@user]) controller.send(:activity_user).should == 1 end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def query(query) if options[:consistency] == :eventual query.flags |= [:slave_ok] if query.respond_to? :flags mode = :read else mode = :write end reply = socket_for(mode).execute(query) reply.tap do |reply| if reply.flags.include?(:query_failure) raise Errors::QueryFailure.new(query, reply.documents.first) end 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 self.set_statistics_groups(group_ids) yaml = Research.get_config_yaml yaml = Hash.new if yaml.nil? if group_ids.nil? unless yaml[:statistics].nil? yaml[:statistics].delete :groups end else if yaml[:statistics].nil? yaml[:statistics] = Hash.new end yaml[:statistics][:groups] = group_ids.join('|') end Research.save_config_yaml yaml return ary 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 "sets the object id's data" do Moped::BSON::ObjectId.new(bytes).data.should == bytes end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def create_title return unless request.post? titles = User.get_config_titles titles = [] if titles.nil? titles << t('user.new_title') User.save_config_titles(titles) render(:partial => 'ajax_title', :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 "should allow requests that are whitelisted" do set_cookie("__profilin=stylin") get '/whitelisted' last_response.headers['X-MiniProfiler-Ids'].should_not be_nil 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 set_auth_users Log.add_info(request, params.inspect) @folder = Folder.find(params[:id]) if Folder.check_user_auth(@folder.id, @login_user, 'w', true) read_users = [] write_users = [] users_auth = params[:users_auth] unless users_auth.nil? users_auth.each do |auth_param| user_id = auth_param.split(':').first auths = auth_param.split(':').last.split('+') if auths.include?('r') read_users << user_id end if auths.include?('w') write_users << user_id end end end user_id = @folder.get_my_folder_owner if !user_id.nil? and (!read_users.include?(user_id.to_s) or !write_users.include?(user_id.to_s)) flash[:notice] = 'ERROR:' + t('folder.my_folder_without_auth_owner') else @folder.set_read_users read_users @folder.set_write_users write_users @folder.save flash[:notice] = t('msg.register_success') end else flash[:notice] = 'ERROR:' + t('folder.need_auth_to_modify') end @group_id = params[:group_id] if @group_id.nil? or @group_id.empty? @users = [] else @users = Group.get_users(@group_id) end render(:partial => 'ajax_auth_users', :layout => false) rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_auth_users', :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 "sanitizes crazy params" do cl = subject.build("true", modified_params) expect(cl).to eq "true --user bob --pass P@\\$sw0\\^\\&\\ \\|\\<\\>/-\\+\\*d\\% --db --desc=Some\\ Description --symkey --symkey-dash pkg1 some\\ pkg --pool 123 --pool 456" 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 index respond_to do |format| format.json do dir = params[:dir] dir = 'desc' unless SORT_DIRECTIONS.include?(dir.try(:upcase)) @occurrences = @bug.occurrences.order("occurred_at #{dir}").limit(50) last = params[:last].present? ? @bug.occurrences.find_by_number(params[:last]) : nil @occurrences = @occurrences.where(infinite_scroll_clause('occurred_at', dir, last, 'occurrences.number')) if last render json: decorate(@occurrences) end format.atom { @occurrences = @bug.occurrences.order('occurred_at DESC').limit(100) } # index.atom.builder end end
0
Ruby
CWE-94
Improper Control of Generation of Code ('Code Injection')
The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
https://cwe.mitre.org/data/definitions/94.html
vulnerable
def 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 end seen = {} matching_tuples.delete_if do |n,_| if seen[n.version] then true else seen[n.version] = true false end end output << clean_text(make_entry(matching_tuples, platforms)) end end
1
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
safe
def test_login_should_redirect_to_back_url_param # request.uri is "test.host" in test environment back_urls = [ 'http://test.host/issues/show/1', 'http://test.host/', '/' ] back_urls.each do |back_url| post :login, :username => 'jsmith', :password => 'jsmith', :back_url => back_url assert_redirected_to back_url end 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
it "updates the first matching document" do users.insert(documents) users.find(scope: scope).update("$set" => { "updated" => true }) users.find(scope: scope, updated: true).count.should eq 1 end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
it "should escape evil haxxor attemptes" do Mail.defaults do delivery_method :sendmail, :arguments => nil end mail = Mail.new do from '"foo\";touch /tmp/PWNED;\""@blah.com' to '"foo\";touch /tmp/PWNED;\""@blah.com' subject 'invalid RFC2822' end Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail', "-f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\"", "\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com", mail) mail.deliver! end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def update_comment Log.add_info(request, params.inspect) return unless request.post? unless params[:thetisBoxEdit].empty? @comment = Comment.find(params[:comment_id]) if @comment.nil? redirect_to(THETIS_RELATIVE_URL_ROOT + '/404.html' ) return end @comment.message = params[:thetisBoxEdit] @comment.save @item = Item.find(@comment.item_id) end render(:partial => 'ajax_comment', :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 stop @manager.shutdown @nodes.each &:stop end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def update_by_ajax Log.add_info(request, params.inspect) cat_h = {:desktop => User::AUTH_DESKTOP, :user => User::AUTH_USER, :log => User::AUTH_LOG} yaml = ApplicationHelper.get_config_yaml cat_h.keys.each do |cat| next if params[cat].nil? or params[cat].empty? unless @login_user.admin?(cat_h[cat]) render(:text => t('msg.need_to_be_admin')) return end yaml[cat] ||= {} params[cat].each do |key, val| yaml[cat][key] = val end end ApplicationHelper.save_config_yaml(yaml) render(:text => '') end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it "doesn't recognize #destroy" do { :delete => "/users/1" }.should_not be_routable end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def new(options = {}) session = with(options) session.instance_variable_set(:@cluster, cluster.dup) if block_given? yield session else session 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 remove_resource(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end force = params['force'] no_error_if_not_exists = params.include?('no_error_if_not_exists') errors = "" params.each { |k,v| if k.index("resid-") == 0 resid = k.gsub('resid-', '') command = [PCS, 'resource', 'delete', resid] command << '--force' if force out, errout, retval = run_cmd(session, *command) if retval != 0 unless out.index(" does not exist.") != -1 and no_error_if_not_exists errors += errout.join(' ').strip + "\n" end end end } errors.strip! if errors == "" return 200 else $logger.info("Remove resource errors:\n"+errors) return [400, errors] end end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def current_database return @current_database if defined? @current_database if database = options[:database] set_current_database(database) else raise "No database set for session. Call #use or #with before accessing the database" 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 "should collapse all comments and emails on a specific contact" do comment = double(Comment) Comment.should_receive(:find).with("1").and_return(comment) comment.should_receive(:update_attribute).with(:state, 'Collapsed') xhr :get, :timeline, :type => "comment", :id => "1", :state => "Collapsed" 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 each documents = load documents.each { |doc| yield doc } while more? return kill if limited? && @limit <= 0 documents = get_more documents.each { |doc| yield doc } 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 update_groups_order Log.add_info(request, params.inspect) return unless request.post? order_ary = params[:groups_order] Research.set_statistics_groups(order_ary) render(:text => '') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def test_reminders_should_only_include_issues_the_user_can_see with_settings :default_language => 'en' do user = User.find(3) member = Member.create!(:project_id => 2, :principal => user, :role_ids => [1]) Issue.create!(:project_id => 2, :tracker_id => 1, :status_id => 1, :subject => 'Issue dlopper should not see', :assigned_to_id => 3, :due_date => 5.days.from_now, :author_id => 2) member.destroy ActionMailer::Base.deliveries.clear Mailer.reminders(:days => 42) assert_equal 1, ActionMailer::Base.deliveries.size mail = last_email assert mail.bcc.include?('[email protected]') assert_mail_body_no_match 'Issue dlopper should not see', mail 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 data @data ||= @@generator.next 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 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-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 html_postprocess(_field, html) helper = ContentTextHelpers.new helper.sanitize(helper.auto_link(html)) end
0
Ruby
CWE-94
Improper Control of Generation of Code ('Code Injection')
The software constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
https://cwe.mitre.org/data/definitions/94.html
vulnerable
def to_s @@string_format % data.unpack("C12") 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 read reply = Protocol::Reply.allocate reply.length, reply.request_id, reply.response_to, reply.op_code, reply.flags, reply.cursor_id, reply.offset, reply.count = @sock.read(36).unpack('l5<q<l2<') if reply.count == 0 reply.documents = [] else buffer = StringIO.new(@sock.read(reply.length - 36)) reply.documents = reply.count.times.map do BSON::Document.deserialize(buffer) end end 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 self.connect(host, port, timeout) Timeout::timeout(timeout) do new(host, port).tap do |sock| sock.set_encoding 'binary' end end end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def entries(path=nil, identifier=nil, options={}) p1 = scm_iconv(@path_encoding, 'UTF-8', path) manifest = hg('rhmanifest', '-r', CGI.escape(hgrev(identifier)), '--', CGI.escape(without_leading_slash(p1.to_s))) do |io| output = io.read.force_encoding('UTF-8') begin parse_xml(output)['rhmanifest']['repository']['manifest'] rescue end end path_prefix = path.blank? ? '' : with_trailling_slash(path) entries = Entries.new as_ary(manifest['dir']).each do |e| n = scm_iconv('UTF-8', @path_encoding, CGI.unescape(e['name'])) p = "#{path_prefix}#{n}" entries << Entry.new(:name => n, :path => p, :kind => 'dir') end as_ary(manifest['file']).each do |e| n = scm_iconv('UTF-8', @path_encoding, CGI.unescape(e['name'])) p = "#{path_prefix}#{n}" lr = Revision.new(:revision => e['revision'], :scmid => e['node'], :identifier => e['node'], :time => Time.at(e['time'].to_i)) entries << Entry.new(:name => n, :path => p, :kind => 'file', :size => e['size'].to_i, :lastrev => lr) end entries rescue HgCommandAborted nil # means not found end
1
Ruby
NVD-CWE-noinfo
null
null
null
safe
def calculated_media_type @calculated_media_type ||= calculated_content_type.split("/").first 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 "returns the query" do query.limit(5).should eql 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
def self.generate_key_pair(key_base_name, recipient, real_name) public_key_file_name = "#{key_base_name}.pub" private_key_file_name = "#{key_base_name}.sec" script = generate_key_script(public_key_file_name, private_key_file_name, recipient, real_name) script_file = Tempfile.new('gpg-script') begin script_file.write(script) script_file.close result = system("gpg --batch --gen-key #{Shellwords.escape(script_file.path)}") raise RuntimeError.new('gpg failed') unless result ensure script_file.close script_file.unlink end end
1
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
safe
it "raises an exception" do expect { session.current_database }.to 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 sanitize(params) return [] if params.nil? || params.empty? params.collect do |k, v| [sanitize_key(k), sanitize_value(v)] end end
1
Ruby
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
safe
it 'does not log in with incorrect two factor' do post "/session/email-login/#{email_token.token}", params: { second_factor_token: "0000", second_factor_method: UserSecondFactor.methods[:totp] } expect(response.status).to eq(200) 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 remove_constraint_rule(session, rule_id) stdout, stderror, retval = run_cmd( session, PCS, "constraint", "rule", "remove", rule_id ) $logger.info stdout return retval 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_escape_dollar_sign assert_equal "\\$", escape_javascript("$") end
1
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
safe
it "should reject a non-critical extension that isn't on the whitelist" do @request.stubs(:request_extensions).returns [{ "oid" => "peach", "value" => "meh", "critical" => false }] expect { @ca.check_internal_signing_policies(@name, @request, false) }.to raise_error( Puppet::SSL::CertificateAuthority::CertificateSigningError, /request extensions that are not permitted/ ) 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
it "returns a hex string representation of the id" do Moped::BSON::ObjectId.from_data(bytes).to_s.should eq "4e4d66343b39b68407000001" 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 consistency options[:consistency] 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 setup_cluster(params, request, session) if not allowed_for_superuser(session) return 403, 'Permission denied' end $logger.info("Setting up cluster: " + params.inspect) nodes_rrp = params[:nodes].split(';') options = [] myoptions = JSON.parse(params[:options]) transport_udp = false options_udp = [] myoptions.each { |o,v| if ["wait_for_all", "last_man_standing", "auto_tie_breaker"].include?(o) options << "--" + o + "=1" end options << "--" + o + "=" + v if [ "token", "token_coefficient", "join", "consensus", "miss_count_const", "fail_recv_const", "last_man_standing_window", ].include?(o) if o == "transport" and v == "udp" options << "--transport=udp" transport_udp = true end if o == "transport" and v == "udpu" options << "--transport=udpu" transport_udp = false end if ["addr0", "addr1", "mcast0", "mcast1", "mcastport0", "mcastport1", "ttl0", "ttl1"].include?(o) options_udp << "--" + o + "=" + v end if ["broadcast0", "broadcast1"].include?(o) options_udp << "--" + o end if o == "ipv6" options << "--ipv6" end } if transport_udp nodes = [] nodes_rrp.each { |node| nodes << node.split(',')[0] } else nodes = nodes_rrp end nodes_options = nodes + options nodes_options += options_udp if transport_udp stdout, stderr, retval = run_cmd( session, PCS, "cluster", "setup", "--enable", "--start", "--name", params[:clustername], *nodes_options ) if retval != 0 return [ 400, (stdout + [''] + stderr).collect { |line| line.rstrip() }.join("\n") ] end return 200 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 "does not set the slave ok flag" do stats = Support::Stats.collect do session.with(consistency: :strong)[:users].find(scope: scope).one end query = stats[:primary].grep(Moped::Protocol::Query).first query.flags.should_not include :slave_ok 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 tags_for_index(model) model.tags.inject("".html_safe) do |out, tag| query = controller.send(:current_query) || "" hashtag = "##{tag}" if query.empty? query = hashtag elsif !query.include?(hashtag) query += " #{hashtag}" end out << link_to_function(tag, "crm.search_tagged('#{escape_javascript(query)}', '#{model.class.to_s.tableize}')", title: tag) 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 "doesn't log in the user when not approved" do SiteSetting.must_approve_users = true get "/session/email-login/#{email_token.token}" expect(response.status).to eq(200) expect(CGI.unescapeHTML(response.body)).to include( I18n.t("login.not_approved") ) end
0
Ruby
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