code
stringlengths
12
2.05k
label
int64
0
1
programming_language
stringclasses
9 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
103
description
stringlengths
36
1.23k
url
stringlengths
36
48
label_name
stringclasses
2 values
def self.validate_token(tokens, extra_chars=nil) extra_chars = Regexp.escape((extra_chars || []).join()) regexp = Regexp.new("^[ ]*[a-zA-Z0-9_.#{extra_chars}]+[ ]*$") [tokens].flatten.each do |token| next if token.blank? if token.to_s.match(regexp).nil? raise("[ERROR] SqlHelper.validate_token failed: #{token}") end end end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def initialize(seeds, options = {}) @cluster = Cluster.new(seeds, {}) @context = Context.new(self) @options = options @options[:consistency] ||= :eventual end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def self.get_group_folder(group_id) SqlHelper.validate_token([group_id]) begin return Folder.where("(owner_id=#{group_id.to_i}) and (xtype='#{Folder::XTYPE_GROUP}')").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 destroy Log.add_info(request, params.inspect) return unless request.post? SqlHelper.validate_token([params[:id]]) begin Group.destroy(params[:id]) rescue => evar Log.add_error(request, evar) end render(:text => '') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "merges the old and new session's options" do session.with(new_options) do |new_session| new_session.options.should eq options.merge(new_options) 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 ls_files(query, options = {}) options[:ref] = options[:ref] ? options[:ref] : "HEAD" query = Shellwords.shellescape(query) @git.ls_files({}, "*#{query}*").split("\n") end
1
Ruby
CWE-284
Improper Access Control
The software does not restrict or incorrectly restricts access to a resource from an unauthorized actor.
https://cwe.mitre.org/data/definitions/284.html
safe
def from_data(data) id = allocate id.instance_variable_set :@data, data id end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def move Log.add_info(request, params.inspect) return unless request.post? @item = Item.find(params[:id]) unless params[:thetisBoxSelKeeper].nil? folder_id = params[:thetisBoxSelKeeper].split(':').last if Folder.check_user_auth(folder_id, @login_user, 'w', true) @item.update_attribute(:folder_id, folder_id) flash[:notice] = t('msg.move_success') else flash[:notice] = 'ERROR:' + t('folder.need_auth_to_write_in') end end render(:partial => 'ajax_move', :layout => false) rescue => evar Log.add_error(request, evar) flash[:notice] = 'ERROR:' + evar.to_s[0, 64] render(:partial => 'ajax_move', :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.new_from_xml_hash(hash) r = Review.new r.state = hash.delete('state') { raise ArgumentError, 'no state' } r.state = r.state.to_sym r.by_user = hash.delete('by_user') r.by_group = hash.delete('by_group') r.by_project = hash.delete('by_project') r.by_package = hash.delete('by_package') r.reviewer = r.creator = hash.delete('who') r.reason = hash.delete('comment') begin r.created_at = Time.zone.parse(hash.delete('when')) rescue TypeError # no valid time -> ignore end raise ArgumentError, "too much information #{hash.inspect}" if hash.present? r 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 index html = <<~HTML <!DOCTYPE html> <html> <head> </head> <body> <div id="app"></div> #{js_asset "jquery-1.8.2.js"} #{js_asset "react.js"} #{js_asset "react-dom.js"} #{js_asset "babel.min.js"} #{js_asset "message-bus.js"} #{js_asset "application.jsx", "text/jsx"} </body> </html> HTML [200, { "content-type" => "text/html;" }, [html]] 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 insert(database, collection, documents) with_node do |node| if safe? node.pipeline do node.insert(database, collection, documents) node.command("admin", { getlasterror: 1 }.merge(safety)) end else node.insert(database, collection, documents) end end end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def set_package_kind( kinds = nil ) check_write_access! private_set_package_kind( kinds ) end
1
Ruby
CWE-275
Permission Issues
Weaknesses in this category are related to improper assignment or handling of permissions.
https://cwe.mitre.org/data/definitions/275.html
safe
def self.get_tmpl_folder tmpl_folder = Folder.where(name: TMPL_ROOT).first if tmpl_folder.nil? ary = self.setup_tmpl_folder unless ary.nil? or ary.empty? tmpl_folder = ary[0] tmpl_system_folder = ary[1] tmpl_workflows_folder = ary[2] tmpl_local_folder = ary[3] tmpl_q_folder = ary[4] end else folders = Folder.where("parent_id=#{tmpl_folder.id}").to_a unless folders.nil? folders.each do |child| case child.name when TMPL_SYSTEM tmpl_system_folder = child when TMPL_WORKFLOWS tmpl_workflows_folder = child when TMPL_LOCAL tmpl_local_folder = child when TMPL_RESEARCH tmpl_q_folder = child end 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 "recognizes and generates #destroy" do { :delete => "/users/1" }.should route_to(:controller => "users", :action => "destroy", :id => "1") 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 flush(ops = queue) operations, callbacks = ops.transpose logging(operations) do ensure_connected do connection.write operations replies = connection.receive_replies(operations) replies.zip(callbacks).map do |reply, callback| callback ? callback[reply] : reply end.last end end ensure ops.clear end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "sets the query operation's skip field" do query.skip(5) query.operation.skip.should eq 5 end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it "returns all other known hosts" do cluster.sync_server(server).should =~ ["localhost:61085", "localhost:61086", "localhost:61084"] 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 socket_for(mode) if options[:retain_socket] @socket ||= cluster.socket_for(mode) else cluster.socket_for(mode) 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
it "logs in and processes commands" do session.login *Support::MongoHQ.auth_credentials session.command(ping: 1).should eq("ok" => 1) end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "should not allow an arbitary state (sanitizes input)" do where_stub = double where_stub.should_receive(:update_all).with(:state => "Expanded") Comment.should_receive(:where).and_return(where_stub) xhr :get, :timeline, :id => "1,2,3,4+", :state => "Expanded" 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 show Log.add_info(request, params.inspect) @group_id = params[:group_id] official_title_id = params[:id] unless official_title_id.nil? or official_title_id.empty? @official_title = OfficialTitle.find(official_title_id) end render(:layout => (!request.xhr?)) 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 "does not modify the original session" do session.with(database: "other") do |safe| session.options[:database].should eq "moped_test" 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 alive? if Kernel::select([self], nil, nil, 0) !eof? rescue false else true 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 disconnect @sock.close rescue ensure @sock = nil 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 mkdir_p_safe mkdir, mkdir_options, destination_dir, file_name destination_dir = realpath File.expand_path(destination_dir) parts = mkdir.split(File::SEPARATOR) parts.reduce do |path, basename| path = realpath path unless path == "" path = File.expand_path(path + File::SEPARATOR + basename) lstat = File.lstat path rescue nil if !lstat || !lstat.directory? unless path.start_with? destination_dir and (FileUtils.mkdir path, mkdir_options rescue false) raise Gem::Package::PathError.new(file_name, destination_dir) end end path end end
1
Ruby
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
https://cwe.mitre.org/data/definitions/22.html
safe
it "should be created correctly" do invite = Fabricate(:invite, email: '[email protected]') user = InviteRedeemer.create_user_from_invite(invite: invite, email: invite.email, username: 'walter', name: 'Walter White') expect(user.username).to eq('walter') expect(user.name).to eq('Walter White') expect(user.email).to eq('[email protected]') expect(user.approved).to eq(true) expect(user.active).to eq(false) 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 test_update_valid SmartProxy.any_instance.stubs(:valid?).returns(true) put :update, {:id => SmartProxy.first,:smart_proxy => {:url => "http://elsewhere.com:8443"}}, set_session_user assert_equal "http://elsewhere.com:8443", SmartProxy.first.url assert_redirected_to smart_proxies_url 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 test_login_should_not_redirect_to_another_host back_urls = [ 'http://test.foo/fake', '//test.foo/fake' ] back_urls.each do |back_url| post :login, :username => 'jsmith', :password => 'jsmith', :back_url => back_url assert_redirected_to '/my/page' 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 accepts?(env) session = session env token = session[:csrf] ||= session['_csrf_token'] || random_string safe?(env) || env['HTTP_X_CSRF_TOKEN'] == token || Request.new(env).params[options[:authenticity_param]] == token end
0
Ruby
CWE-203
Observable Discrepancy
The product behaves differently or sends different responses under different circumstances in a way that is observable to an unauthorized actor, which exposes security-relevant information about the state of the product, such as whether a particular operation was successful or not.
https://cwe.mitre.org/data/definitions/203.html
vulnerable
it "stores whether the connection is direct" do cluster.direct.should be_true 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 "updates the record matching selector with change" do session.should_receive(:with, :consistency => :strong). and_yield(session) session.should_receive(:execute).with do |update| update.flags.should eq [] update.selector.should eq query.operation.selector update.update.should eq change end query.update change end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def from_string(string) raise Errors::InvalidObjectId.new(string) unless legal?(string) data = [] 12.times { |i| data << string[i*2, 2].to_i(16) } new data end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def initialize(database, command, options = {}) super database, :$cmd, command, options.merge(limit: -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
def add_node_attr_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end retval = add_node_attr( session, params["node"], params["key"], params["value"] ) # retval = 2 if removing attr which doesn't exist if retval == 0 or retval == 2 return [200, "Successfully added attribute to node"] else return [400, "Error adding attribute to node"] 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 login Log.add_info(request, '') # Not to show passwords. user = User.authenticate(params[:user]) if user.nil? flash[:notice] = '<span class=\'font_msg_bold\'>'+t('user.u_name')+'</span>'+t('msg.or')+'<span class=\'font_msg_bold\'>'+t('password.name')+'</span>'+t('msg.is_invalid') if params[:fwd_controller].nil? or params[:fwd_controller].empty? redirect_to(:controller => 'login', :action => 'index') else url_h = {:controller => 'login', :action => 'index', :fwd_controller => params[:fwd_controller], :fwd_action => params[:fwd_action]} unless params[:fwd_params].nil? params[:fwd_params].each do |key, val| url_h["fwd_params[#{key}]"] = val end end redirect_to(url_h) end else @login_user = LoginHelper.on_login(user, session) if params[:fwd_controller].nil? or params[:fwd_controller].empty? prms = ApplicationHelper.get_fwd_params(params) prms.delete('user') prms[:controller] = 'desktop' prms[:action] = 'show' redirect_to(prms) else url_h = {:controller => params[:fwd_controller], :action => params[:fwd_action]} url_h = url_h.update(params[:fwd_params]) unless params[:fwd_params].nil? redirect_to(url_h) end end end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def drop_on_recyclebox Log.add_info(request, params.inspect) return unless request.post? SqlHelper.validate_token([params[:id]]) unless @login_user.nil? Toy.destroy(params[:id]) end render(:text => params[:id]) 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 wf_issue Log.add_info(request, params.inspect) begin @item = Item.find(params[:id]) @workflow = @item.workflow rescue => evar Log.add_error(request, evar) end attrs = ActionController::Parameters.new({status: Workflow::STATUS_ACTIVE, issued_at: Time.now}) @workflow.update_attributes(attrs.permit(Workflow::PERMIT_BASE)) @orders = @workflow.get_orders render(:partial => 'ajax_workflow', :layout => false) end
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 new session" do session.stub(with: new_session) session.new(new_options).should eql new_session end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def self.get_for(user_id, category=nil) SqlHelper.validate_token([user_id, category]) con = [] con << "(user_id=#{user_id})" con << "(category='#{category}')" unless category.nil? settings = Setting.where(con.join(' and ')).to_a return nil if settings.nil? or settings.empty? hash = Hash.new settings.each do |setting| hash[setting.xkey] = setting.xvalue end return hash end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
it "processes the block" do node.ensure_connected do node.command("admin", ping: 1) end.should eq("ok" => 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 list if params[:action] == 'list' Log.add_info(request, params.inspect) end @group_id = nil if !params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxSelKeeper].split(':').last elsif !params[:group_id].blank? @group_id = params[:group_id] end SqlHelper.validate_token([@group_id]) # Copy to FEATURE_PAGING_IN_TREE >>> con = ['User.id > 0'] unless @group_id.nil? if @group_id == '0' con << "((User.groups like '%|0|%') or (User.groups is null))" else con << SqlHelper.get_sql_like(['User.groups'], "|#{@group_id}|") end end if params[:keyword] key_array = params[:keyword].split(nil) key_array.each do |key| con << SqlHelper.get_sql_like(['User.name', 'User.email', 'User.fullname', 'User.address', 'User.organization', 'User.tel1', 'User.tel2', 'User.tel3', 'User.fax', 'User.url', 'User.postalcode', 'User.title'], key) end end where = '' unless con.empty? where = ' where ' + con.join(' and ') end order_by = nil @sort_col = params[:sort_col] @sort_type = params[:sort_type] if @sort_col.blank? or @sort_type.blank? @sort_col = 'OfficialTitle.xorder' @sort_type = 'ASC' end SqlHelper.validate_token([@sort_col, @sort_type]) order_by = @sort_col + ' ' + @sort_type if @sort_col == 'OfficialTitle.xorder' order_by = '(OfficialTitle.xorder is null) ' + @sort_type + ', ' + order_by else order_by << ', (OfficialTitle.xorder is null) ASC, OfficialTitle.xorder ASC' end if @sort_col != 'User.name' order_by << ', User.name ASC' end sql = 'select distinct User.* from (users User left join user_titles UserTitle on User.id=UserTitle.user_id)' sql << ' left join official_titles OfficialTitle on UserTitle.official_title_id=OfficialTitle.id' sql << where + ' order by ' + order_by @user_pages, @users, @total_num = paginate_by_sql(User, sql, 50) # Copy to FEATURE_PAGING_IN_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 test_destroy domain = @model domain.hosts.clear domain.hostgroups.clear domain.subnets.clear delete :destroy, {:id => domain}, set_session_user assert_redirected_to domains_url assert !Domain.exists?(domain.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
def self.quote(str) return ActiveRecord::Base.connection.quote(str) 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_disp_ctrl Log.add_info(request, params.inspect) folder_id = params[:id] SqlHelper.validate_token([folder_id]) if folder_id != '0' begin @folder = Folder.find(folder_id) rescue => evar @folder = nil end end session[:folder_id] = folder_id render(:partial => 'ajax_disp_ctrl', :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 validate_back_url(back_url) if CGI.unescape(back_url).include?('..') return false end begin uri = URI.parse(back_url) rescue URI::InvalidURIError return false end [:scheme, :host, :port].each do |component| if uri.send(component).present? && uri.send(component) != request.send(component) return false end uri.send(:"#{component}=", nil) end # Always ignore basic user:password in the URL uri.userinfo = nil path = uri.to_s # Ensure that the remaining URL starts with a slash, followed by a # non-slash character or the end if path !~ %r{\A/([^/]|\z)} return false end if path.match(%r{/(login|account/register)}) return false end if relative_url_root.present? && !path.starts_with?(relative_url_root) return false end return path end
1
Ruby
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
safe
def paidhld_update_multi Log.add_info(request, params.inspect) return unless request.post? year = params[:year].to_i num = params[:num].to_f group_id = params[:group_id] users_hash = (params[:check_user] || {}) SqlHelper.validate_token([group_id, users_hash.keys]) done = false users_hash.each do |user_id, value| if value == '1' PaidHoliday.update_for(user_id, year, num) done = true end end unless done if group_id.blank? users = (User.find_all || []) else users = Group.get_users(group_id) end users.each do |user| PaidHoliday.update_for(user.id, year, num) end end flash[:notice] = t('msg.update_success') self.users render(:action => 'users') rescue => evar Log.add_error(request, evar) flash[:notice] = 'ERROR:' + evar.to_s self.users render(:action => 'users') 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(uuid, options = {}) if uuid.nil? || uuid.to_s.empty? raise NotFound, "can't find a record with nil identifier" end uri = uuid =~ /^http/ ? uuid : member_path(uuid) begin from_response API.get(uri, {}, options) rescue API::NotFound => e raise NotFound, e.description end 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 check_owner return if params[:id].nil? or params[:id].empty? or @login_user.nil? begin owner_id = Location.find(params[:id]).user_id rescue owner_id = -1 end if !@login_user.admin?(User::AUTH_LOCATION) and owner_id != @login_user.id Log.add_check(request, '[check_owner]'+request.to_s) flash[:notice] = t('msg.need_to_be_owner') redirect_to(:controller => 'desktop', :action => 'show') end end
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 shutdown @servers.each &:close @clients.each &:close @shutdown = true end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def escape_javascript(javascript) javascript = javascript.to_s if javascript.empty? result = "" else result = javascript.gsub(/(\\|<\/|\r\n|\342\200\250|\342\200\251|[\n\r"']|[`]|[$])/u, JS_ESCAPE_MAP) end javascript.html_safe? ? result.html_safe : result end
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 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 #{script_file.path}") raise RuntimeError.new('gpg failed') unless result ensure script_file.close script_file.unlink 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 down! @down_at = Time.new disconnect 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 drop session.with(consistency: :strong) do |session| session.context.command name, dropDatabase: 1 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 update_config Log.add_info(request, params.inspect) yaml = ApplicationHelper.get_config_yaml unless params[:timecard].nil? or params[:timecard].empty? yaml[:timecard] = Hash.new if yaml[:timecard].nil? params[:timecard].each do |key, val| yaml[:timecard][key] = val end ApplicationHelper.save_config_yaml(yaml) end @yaml_timecard = yaml[:timecard] @yaml_timecard = Hash.new if @yaml_timecard.nil? flash[:notice] = t('msg.update_success') render(:action => 'configure') end
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 auth_database ENV["MONGOHQ_SINGLE_NAME"] 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 raise a warning (and keep parsing) on having an incorrectly formatted header" do STDERR.should_receive(:puts).with("WARNING: Could not parse (and so ignoring) 'quite Delivered-To: [email protected]'") Mail.read(fixture('emails', 'plain_emails', 'raw_email_incorrect_header.eml')) end
0
Ruby
CWE-93
Improper Neutralization of CRLF Sequences ('CRLF Injection')
The software uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.
https://cwe.mitre.org/data/definitions/93.html
vulnerable
def rename Log.add_info(request, params.inspect) @group = Group.find(params[:id]) unless params[:thetisBoxEdit].nil? or params[:thetisBoxEdit].empty? @group.rename params[:thetisBoxEdit] end render(:partial => 'ajax_group_name', :layout => false) rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_group_name', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def legal?(str) !!str.match(/^[0-9a-f]{24}$/i) 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 content_types_from_name @content_types_from_name ||= MIME::Types.type_for(@name) 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 private_message_reset_new topic_query = TopicQuery.new(current_user, limit: false) if params[:topic_ids].present? unless Array === params[:topic_ids] raise Discourse::InvalidParameters.new( "Expecting topic_ids to contain a list of topic ids" ) end topic_scope = topic_query .private_messages_for(current_user, :all) .where("topics.id IN (?)", params[:topic_ids].map(&:to_i)) else params.require(:inbox) inbox = params[:inbox].to_s filter = private_message_filter(topic_query, inbox) topic_scope = topic_query.filter_private_message_new(current_user, filter) end topic_ids = TopicsBulkAction.new( current_user, topic_scope.distinct(false).pluck(:id), type: "dismiss_topics" ).perform! render json: success_json.merge(topic_ids: topic_ids) end
0
Ruby
CWE-863
Incorrect Authorization
The software performs an authorization check when an actor attempts to access a resource or perform an action, but it does not correctly perform the check. This allows attackers to bypass intended access restrictions.
https://cwe.mitre.org/data/definitions/863.html
vulnerable
def hiccup @set.manager.close_clients_for(self) 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(remote_host, remote_port, local_host = nil, local_port = nil) if Thread.current[:private_address_check] && PrivateAddressCheck.resolves_to_private_address?(remote_host) raise PrivateAddressCheck::PrivateConnectionAttemptedError end initialize_without_private_address_check(remote_host, remote_port, local_host, local_port) end
0
Ruby
CWE-362
Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.
https://cwe.mitre.org/data/definitions/362.html
vulnerable
def start @nodes.each &:start @worker = Thread.start do Thread.abort_on_exception = true catch(:shutdown) do loop do Moped.logger.debug "replica_set: waiting for next client" server, client = @manager.next_client if server Moped.logger.debug "replica_set: proxying incoming request to mongo" server.proxy(client, @mongo) else Moped.logger.debug "replica_set: no requests; passing" Thread.pass end end 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 column_content(column, item) value = column.value_object(item) if value.is_a?(Array) values = value.collect {|v| column_value(column, item, v)}.compact safe_join(values, ', ') else column_value(column, item, value) 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
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-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 Log.add_info(request, params.inspect) return unless request.post? if params[:check_xlog].nil? list render(:action => 'list') return end count = 0 SqlHelper.validate_token([params[:check_xlog].keys]) params[:check_xlog].each do |key, value| if value == '1' ZeptairXlog.delete(key) count += 1 end end list flash[:notice] = count.to_s + t('log.deleted') render(:action => 'list') 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 more? @get_more_op.cursor_id != 0 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 disconnect @sock.close rescue ensure @sock = nil 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 pcsd_restart_nodes(session, nodes) node_response = {} threads = [] nodes.each { |node| threads << Thread.new { code, response = send_request_with_token( session, node, '/pcsd_restart', true ) node_response[node] = [code, response] } } threads.each { |t| t.join } node_error = [] node_status = {} node_response.each { |node, response| if response[0] == 200 node_status[node] = { 'status' => 'ok', 'text' => 'Success', } else text = response[1] if response[0] == 401 text = "Unable to authenticate, try running 'pcs cluster auth'" elsif response[0] == 400 begin parsed_response = JSON.parse(response[1], {:symbolize_names => true}) if parsed_response[:noresponse] text = "Unable to connect" elsif parsed_response[:notoken] or parsed_response[:notauthorized] text = "Unable to authenticate, try running 'pcs cluster auth'" end rescue JSON::ParserError end end node_status[node] = { 'status' => 'error', 'text' => text } node_error << node end } return { 'status' => node_error.empty?() ? 'ok' : 'error', 'text' => node_error.empty?() ? 'Success' : \ "Unable to restart pcsd on nodes: #{node_error.join(', ')}", 'node_status' => node_status, } end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
it "raises an AuthenticationFailure exception" do session.login "invalid-user", "invalid-password" lambda do session.command(ping: 1) end.should raise_exception(Moped::Errors::AuthenticationFailure) 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 session.with(consistency: :strong) do |session| session.context.remove operation.database, operation.collection, operation.selector, flags: [:remove_first] 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_bad_early_options assert_raise HgCommandArgumentError do @adapter.diff('sources/welcome_controller.rb', '--config=alias.rhdiff=!xterm') end assert_raise HgCommandArgumentError do @adapter.entries('--debugger') end assert_raise HgCommandArgumentError do @adapter.revisions(nil, nil, nil, limit: '--repo=otherrepo') end assert_raise HgCommandArgumentError do @adapter.nodes_in_branch('default', limit: '--repository=otherrepo') end assert_raise HgCommandArgumentError do @adapter.nodes_in_branch('-Rotherrepo') end end
1
Ruby
NVD-CWE-noinfo
null
null
null
safe
def update_mail_unread Log.add_info(request, params.inspect) return unless request.post? email_id = params[:email_id] unread = (params[:unread] == "1") begin email = Email.find(email_id) if !email.nil? and (email.user_id == @login_user.id) if email.xtype == Email::XTYPE_RECV status = (unread)?(Email::STATUS_UNREAD):(Email::STATUS_NONE) email.update_attribute(:status, status) end end rescue => evar Log.add_error(nil, evar) end render(:text => '') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def destroy_multi Log.add_info(request, params.inspect) return unless request.post? if params[:check_item].nil? list render(:action => 'list') return end is_admin = @login_user.admin?(User::AUTH_ITEM) count = 0 params[:check_item].each do |item_id, value| if value == '1' begin item = Item.find(item_id) next if !is_admin and item.user_id != @login_user.id item.destroy rescue => evar Log.add_error(request, evar) end count += 1 end end flash[:notice] = t('item.deleted', :count => count) params[:folder_id] = session[:folder_id] list render(:action => 'list') 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 "converts false to a boolean" do bundle "add 'foo' --require=false" expect(bundled_app_gemfile.read).to match(/gem "foo",(?: .*,) :require => false/) end
1
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
safe
def update_folders_order Log.add_info(request, params.inspect) return unless request.post? order_arr = params[:folders_order] SqlHelper.validate_token([params[:id]]) folders = MailFolder.get_childs(params[:id], false, false) # folders must be ordered by xorder ASC. folders.sort! { |id_a, id_b| idx_a = order_arr.index(id_a) idx_b = order_arr.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
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 config_restore(params, request, session) if params[:name] code, response = send_request_with_token( session, params[:name], 'config_restore', true, {:tarball => params[:tarball]} ) else if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end $logger.info "Restore node configuration" if params[:tarball] != nil and params[:tarball] != "" out = "" errout = "" status = Open4::popen4(PCS, "config", "restore", "--local") { |pid, stdin, stdout, stderr| stdin.print(params[:tarball]) stdin.close() out = stdout.readlines() errout = stderr.readlines() } retval = status.exitstatus if retval == 0 $logger.info "Restore successful" return "Succeeded" else $logger.info "Error during restore: #{errout.join(' ').strip()}" return errout.length > 0 ? errout.join(' ').strip() : "Error" end else $logger.info "Error: Invalid tarball" return "Error: Invalid tarball" 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 self.up add_column :items, :source_id, :integer add_column :addresses, :groups, :text add_column :addresses, :teams, :text add_column :workflows, :groups, :text add_column :users, :figure, :string add_column :groups, :xtype, :string add_column :teams, :req_to_del_at, :datetime change_table :teams do |t| t.timestamps end Team.find_each do |team| begin item = Item.find(team.item_id) rescue end next if item.nil? attrs = ActionController::Parameters.new({created_at: item.created_at, updated_at: item.updated_at}) attrs.permit! team.update_attributes(attrs) 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 command(database, command) options = consistency == :eventual ? { :flags => [:slave_ok] } : {} with_node do |node| node.command(database, command, options) 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 search Log.add_info(request, params.inspect) unless params[:select_sorting].nil? or params[:select_sorting].empty? sort_a = params[:select_sorting].split(' ') params[:sort_col] = sort_a.first params[:sort_type] = sort_a.last end list if params[:keyword].nil? or params[:keyword].empty? if params[:from_action].nil? or params[:from_action] == 'bbs' render(:action => 'bbs') else render(:action => 'list') end end end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def destroy Log.add_info(request, params.inspect) return unless request.post? workflow = Workflow.find(params[:id]) begin workflow.item.destroy rescue => evar Log.add_error(nil, evar) end my_wf_folder = WorkflowsHelper.get_my_wf_folder(@login_user.id) sql = WorkflowsHelper.get_list_sql(@login_user.id, my_wf_folder.id) @workflows = Workflow.find_by_sql(sql) render(:partial => 'ajax_workflow', :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 "returns the query" do query.limit(5).should eql 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
it "returns the right category group permissions for an anon user" do json = described_class.new(category, scope: Guardian.new, root: false).as_json expect(json[:group_permissions]).to eq([ { permission_type: CategoryGroup.permission_types[:full], group_name: Group[:everyone]&.name } ]) end
0
Ruby
CWE-276
Incorrect Default Permissions
During installation, installed file permissions are set to allow anyone to modify those files.
https://cwe.mitre.org/data/definitions/276.html
vulnerable
def update Log.add_info(request, params.inspect) return unless request.post? attrs = params[:mail_filter] if attrs['and_or'] == 'none' attrs['and_or'] = nil attrs['conditions'] = nil else filter_conditions = params[:filter_condition] condition_entries = [] filter_conditions.each do |condition_id, entry| point, compare, val = entry.split("\n") if val.nil? or val.empty? condition_entries << [point, compare].join('-') else condition_entries << [point, compare, val].join('-') end end attrs['conditions'] = condition_entries.join("\n") end filter_actions = params[:filter_action] action_entries = [] filter_actions.each do |action_id, entry| verb, val = entry.split("\n") if val.nil? or val.empty? action_entries << verb else action_entries << [verb, val].join('-') end end attrs['actions'] = action_entries.join("\n") mail_filter_id = params[:id] if mail_filter_id.blank? @mail_filter = MailFilter.new(attrs.permit(MailFilter::PERMIT_BASE)) @mail_filter.mail_account_id = params[:mail_account_id] else @mail_filter = MailFilter.find(mail_filter_id) if @mail_filter.mail_account.user_id != @login_user.id flash[:notice] = t('msg.need_to_be_owner') redirect_to(:controller => 'desktop', :action => 'show') return end end if @mail_filter.id.nil? @mail_filter.save! flash[:notice] = t('msg.register_success') else @mail_filter.update_attributes(attrs.permit(MailFilter::PERMIT_BASE)) flash[:notice] = t('msg.update_success') end list render(:action => 'list', :layout => !request.xhr?) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def send_password Log.add_info(request, params.inspect) mail_addr = params[:thetisBoxEdit] SqlHelper.validate_token([mail_addr]) begin users = User.where("email='#{mail_addr}'").to_a rescue => evar end if users.nil? or users.empty? Log.add_error(request, evar) flash[:notice] = 'ERROR:' + t('email.address_not_found') else user_passwords_h = {} users.each do |user| newpass = UsersHelper.generate_password user.update_attribute(:pass_md5, UsersHelper.generate_digest_pass(user.name, newpass)) user_passwords_h[user] = newpass end NoticeMailer.password(user_passwords_h, ApplicationHelper.root_url(request)).deliver; flash[:notice] = t('email.sent') end render(:controller => 'login', :action => 'index') end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def resource_clone(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end unless params[:resource_id] return [400, 'resource_id has to be specified.'] end _, stderr, retval = run_cmd( session, PCS, 'resource', 'clone', params[:resource_id] ) if retval != 0 return [400, 'Unable to create clone resource from ' + "'#{params[:resource_id]}': #{stderr.join('')}" ] 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 "returns the same hash" do Moped::BSON::ObjectId.from_data(bytes).hash.should eq Moped::BSON::ObjectId.from_data(bytes).hash end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def self.execute_action_move(mail_filter, email, val) mail_folder_id = val mail_folder = MailFolder.find_by_id(mail_folder_id) if !mail_folder.nil? and (mail_folder.user_id == email.user_id) email.update_attribute(:mail_folder_id, mail_folder_id) end return true end
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 "defaults to an empty selector" do Moped::Query.should_receive(:new). with(collection, {}).and_return(query) collection.find.should eq query end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it "updates to a mongo advanced selector" do query.explain query.operation.selector.should eq( "$query" => selector, "$explain" => true, "$orderby" => { _id: 1 } ) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def queue Threaded.stack(:pipelined_operations) 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 original_filename filename = filename_from_header || filename_from_uri mime_type = MiniMime.lookup_by_content_type(file.content_type) unless File.extname(filename).present? || mime_type.blank? filename = "#{filename}.#{mime_type.extension}" end filename 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 update_q_ctrl Log.add_info(request, params.inspect) return unless request.post? 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
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 "sanitizes Fixnum array param value" do cl = subject.build_command_line("true", nil => [1]) expect(cl).to eq "true 1" 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 match_resource(env) path = env[PATH_INFO] origin = env[HTTP_ORIGIN] origin_matched = false all_resources.each do |r| if r.allow_origin?(origin, env) origin_matched = true if found = r.match_resource(path, env) return [found, nil] end end end [nil, origin_matched ? Result::MISS_NO_PATH : Result::MISS_NO_ORIGIN] 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 record(node, operations) key = if node.primary? :primary elsif node.secondary? :secondary else :other end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def self.get_for(user_id) SqlHelper.validate_token([user_id]) return Research.where("user_id=#{user_id}").first end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def check_owner return if params[:id].nil? or params[:id].empty? or @login_user.nil? begin owner_id = Workflow.find(params[:id]).user_id rescue owner_id = -1 end if !@login_user.admin?(User::AUTH_WORKFLOW) and owner_id != @login_user.id Log.add_check(request, '[check_owner]'+request.to_s) flash[:notice] = t('msg.need_to_be_owner') redirect_to(:controller => 'desktop', :action => 'show') end end
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 "applies the cached authentication" do cluster.stub(:sync) { cluster.servers << server } socket.should_receive(:apply_auth).with(cluster.auth) 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
def self.get_group_folder(group_id) SqlHelper.validate_token([group_id]) begin return Folder.where("(owner_id=#{group_id}) and (xtype='#{Folder::XTYPE_GROUP}')").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