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 discard_cookie!(headers) Rack::Utils.delete_cookie_header!(headers, COOKIE_NAME, :path => '/') 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 "should still send an email if the settings have been set to nil" do Mail.defaults do delivery_method :exim, :arguments => nil end mail = Mail.new do from '[email protected]' to '[email protected], [email protected]' subject 'invalid RFC2822' end Mail::Exim.should_receive(:call).with('/usr/sbin/exim', '-f "[email protected]"', '[email protected] [email protected]', 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 password_policy(password) if Setting.get('password_min_size').to_i > password.length return ["Can\'t update password, it must be at least %s characters long!", Setting.get('password_min_size')] end if Setting.get('password_need_digit').to_i == 1 && password !~ /\d/ return ["Can't update password, it must contain at least 1 digit!"] end if Setting.get('password_min_2_lower_2_upper_characters').to_i == 1 && ( password !~ /[A-Z].*[A-Z]/ || password !~ /[a-z].*[a-z]/ ) return ["Can't update password, it must contain at least 2 lowercase and 2 uppercase characters!"] end true end
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
def update_product_autopackages check_write_access! backend_pkgs = Collection.find :id, :what => 'package', :match => "@project='#{self.name}' and starts-with(@name,'_product:')" b_pkg_index = backend_pkgs.each_package.inject(Hash.new) {|hash,elem| hash[elem.name] = elem; hash} frontend_pkgs = self.packages.where("`packages`.name LIKE '_product:%'") f_pkg_index = frontend_pkgs.inject(Hash.new) {|hash,elem| hash[elem.name] = elem; hash} all_pkgs = [b_pkg_index.keys, f_pkg_index.keys].flatten.uniq all_pkgs.each do |pkg| if b_pkg_index.has_key?(pkg) and not f_pkg_index.has_key?(pkg) # new autopackage, import in database p = self.packages.new(name: pkg) p.update_from_xml(Xmlhash.parse(b_pkg_index[pkg].dump_xml)) p.store elsif f_pkg_index.has_key?(pkg) and not b_pkg_index.has_key?(pkg) # autopackage was removed, remove from database f_pkg_index[pkg].destroy end end end
1
Ruby
CWE-275
Permission Issues
Weaknesses in this category are related to improper assignment or handling of permissions.
https://cwe.mitre.org/data/definitions/275.html
safe
def update if @application.update(application_params) flash[:notice] = I18n.t(:notice, scope: i18n_scope(:update)) respond_to do |format| format.html { redirect_to oauth_application_url(@application) } format.json { render json: @application } end else respond_to do |format| format.html { render :edit } format.json do errors = @application.errors.full_messages render json: { errors: errors }, status: :unprocessable_entity end end end end
0
Ruby
CWE-862
Missing Authorization
The software does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
vulnerable
def verify_files gem gem.each do |entry| verify_entry entry end unless @spec then raise Gem::Package::FormatError.new 'package metadata is missing', @gem end unless @files.include? 'data.tar.gz' then raise Gem::Package::FormatError.new \ 'package content (data.tar.gz) is missing', @gem end if duplicates = @files.group_by {|f| f }.select {|k,v| v.size > 1 }.map(&:first) and duplicates.any? raise Gem::Security::Exception, "duplicate files in the package: (#{duplicates.map(&:inspect).join(', ')})" end end
1
Ruby
CWE-347
Improper Verification of Cryptographic Signature
The software does not verify, or incorrectly verifies, the cryptographic signature for data.
https://cwe.mitre.org/data/definitions/347.html
safe
it "marks the node as down" do node.ensure_connected {} rescue nil node.should be_down 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 cat(path, identifier=nil) p = CGI.escape(scm_iconv(@path_encoding, 'UTF-8', path)) hg 'rhcat', '-r', CGI.escape(hgrev(identifier)), '--', hgtarget(p) do |io| io.binmode io.read end rescue HgCommandAborted nil # means not found end
1
Ruby
NVD-CWE-noinfo
null
null
null
safe
def self.included(context) context.before :all do @replica_set = ReplicaSetSimulator.new @replica_set.start @primary, @secondaries = @replica_set.initiate end context.after :all do @replica_set.stop end context.after :each do @replica_set.nodes.each &:restart end context.let :seeds do @replica_set.nodes.map &:address end end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
it "should use the from address is no return path or sender are specified" do Mail.defaults do delivery_method :exim end mail = Mail.new do to "[email protected]" from "[email protected]" subject "Can't set the return-path" message_id "<[email protected]>" body "body" end Mail::Exim.should_receive(:call).with('/usr/sbin/exim', '-i -t -f "[email protected]"', '[email protected]', 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 calculated_media_type @calculated_media_type ||= calculated_content_type.split("/").first end
0
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
it "queries a slave node" do session.should_receive(:socket_for).with(:read). and_return(socket) session.query(query) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def destroy_q_page Log.add_info(request, params.inspect) return unless request.post? begin Item.find(params[:id]).destroy rescue end # Get $Templates and its sub folders to update partial division. @tmpl_folder, @tmpl_q_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_RESEARCH) @items = Folder.get_items_admin(@tmpl_q_folder.id, 'xorder ASC') render(:partial => 'ajax_q_page', :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 "does not re-sync the cluster" do cluster.should_receive(:sync).never cluster.socket_for :write 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 not return HTTP_X_FORWARDED_FOR as remote_address" do @connection.request.env['HTTP_X_FORWARDED_FOR'] = '1.2.3.4' @connection.stub!(:socket_address).and_return("127.0.0.1") @connection.remote_address.should == "127.0.0.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
def self.reminders(options={}) days = options[:days] || 7 project = options[:project] ? Project.find(options[:project]) : nil tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil target_version_id = options[:version] ? Version.named(options[:version]).pluck(:id) : nil if options[:version] && target_version_id.blank? raise ActiveRecord::RecordNotFound.new("Couldn't find Version with named #{options[:version]}") end user_ids = options[:users] scope = Issue.open.where("#{Issue.table_name}.assigned_to_id IS NOT NULL" + " AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" + " AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date ) scope = scope.where(:assigned_to_id => user_ids) if user_ids.present? scope = scope.where(:project_id => project.id) if project scope = scope.where(:fixed_version_id => target_version_id) if target_version_id.present? scope = scope.where(:tracker_id => tracker.id) if tracker issues_by_assignee = scope.includes(:status, :assigned_to, :project, :tracker). group_by(&:assigned_to) issues_by_assignee.keys.each do |assignee| if assignee.is_a?(Group) assignee.users.each do |user| issues_by_assignee[user] ||= [] issues_by_assignee[user] += issues_by_assignee[assignee] end end end issues_by_assignee.each do |assignee, issues| if assignee.is_a?(User) && assignee.active? && issues.present? visible_issues = issues.select {|i| i.visible?(assignee)} reminder(assignee, visible_issues, days).deliver if visible_issues.present? end 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 self.get_tree_by_group_for_admin(group_id) SqlHelper.validate_token([group_id]) folder_tree = {} tree_id = '0' if group_id.to_s == '0' sql = 'select distinct * from folders' where = " where (parent_id=#{tree_id.to_i})" where << " and ((xtype is null) or not((xtype='#{XTYPE_GROUP}') or (xtype='#{XTYPE_USER}')))" order_by = ' order by xorder ASC, id ASC' else sql = 'select distinct Folder.* from folders Folder, users User' where = " where (Folder.parent_id=#{tree_id.to_i})" where << ' and (' where << "((Folder.xtype='#{XTYPE_GROUP}') and (Folder.owner_id=#{group_id.to_i}))" where << ' or ' where << "((Folder.xtype='#{XTYPE_USER}') and (Folder.owner_id=User.id) and #{SqlHelper.get_sql_like(['User.groups'], "|#{group_id}|")})" where << ' )' order_by = ' order by Folder.xorder ASC, Folder.id ASC' end sql << where + order_by folder_tree[tree_id] = Folder.find_by_sql(sql) folder_tree[tree_id].each do |folder| folder_tree = Folder.get_tree(folder_tree, nil, folder, true) end return Folder.sort_tree(folder_tree) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def get_more(database, collection, cursor_id, limit) process Protocol::GetMore.new(database, collection, cursor_id, limit) 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 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
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_should_not_destroy_if_used_by_hosts subnet = subnets(:one) delete :destroy, {:id => subnet}, set_session_user assert_redirected_to subnets_url assert Subnet.exists?(subnet.id) 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 '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" )) expect(response_body).to_not include(I18n.t( "login.invalid_second_factor_code" )) end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def supplied_media_type @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 "memoizes the database" do database = session.current_database session.current_database.should equal(database) end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def get_records_group Log.add_info(request, params.inspect) where = ' where Research.status=' + Research::U_STATUS_COMMITTED.to_s unless params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxSelKeeper].split(':').last SqlHelper.validate_token([@group_id]) group_cons = [] if @group_id != '0' group_cons << SqlHelper.get_sql_like(['User.groups'], "|#{@group_id}|") where << ' and (Research.user_id = User.id)' where << ' and (' + group_cons.join(' or ') + ')' end end sql = 'select distinct Research.* from researches Research, users User' + where @researches = Research.find_by_sql(sql) q_hash = Research.get_config_yaml unless q_hash.nil? or q_hash.empty? @q_codes = q_hash.keys @q_codes.delete_if{ |q_code| !q_code.instance_of?(String) or q_code.match(/^q\d{2}_\d{2}$/).nil? } @q_codes.sort! end render(:partial => 'ajax_statistics_records', :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 'sets file extension based on content-type if missing' do expect(subject.original_filename).to eq "test.jpeg" end
0
Ruby
CWE-918
Server-Side Request Forgery (SSRF)
The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
https://cwe.mitre.org/data/definitions/918.html
vulnerable
def 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
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "with Pathname command and params" do cl = subject.build(Pathname.new("/usr/bin/ruby"), "-v" => nil) expect(cl).to eq "/usr/bin/ruby -v" 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 select(request) # We rely on the request's parsing of the URI. # Short-circuit to :file if it's a fully-qualified path or specifies a 'file' protocol. return PROTOCOL_MAP["file"] if Puppet::Util.absolute_path?(request.key) return PROTOCOL_MAP["file"] if request.protocol == "file" # We're heading over the wire the protocol is 'puppet' and we've got a server name or we're not named 'apply' or 'puppet' if request.protocol == "puppet" and (request.server or !["puppet","apply"].include?(Puppet.settings[:name])) return PROTOCOL_MAP["puppet"] end if request.protocol and PROTOCOL_MAP[request.protocol].nil? raise(ArgumentError, "URI protocol '#{request.protocol}' is not currently supported for file serving") end # If we're still here, we're using the file_server or modules. :file_server 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 test_should_not_destroy_if_used_by_hosts subnet = subnets(:one) delete :destroy, {:id => subnet}, set_session_user assert_redirected_to subnets_url assert Subnet.unscoped.exists?(subnet.id) end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
it "raises a QueryFailure exception" do expect { session.query(query) }.to raise_exception(Moped::Errors::QueryFailure) 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 kill session.execute kill_cursor_op 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 set_inboxes @inbox_ids = if params[:inbox_id] current_account.inboxes.where(id: params[:inbox_id]) else @current_user.assigned_inboxes.pluck(:id) end
0
Ruby
CWE-269
Improper Privilege Management
The software does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.
https://cwe.mitre.org/data/definitions/269.html
vulnerable
def get_disp_ctrl Log.add_info(request, params.inspect) if params[:id] != '0' begin @folder = Folder.find(params[:id]) rescue => evar @folder = nil end end session[:folder_id] = params[:id] render(:partial => 'ajax_disp_ctrl', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def supplied_file_media_types @supplied_file_media_types ||= MIME::Types.type_for(@name).collect(&:media_type) end
0
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
it "returns default error message for spoofed media type" do build_validator file = File.new(fixture_file("5k.png"), "rb") @dummy.avatar.assign(file) detector = mock("detector", :spoofed? => true) Paperclip::MediaTypeSpoofDetector.stubs(:using).returns(detector) @validator.validate(@dummy) assert_equal I18n.t("errors.messages.spoofed_media_type"), @dummy.errors[:avatar].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
def status { "ismaster" => @primary, "secondary" => @secondary, "hosts" => @set.nodes.map(&:address), "me" => address, "maxBsonObjectSize" => 16777216, "ok" => 1.0 } end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def kill_cursors(*args) raise NotImplementedError, "#kill_cursors cannot be called on Context; it must be called directly on a node" end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it 'logs in correctly' do post "/session/email-login/#{email_token.token}", params: { second_factor_token: ROTP::TOTP.new(user_second_factor.data).now, second_factor_method: UserSecondFactor.methods[:totp] } expect(response).to redirect_to("/") end
0
Ruby
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 attachments_without_content return [] if self.id.nil? sql = 'select id, title, memo, name, size, content_type, comment_id, xorder, location from attachments' sql << ' where comment_id=' + self.id.to_s sql << ' order by xorder ASC' begin attachments = Attachment.find_by_sql(sql) rescue => evar Log.add_error(nil, evar) end attachments = [] if attachments.nil? return attachments 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 decode_compact_serialized(input, private_key_or_secret, algorithms = nil, encryption_methods = nil, _allow_blank_payload = false) unless input.count('.') + 1 == NUM_OF_SEGMENTS raise InvalidFormat.new("Invalid JWE Format. JWE should include #{NUM_OF_SEGMENTS} segments.") end jwe = new _header_json_, jwe.jwe_encrypted_key, jwe.iv, jwe.cipher_text, jwe.authentication_tag = input.split('.').collect do |segment| begin Base64.urlsafe_decode64 segment rescue ArgumentError raise DecryptionFailed end end jwe.auth_data = input.split('.').first jwe.header = JSON.parse(_header_json_).with_indifferent_access unless private_key_or_secret == :skip_decryption jwe.decrypt! private_key_or_secret, algorithms, encryption_methods end jwe 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 "should use the rest terminus when the 'puppet' URI scheme is used and a host name is present" do uri = "puppet://myhost/fakemod/my/file" # It appears that the mocking somehow interferes with the caching subsystem. # This mock somehow causes another terminus to get generated. @indirection.terminus(:rest).expects(:find) @indirection.find(uri) 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
detectExtension(mimeType) { if (!mimeType) { return defaultExtension; } let parts = (mimeType || '') .toLowerCase() .trim() .split('/'); let rootType = parts.shift().trim(); let subType = parts.join('/').trim(); if (mimeTypes.has(rootType + '/' + subType)) { let value = mimeTypes.get(rootType + '/' + subType); if (Array.isArray(value)) { return value[0]; } return value; } switch (rootType) { case 'text': return 'txt'; default: return 'bin'; } }
0
Ruby
CWE-88
Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')
The software constructs a string for a command to executed by a separate component in another control sphere, but it does not properly delimit the intended arguments, options, or switches within that command string.
https://cwe.mitre.org/data/definitions/88.html
vulnerable
def initialize @sock = nil @request_id = 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
def deliver!(mail) if ::File.respond_to?(:makedirs) ::File.makedirs settings[:location] else ::FileUtils.mkdir_p settings[:location] end mail.destinations.uniq.each do |to| ::File.open(::File.join(settings[:location], to), 'a') { |f| "#{f.write(mail.encoded)}\r\n\r\n" } end end
0
Ruby
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
https://cwe.mitre.org/data/definitions/22.html
vulnerable
def create @application = Doorkeeper.config.application_model.new(application_params) if @application.save flash[:notice] = I18n.t(:notice, scope: %i[doorkeeper flash applications create]) flash[:application_secret] = @application.plaintext_secret respond_to do |format| format.html { redirect_to oauth_application_url(@application) } format.json { render json: @application } end else respond_to do |format| format.html { render :new } format.json do errors = @application.errors.full_messages render json: { errors: errors }, status: :unprocessable_entity end end end end
0
Ruby
CWE-862
Missing Authorization
The software does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
vulnerable
def setup @store = Redis::Store.new :marshalling => true @rabbit = OpenStruct.new :name => "bunny" @white_rabbit = OpenStruct.new :color => "white" @store.set "rabbit", @rabbit @store.del "rabbit2" 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
def update_folders_order Log.add_info(request, params.inspect) order_ary = params[:folders_order] folders = MailFolder.get_childs(params[:id], false, false) # folders must be ordered by xorder ASC. folders.sort! { |id_a, id_b| idx_a = order_ary.index(id_a) idx_b = order_ary.index(id_b) if idx_a.nil? or idx_b.nil? idx_a = folders.index(id_a) idx_b = folders.index(id_b) end idx_a - idx_b } idx = 1 folders.each do |folder_id| begin folder = MailFolder.find(folder_id) next if folder.user_id != @login_user.id folder.update_attribute(:xorder, idx) if folder.xtype == MailFolder::XTYPE_ACCOUNT_ROOT mail_account = MailAccount.find_by_id(folder.mail_account_id) unless mail_account.nil? mail_account.update_attribute(:xorder, idx) end end idx += 1 rescue => evar Log.add_error(request, evar) end end 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 "returns true" do Moped::BSON::ObjectId.from_data(bytes).should == Moped::BSON::ObjectId.from_data(bytes) 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 delete_comment_attachment Log.add_info(request, params.inspect) return unless request.post? begin attachment = Attachment.find(params[:attachment_id]) @comment = Comment.find(params[:comment_id]) if attachment.comment_id == @comment.id attachment.destroy @comment.update_attribute(:updated_at, Time.now) end rescue => evar Log.add_error(request, evar) 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 from_time(time) from_data @@generator.generate(time.to_i) 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 'initalizes the review in state :new' do expect(subject.state).to eq(:new) end
1
Ruby
CWE-862
Missing Authorization
The software does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
safe
def logout session.cluster.logout(name) 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_nest get :nest, {:id => Hostgroup.first.id}, set_session_user assert_template 'new' 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 search Log.add_info(request, params.inspect) unless params[:select_sorting].blank? sort_a = params[:select_sorting].split(' ') params[:sort_col] = sort_a.first params[:sort_type] = sort_a.last end list if params[:keyword].blank? if params[:from_action].nil? or params[:from_action] == 'bbs' render(:action => 'bbs') else render(:action => 'list') end end end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
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
it "sanitizes Pathname param value" do cl = subject.build_command_line("true", nil => [Pathname.new("/usr/bin/ruby")]) expect(cl).to eq "true /usr/bin/ruby" 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 add_official_titles Log.add_info(request, params.inspect) return unless request.post? @user = User.find(params[:user_id]) unless params[:official_titles].nil? params[:official_titles].each do |official_title_id| if @user.user_titles.index{|user_title| user_title.official_title_id.to_s == official_title_id}.nil? user_title = UserTitle.new user_title.user_id = @user.id user_title.official_title_id = official_title_id user_title.save! @user.user_titles << user_title end end end render(:partial => 'ajax_user_titles', :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 "raises a connection error" do lambda do replica_set.with_primary do |node| node.command "admin", ping: 1 end end.should raise_exception(Moped::Errors::ConnectionFailure) end
1
Ruby
CWE-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 socket_for(mode) sync unless primaries.any? || (secondaries.any? && mode == :read) server = nil while primaries.any? || (secondaries.any? && mode == :read) if mode == :write || secondaries.empty? server = primaries.sample else server = secondaries.sample end if server socket = server.socket socket.connect unless socket.connection if socket.alive? break server else remove server end end end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def initialize(session, query_operation) @session = session @query_op = query_operation.dup @get_more_op = Protocol::GetMore.new( @query_op.database, @query_op.collection, 0, @query_op.limit ) @kill_cursor_op = Protocol::KillCursors.new([0]) end
0
Ruby
CWE-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 "handles Symbol keys with tailing '='" do cl = subject.build("true", :abc= => "def") expect(cl).to eq "true --abc=def" 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 initialize(string) super("'#{string}' is not a valid object id.") 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 "sets slave_ok on the query flags" do session.stub(socket_for: socket) socket.should_receive(:execute) do |query| query.flags.should include :slave_ok end session.query(query) end
0
Ruby
CWE-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.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? mail_accounts = MailAccount.where(con).to_a mail_accounts.each do |mail_account| mail_account.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 self.find_term(user_id, start_date, end_date) SqlHelper.validate_token([user_id]) start_s = start_date.strftime(Schedule::SYS_DATE_FORM) end_s = end_date.strftime(Schedule::SYS_DATE_FORM) con = "(user_id=#{user_id}) and (date >= '#{start_s}') and (date <= '#{end_s}')" ary = Timecard.where(con).order('date ASC').to_a timecards_h = Hash.new unless ary.nil? ary.each do |timecard| timecards_h[timecard.date.strftime(Schedule::SYS_DATE_FORM)] = timecard end end return timecards_h 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.run! # :nodoc: if check! super else Null end end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def each cursor = Cursor.new(session, operation) cursor.to_enum.tap do |enum| enum.each do |document| yield document end if block_given? end end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def test_update_valid SmartProxy.any_instance.stubs(:valid?).returns(true) put :update, {:id => SmartProxy.unscoped.first, :smart_proxy => {:url => "http://elsewhere.com:8443"}}, set_session_user assert_equal "http://elsewhere.com:8443", SmartProxy.unscoped.first.url assert_redirected_to smart_proxies_url end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def move Log.add_info(request, params.inspect) return unless request.post? @folder = Folder.find(params[:id]) if params[:thetisBoxSelKeeper].blank? redirect_to(:action => 'show_tree') return end parent_id = params[:thetisBoxSelKeeper].split(':').last check = true unless Folder.check_user_auth(parent_id, @login_user, 'w', true) check = false end unless Folder.check_user_auth(@folder.id, @login_user, 'w', true) check = false end unless check flash[:notice] = 'ERROR:' + t('folder.need_auth_to_modify') redirect_to(:action => 'show_tree') return end # Check if specified parent is not one of subfolders. childs = Folder.get_childs(@folder.id, nil, true, true, false) if childs.include?(parent_id) or (@folder.id == parent_id.to_i) flash[:notice] = 'ERROR:' + t('folder.cannot_be_parent') redirect_to(:action => 'show_tree') return end @folder.parent_id = parent_id @folder.xorder = Folder.get_order_max(parent_id) + 1 @folder.save redirect_to(:action => 'show_tree') 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 "initializes with the string's bytes" do Moped::BSON::ObjectId.should_receive(:from_data).with(bytes) Moped::BSON::ObjectId.from_string "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 to_xml(options = nil) [name].to_xml 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 run_cmd_options(session, options, *args) $logger.info("Running: " + args.join(" ")) start = Time.now out = "" errout = "" proc_block = proc { |pid, stdin, stdout, stderr| if options and options.key?('stdin') stdin.puts(options['stdin']) stdin.close() end out = stdout.readlines() errout = stderr.readlines() duration = Time.now - start $logger.debug(out) $logger.debug(errout) $logger.debug("Duration: " + duration.to_s + "s") } cib_user = session[:username] # when running 'id -Gn' to get the groups they are not defined yet cib_groups = (session[:usergroups] || []).join(' ') $logger.info("CIB USER: #{cib_user}, groups: #{cib_groups}") # Open4.popen4 reimplementation which sets ENV in a child process prior # to running an external process by exec status = Open4::do_popen(proc_block, :init) { |ps_read, ps_write| ps_read.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) ps_write.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) ENV['CIB_user'] = cib_user ENV['CIB_user_groups'] = cib_groups exec(*args) } retval = status.exitstatus $logger.info("Return Value: " + retval.to_s) return out, errout, 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 check_write_access! return if Rails.env.test? and User.current.nil? # for unit tests unless User.current.can_modify_package? self raise WritePermissionError, "No permission to modify package '#{self.name}' for user '#{User.current.login}'" end end
1
Ruby
CWE-275
Permission Issues
Weaknesses in this category are related to improper assignment or handling of permissions.
https://cwe.mitre.org/data/definitions/275.html
safe
def add_role(what, role) check_write_access! self.transaction do if what.kind_of? Group self.project_group_role_relationships.create!(role: role, group: what) else self.project_user_role_relationships.create!(role: role, user: what) end write_to_backend end end
1
Ruby
CWE-275
Permission Issues
Weaknesses in this category are related to improper assignment or handling of permissions.
https://cwe.mitre.org/data/definitions/275.html
safe
def login(database, username, password) getnonce = Protocol::Command.new(database, getnonce: 1) connection.write [getnonce] result = connection.read.documents.first raise Errors::OperationFailure.new(getnonce, result) unless result["ok"] == 1 authenticate = Protocol::Commands::Authenticate.new(database, username, password, result["nonce"]) connection.write [authenticate] result = connection.read.documents.first raise Errors::AuthenticationFailure.new(authenticate, result) unless result["ok"] == 1 auth[database] = [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 redirect_back_or_default(default, options={}) back_url = params[:back_url].to_s if back_url.present? && valid_back_url?(back_url) redirect_to(back_url) return elsif options[:referer] redirect_to_referer_or default return end redirect_to default false end
0
Ruby
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
vulnerable
it "creates an index with the extra options" do indexes.create({name: 1}, {unique: true, dropDups: true}) index = indexes[name: 1] index["unique"].should be_true index["dropDups"].should be_true 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 add_meta_attr_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end retval = add_meta_attr( session, params["res_id"], params["key"],params["value"] ) if retval == 0 return [200, "Successfully added meta attribute"] else return [400, "Error adding meta attribute"] 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
it "initializes with the string's bytes" do Moped::BSON::ObjectId.should_receive(:from_data).with(bytes) Moped::BSON::ObjectId.from_string "4e4d66343b39b68407000001" 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 "raises a query failure exception for invalid queries" do lambda do users.find("age" => { "$in" => nil }).first end.should raise_exception(Moped::Errors::QueryFailure) 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 from_data(data) object_id = allocate object_id.send(:data=, data) object_id end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def initialize(env) request = ::Rack::Request.new(env) @cookie = request.cookies[COOKIE_NAME] if @cookie @cookie.split(",").map{|pair| pair.split("=")}.each do |k,v| @orig_disable_profiling = @disable_profiling = (v=='t') if k == "dp" @backtrace_level = v.to_i if k == "bt" end end @backtrace_level = nil if !@backtrace_level.nil? && (@backtrace_level == 0 || @backtrace_level > BACKTRACE_NONE) @orig_backtrace_level = @backtrace_level 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 access?(query) return false if record.internal == true && !user.permissions?('ticket.agent') ticket = Ticket.lookup(id: record.ticket_id) Pundit.authorize(user, ticket, query) end
0
Ruby
CWE-862
Missing Authorization
The software does not perform an authorization check when an actor attempts to access a resource or perform an action.
https://cwe.mitre.org/data/definitions/862.html
vulnerable
it "returns a random slave connection" do secondaries = [server] cluster.stub(secondaries: secondaries) secondaries.should_receive(:sample).and_return(server) 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 self.load_current_node(session, crm_dom=nil) node = ClusterEntity::Node.new node.corosync = corosync_running? node.corosync_enabled = corosync_enabled? node.pacemaker = pacemaker_running? node.pacemaker_enabled = pacemaker_enabled? node.cman = cman_running? node.pcsd_enabled = pcsd_enabled? node_online = (node.corosync and node.pacemaker) node.status = node_online ? 'online' : 'offline' node.uptime = get_node_uptime node.id = get_local_node_id if node_online and crm_dom node_el = crm_dom.elements["//node[@id='#{node.id}']"] if node_el and node_el.attributes['standby'] == 'true' node.status = 'standby' else node.status = 'online' end node.quorum = !!crm_dom.elements['//current_dc[@with_quorum="true"]'] else node.status = 'offline' end return node 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.parse_csv_row(row, book, idxs, user) imp_id = (idxs[0].nil? or row[idxs[0]].nil?)?(nil):(row[idxs[0]].strip) unless imp_id.nil? or imp_id.empty? 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
def self.update_xorder(title, order) if title.nil? con = nil else con = ['title=?', title] end SqlHelper.validate_token([order]) User.update_all("xorder=#{order}", con) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def end(name) stack(name).pop 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 delete = Protocol::Delete.new( operation.database, operation.collection, operation.selector, flags: [:remove_first] ) session.with(consistency: :strong) do |session| session.execute delete end end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def get_nodes_status() corosync_online = [] corosync_offline = [] pacemaker_online = [] pacemaker_offline = [] pacemaker_standby = [] in_pacemaker = false stdout, stderr, retval = run_cmd( PCSAuth.getSuperuserSession, PCS, "status", "nodes", "both" ) stdout.each {|l| l = l.chomp if l.start_with?("Pacemaker Nodes:") in_pacemaker = true end if l.start_with?("Pacemaker Remote Nodes:") break end if l.end_with?(":") next end title,nodes = l.split(/: /,2) if nodes == nil next end if title == " Online" in_pacemaker ? pacemaker_online.concat(nodes.split(/ /)) : corosync_online.concat(nodes.split(/ /)) elsif title == " Standby" if in_pacemaker pacemaker_standby.concat(nodes.split(/ /)) end elsif title == " Maintenance" if in_pacemaker pacemaker_online.concat(nodes.split(/ /)) end else in_pacemaker ? pacemaker_offline.concat(nodes.split(/ /)) : corosync_offline.concat(nodes.split(/ /)) end } return { 'corosync_online' => corosync_online, 'corosync_offline' => corosync_offline, 'pacemaker_online' => pacemaker_online, 'pacemaker_offline' => pacemaker_offline, 'pacemaker_standby' => pacemaker_standby, } end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
it 'should return nil if the key ID is invalid' do expect(jwt_validator.jwks_key(:alg, "#{jwks_kid}_invalid")).to eq(nil) end
0
Ruby
CWE-347
Improper Verification of Cryptographic Signature
The software does not verify, or incorrectly verifies, the cryptographic signature for data.
https://cwe.mitre.org/data/definitions/347.html
vulnerable
def gate_process HistoryHelper.keep_last(request) SqlHelper.validate_token([session[:login_user_id]]) begin @login_user = User.find(session[:login_user_id]) rescue => evar @login_user = nil end begin if @login_user.nil? \ or @login_user.time_zone.nil? or @login_user.time_zone.empty? unless THETIS_USER_TIMEZONE_DEFAULT.nil? or THETIS_USER_TIMEZONE_DEFAULT.empty? Time.zone = THETIS_USER_TIMEZONE_DEFAULT end else Time.zone = @login_user.time_zone end rescue => evar logger.fatal(evar.to_s) end end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "returns a new indexes instance" do collection.indexes.should be_an_instance_of Moped::Indexes 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 "queries the master node" do session.should_receive(:socket_for).with(:write). and_return(socket) session.query(query) end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def log_operations(logger, ops, duration) prefix = " MOPED: #{address} " indent = " "*prefix.length runtime = (" (%.1fms)" % duration) if ops.length == 1 logger.debug prefix + ops.first.log_inspect + runtime else first, *middle, last = ops logger.debug prefix + first.log_inspect middle.each { |m| logger.debug indent + m.log_inspect } logger.debug indent + last.log_inspect + runtime 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 "sets the query operation's fields" do query.select(a: 1) query.operation.fields.should eq(a: 1) end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def save_page Log.add_info(request, params.inspect) return unless request.post? # Next page pave_val = params[:page].to_i + 1 @page = sprintf('%02d', pave_val) page_num = Dir.glob(File.join(Research.page_dir, "_q[0-9][0-9].html.erb")).length unless params[:research].nil? params[:research].each do |key, value| if value.instance_of?(Array) value.compact! value.delete('') if value.empty? params[:research][key] = nil else params[:research][key] = value.join("\n") + "\n" end end end end research_id = params[:research_id] SqlHelper.validate_token([research_id]) if research_id.blank? @research = Research.new(params.require(:research).permit(Research::PERMIT_BASE)) @research.status = Research::U_STATUS_IN_ACTON @research.update_attribute(:user_id, @login_user.id) else @research = Research.find(research_id) @research.update_attributes(params.require(:research).permit(Research::PERMIT_BASE)) end if pave_val <= page_num render(:action => 'edit_page') else tmpl_folder, tmpl_q_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_RESEARCH) if tmpl_q_folder.nil? ary = TemplatesHelper.setup_tmpl_folder tmpl_q_folder = ary[4] end items = Folder.get_items_admin(tmpl_q_folder.id, 'xorder ASC') @q_caps_h = {} unless items.nil? items.each do |item| desc = item.description next if desc.nil? or desc.empty? hash = Research.select_q_caps(desc) hash.each do |key, val| @q_caps_h[key] = val end end end render(:action => 'confirm') end rescue => evar Log.add_error(request, evar) @page = '01' render(:action => 'edit_page') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "returns the same hash" do Moped::BSON::ObjectId.new(bytes).hash.should eq Moped::BSON::ObjectId.new(bytes).hash 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 "handles Symbol keys with underscore" do cl = subject.build_command_line("true", :abc_def => "ghi") expect(cl).to eq "true --abc-def ghi" 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 test_attr_wrapper assert_equal("<p strange=*attrs*></p>\n", render("%p{ :strange => 'attrs'}", :attr_wrapper => '*')) assert_equal("<p escaped='quo\"te'></p>\n", render("%p{ :escaped => 'quo\"te'}", :attr_wrapper => '"')) assert_equal("<p escaped=\"quo'te\"></p>\n", render("%p{ :escaped => 'quo\\'te'}", :attr_wrapper => '"')) assert_equal("<p escaped=\"q'uo&#x0022;te\"></p>\n", render("%p{ :escaped => 'q\\'uo\"te'}", :attr_wrapper => '"')) assert_equal("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n", render("!!! XML", :attr_wrapper => '"', :format => :xhtml)) 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