code
stringlengths
12
2.05k
label
int64
0
1
programming_language
stringclasses
9 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
103
description
stringlengths
36
1.23k
url
stringlengths
36
48
label_name
stringclasses
2 values
def self.get_childs(klass, node_id, recursive, ret_obj) SqlHelper.validate_token([node_id]) array = [] if recursive tree = klass.get_tree(Hash.new, nil, node_id) return array if tree.nil? tree.each do |parent_id, childs| if ret_obj array |= childs else childs.each do |node| node_id = node.id.to_s array << node_id unless array.include?(node_id) end end end else nodes = klass.where("parent_id=#{node_id.to_i}").order('xorder ASC, id ASC').to_a if ret_obj array = nodes else nodes.each do |node| array << node.id.to_s end end end return array 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 "executes the operation on the master node" do session.should_receive(:socket_for).with(:write). and_return(socket) socket.should_receive(:execute).with(operation) session.execute(operation) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def self.get_for(user_id, fiscal_year=nil) SqlHelper.validate_token([user_id, fiscal_year]) begin con = [] con << "(user_id=#{user_id.to_i})" if fiscal_year.nil? return PaidHoliday.where(con).order('year ASC').to_a else con << "(year=#{fiscal_year.to_i})" return PaidHoliday.where(con.join(' and ')).first end rescue end return nil 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 reset_users Log.add_info(request, params.inspect) count = 0 unless params[:check_user].nil? params[:check_user].each do |user_id, value| if value == '1' begin Research.destroy_all('user_id=' + user_id.to_s) count += 1 rescue => evar Log.add_error(request, evar) end end end end if count > 0 flash[:notice] = t('msg.status_of')+ count.to_s + t('user.status_reset') end redirect_to(:controller => 'researches', :action => 'users') rescue => evar Log.add_error(request, evar) render(:text => evar.to_s) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def category_preferences_export return enum_for(:category_preferences_export) unless block_given? CategoryUser .where(user_id: @current_user.id) .select(:category_id, :notification_level, :last_seen_at) .each do |cu| yield [ cu.category_id, piped_category_name(cu.category_id), NotificationLevels.all[cu.notification_level], cu.last_seen_at ] end 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 output_versions output, versions versions.each do |gem_name, matching_tuples| matching_tuples = matching_tuples.sort_by { |n,_| n.version }.reverse platforms = Hash.new { |h,version| h[version] = [] } matching_tuples.each do |n, _| platforms[n.version] << n.platform if n.platform end seen = {} matching_tuples.delete_if do |n,_| if seen[n.version] then true else seen[n.version] = true false end end output << make_entry(matching_tuples, platforms) 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 on_moved Log.add_info(request, params.inspect) location_id = params[:id] if location_id.nil? or location_id.empty? location = Location.get_for(@login_user) if location.nil? location = Location.new location.user_id = @login_user.id end else begin location = Location.find(location_id) rescue end end unless location.nil? group_id = params[:group_id] group_id = nil if group_id.empty? attrs = ActionController::Parameters.new({group_id: group_id, x: params[:x], y: params[:y]}) location.update_attributes(attrs.permit(Location::PERMIT_BASE)) end render(:text => (location.nil?)?'':location.id.to_s) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def record(node, operations) key = if node.primary? :primary elsif node.secondary? :secondary else :other end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "logs out" do lambda do session.command dbStats: 1 end.should_not raise_exception session.logout lambda do session.command dbStats: 1 end.should raise_exception(Moped::Errors::OperationFailure) end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "should should be a subclass of Base" do Puppet::FileServing::Metadata.superclass.should equal(Puppet::FileServing::Base) end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
def self.destroy(host) if host =~ Regexp.union(/[#{SEPARATOR}]/, /\A\.\.?\Z/) raise ArgumentError, "Invalid node name #{host.inspect}" end dir = File.join(Puppet[:reportdir], host) if File.exists?(dir) Dir.entries(dir).each do |file| next if ['.','..'].include?(file) file = File.join(dir, file) File.unlink(file) if File.file?(file) end Dir.rmdir(dir) 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 "returns the master connection" do cluster.socket_for(:read).should eq socket end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def get_tokens(params, request, session) # pcsd runs as root thus always returns hacluster's tokens if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end return [200, JSON.generate(read_tokens)] end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def initialize(nodes = 3) @nodes = nodes.times.map { Node.new(self) } @manager = ConnectionManager.new(@nodes) @mongo = TCPSocket.new "127.0.0.1", 27017 end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def new_ally_request_link(uniqueid, data) link = "/profile?uid=#{data[:uid]}" link_html = "<a href=\"#{link}\">#{data[:user]}</a>" # rubocop:disable Layout/LineLength "<div id=\"#{uniqueid}\"><div>#{t('notifications.ally.sent_html', link_to_user: link_html)}</div>#{request_actions(data[:user_id])}</div>" # rubocop:enable Layout/LineLength end
0
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def first session.simple_query(operation) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def each documents = query @query_op documents.each { |doc| yield doc } while more? return kill if limited? && @get_more_op.limit <= 0 documents = query @get_more_op documents.each { |doc| yield doc } end end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def paginate_by_sql(model, sql, per_page, options={}) if options[:count].blank? total = model.count_by_sql_wrapping_select_query(sql) else if options[:count].is_a?(Integer) total = options[:count] #else # total = model.count_by_sql(options[:count]) end end SqlHelper.validate_token([params['page']]) object_pages = model.paginate_by_sql(sql, {:page => params['page'], :per_page => per_page}) return [object_pages, object_pages, total] 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 empty Log.add_info(request, params.inspect) @folder_id = params[:id] mail_account_id = params[:mail_account_id] SqlHelper.validate_token([mail_account_id]) trash_folder = MailFolder.get_for(@login_user, mail_account_id, MailFolder::XTYPE_TRASH) mail_folder = MailFolder.find(@folder_id) emails = MailFolder.get_mails(mail_folder.id, @login_user) || [] if mail_folder.id == trash_folder.id \ or mail_folder.get_parents(false).include?(trash_folder.id.to_s) emails.each do |email| email.destroy end flash[:notice] = t('msg.delete_success') else emails.each do |email| email.update_attribute(:mail_folder_id, trash_folder.id) end flash[:notice] = t('msg.moved_to_trash') end get_mails 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 mime_magic_content_type(new_file) content_type = nil File.open(new_file.path) do |fd| content_type = Marcel::MimeType.for(fd) end content_type end
0
Ruby
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
vulnerable
def test_jail_classes_should_have_limited_methods expected = ["new", "methods", "name", "inherited", "method_added", "inspect", "allow", "allowed?", "allowed_methods", "init_allowed_methods", "<", # < needed in Rails Object#subclasses_of "ancestors", "==" # ancestors and == needed in Rails::Generator::Spec#lookup_class ] objects.each do |object| assert_equal expected.sort, reject_pretty_methods(object.to_jail.class.methods.map(&:to_s).sort) end end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
def replica_set_session(auth = true) session = Moped::Session.new replica_set_seeds, database: replica_set_database session.login *replica_set_credentials if auth session end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "sets the generation time" do time = Time.at((Time.now.utc - 64800).to_i).utc Moped::BSON::ObjectId.from_time(time).generation_time.should == time end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def logout session.context.logout(name) end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it 'should return a second factor prompt' do get "/session/email-login/#{email_token.token}" expect(response.status).to eq(200) response_body = CGI.unescapeHTML(response.body) expect(response_body).to include(I18n.t( "login.second_factor_title" )) expect(response_body).to_not include(I18n.t( "login.invalid_second_factor_code" )) end
0
Ruby
CWE-287
Improper Authentication
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
def self.get_carried_over(user_id, year) SqlHelper.validate_token([user_id, year]) yaml = ApplicationHelper.get_config_yaml unless yaml[:timecard].nil? paidhld_carry_over = yaml[:timecard]['paidhld_carry_over'] end return 0 if paidhld_carry_over.nil? or paidhld_carry_over.empty? or paidhld_carry_over == PaidHoliday::CARRY_OVER_NONE begin con = "(user_id=#{user_id}) and (year < #{year})" paidhlds = PaidHoliday.where(con).order('year ASC').to_a rescue end return 0 if paidhlds.nil? or paidhlds.empty? sum = 0 year_begins_from, month_begins_at = TimecardsHelper.get_fiscal_params if paidhld_carry_over == PaidHoliday::CARRY_OVER_1_YEAR last_carried_out = 0 for y in paidhlds.first.year .. year - 1 paidhld = paidhlds.find { |hld| hld.year == y } given_num = (paidhld.nil?)?0:paidhld.num start_date, end_date = TimecardsHelper.get_year_span(y, year_begins_from, month_begins_at) applied_paid_hlds = Timecard.applied_paid_hlds(user_id, start_date, end_date) if applied_paid_hlds >= last_carried_out last_carried_out = given_num - (applied_paid_hlds - last_carried_out) else last_carried_out = given_num end end return last_carried_out elsif paidhld_carry_over == PaidHoliday::CARRY_OVER_NO_EXPIRATION paidhlds.each do |paidhld| sum += paidhld.num end start_date, dummy = TimecardsHelper.get_year_span(paidhlds.first.year, year_begins_from, month_begins_at) dummy, end_date = TimecardsHelper.get_year_span(year - 1, year_begins_from, month_begins_at) applied_paid_hlds = Timecard.applied_paid_hlds(user_id, start_date, end_date) return (sum - applied_paid_hlds) else return 0 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 from_string(string) unless legal?(string) raise Invalid.new("'#{string}' is an invalid ObjectId.") end from_data([ string ].pack("H*")) end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def send_password Log.add_info(request, params.inspect) mail_addr = params[:thetisBoxEdit] SqlHelper.validate_token([mail_addr], ['@-']) begin users = User.where("email='#{mail_addr}'").to_a rescue => evar end if users.nil? or users.empty? Log.add_error(request, evar) 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 build_command_line(command, params = nil) return command.to_s if params.nil? || params.empty? "#{command} #{assemble_params(sanitize(params))}" end
0
Ruby
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
def _call(env) unless ALLOWED_VERBS.include? env["REQUEST_METHOD"] return fail(405, "Method Not Allowed") end path_info = Utils.unescape(env["PATH_INFO"]) parts = path_info.split SEPS parts.inject(0) do |depth, part| case part when '', '.' depth when '..' return fail(404, "Not Found") if depth - 1 < 0 depth - 1 else depth + 1 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 one_time_password otp_username = $redis.get "otp_#{params[:token]}" if otp_username && user = User.find_by_username(otp_username) log_on_user(user) $redis.del "otp_#{params[:token]}" return redirect_to path("/") else @error = I18n.t('user_api_key.invalid_token') end render layout: 'no_ember' end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def set_admin User.current = users(:admin) end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def __bson_dump__(io, key) io << Types::OBJECT_ID io << key io << NULL_BYTE io << data.pack('C12') end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def test_clone get :clone, {:id => hostgroups(:common)}, set_session_user assert_template 'new' end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def generate(type, str) case type when :md5 attribute_value = '{MD5}' + Base64.encode64(Digest::MD5.digest(str)).chomp! when :sha attribute_value = '{SHA}' + Base64.encode64(Digest::SHA1.digest(str)).chomp! when :ssha srand; salt = (rand * 1000).to_i.to_s attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp! else raise Net::LDAP::HashTypeUnsupportedError, "Unsupported password-hash type (#{type})" end
0
Ruby
CWE-916
Use of Password Hash With Insufficient Computational Effort
The software generates a hash for a password, but it uses a scheme that does not provide a sufficient level of computational effort that would make password cracking attacks infeasible or expensive.
https://cwe.mitre.org/data/definitions/916.html
vulnerable
def self.authenticate(attrs) return nil if attrs.nil? or attrs[:name].nil? or attrs[:password].nil? name = attrs[:name] password = attrs[:password] SqlHelper.validate_token([name]) pass_md5 = UsersHelper.generate_digest_pass(name, password) return User.where("(name='#{name}') and (pass_md5='#{pass_md5}')").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 get_folders_order Log.add_info(request, params.inspect) @folder_id = params[:id] if @folder_id == '0' @folders = MailFolder.get_account_roots_for(@login_user) else mail_folder = MailFolder.find(@folder_id) if mail_folder.user_id == @login_user.id @folders = MailFolder.get_childs(@folder_id, false, true) end end render(:partial => 'ajax_folders_order', :layout => false) rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_folders_order', :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 command(database, cmd, options = {}) operation = Protocol::Command.new(database, cmd, options) process(operation) do |reply| result = reply.documents[0] raise Errors::OperationFailure.new( operation, result ) if result["ok"] != 1 || result["err"] || result["errmsg"] result 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 lookup_server(client) port = client.addr(false)[1] @servers.find do |server| server.to_io && server.to_io.addr[1] == port end end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
it "updates a hostgroup with a parent parameter, allows empty values" do child = FactoryGirl.create(:hostgroup, :parent => @base) as_admin do assert_equal "original", child.parameters["x"] end post :update, {"id" => child.id, "hostgroup" => {"name" => child.name, :group_parameters_attributes => {"0" => {:name => "x", :value => "", :_destroy => ""}, "1" => {:name => "y", :value => "overridden", :_destroy => ""}}}}, set_session_user assert_redirected_to hostgroups_url child.reload assert_equal "overridden", child.parameters["y"] assert_equal "", child.parameters["x"] 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 check_mail_owner return if params[:id].blank? or @login_user.nil? begin owner_id = Email.find(params[:id]).user_id rescue owner_id = -1 end if !@login_user.admin?(User::AUTH_MAIL) and owner_id != @login_user.id Log.add_check(request, '[check_mail_owner]'+request.to_s) flash[:notice] = t('msg.need_to_be_owner') redirect_to(:controller => 'desktop', :action => 'show') 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 down? @down_at end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def connect(host, port, timeout) @sock = TCPSocket.connect host, port, timeout end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
it 'returns success' do get "/session/email-login/#{email_token.token}" expect(response).to redirect_to("/") end
0
Ruby
CWE-287
Improper Authentication
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
it 'does not parse scientific notation' do expect(Raven::OkJson.decode("[123e090]")).to eq ["123e090"] end
1
Ruby
CWE-399
Resource Management Errors
Weaknesses in this category are related to improper management of system resources.
https://cwe.mitre.org/data/definitions/399.html
safe
def week Log.add_info(request, params.inspect) date_s = params[:date] if date_s.blank? @date = Date.today else @date = Date.parse(date_s) end params[:display] = 'week' end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def valid_back_url?(back_url) !!validate_back_url(back_url) end
1
Ruby
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
safe
def login(database, username, password) cluster.auth[database.to_s] = [username, password] end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def create Log.add_info(request, params.inspect) return unless request.post? my_wf_folder = WorkflowsHelper.get_my_wf_folder(@login_user.id) tmpl_item = Item.find(params[:select_workflow]) item = tmpl_item.copy(@login_user.id, my_wf_folder.id) attrs = ActionController::Parameters.new({title: tmpl_item.title + t('msg.colon') + User.get_name(@login_user.id), public: false}) item.update_attributes(attrs.permit(Item::PERMIT_BASE)) item.workflow.update_attribute(:status, Workflow::STATUS_NOT_ISSUED) sql = WorkflowsHelper.get_list_sql(@login_user.id, my_wf_folder.id) @workflows = Workflow.find_by_sql(sql) render(:partial => 'ajax_workflow', :layout => false) rescue => evar Log.add_error(request, evar) 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
def add_location_constraint( session, resource, node, score, force=false, autocorrect=true ) if node == "" return "Bad node" end if score == "" nodescore = node else nodescore = node + "=" + score end cmd = [PCS, "constraint", "location", resource, "prefers", nodescore] cmd << '--force' if force cmd << '--autocorrect' if autocorrect stdout, stderr, retval = run_cmd(session, *cmd) return retval, stderr.join(' ') end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def self.destroy_by_user(user_id, add_con=nil) SqlHelper.validate_token([user_id]) con = "user_id=#{user_id}" con << " and (#{add_con})" unless add_con.nil? or add_con.empty? emails = Email.where(con).to_a emails.each do |email| email.destroy end end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
def select_official_titles Log.add_info(request, params.inspect) @user = User.find(params[:user_id]) unless params[:thetisBoxSelKeeper].nil? @group_id = params[:thetisBoxSelKeeper].split(':').last end SqlHelper.validate_token([@group_id]) if @group_id.nil? @official_titles = OfficialTitle.get_for('0', false, true) else @official_titles = OfficialTitle.get_for(@group_id, false, true) end render(:partial => 'select_official_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
def setup FactoryGirl.create(:host) end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
it "raises no exception" do lambda do cluster.sync_server server end.should_not raise_exception end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def secondaries servers.select(&:secondary?) end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it "creates a new cursor" do cursor = mock(Moped::Cursor, next: nil) Moped::Cursor.should_receive(:new). with(session, query.operation).and_return(cursor) query.each end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it "fetches more" do users.insert(102.times.map { Hash["scope" => scope] }) stats = Support::Stats.collect do users.find(scope: scope).entries end stats[node_for_reads].grep(Moped::Protocol::GetMore).count.should eq 1 end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "approves pending record" do reviewable = ReviewableUser.needs_review!(target: Fabricate(:user, email: invite.email), created_by: invite.invited_by) reviewable.status = Reviewable.statuses[:pending] reviewable.save! invite_redeemer.redeem reviewable.reload expect(reviewable.status).to eq(Reviewable.statuses[:approved]) 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
it "should escape the return path address" do Mail.defaults do delivery_method :exim end mail = Mail.new do to '[email protected]' from '"from+suffix test"@test.lindsaar.net' 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 "\"from+suffix test\"@test.lindsaar.net"', '[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
it "drops the index that matches the key" do indexes[name: 1].should be_nil end
0
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
def __bson_load__(io) new io.read(12).unpack('C*') end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it "should choose :rest when the Settings name isn't 'puppet'" do @request.stubs(:protocol).returns "puppet" # We have to stub this because we can't set name Puppet.settings.stubs(:value).with(:name).returns "foo" @object.select(@request).should == :rest end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
it "returns the same hash" do Moped::BSON::ObjectId.new(bytes).hash.should eq Moped::BSON::ObjectId.new(bytes).hash end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
it "parses yaml" do YAML.should_receive(:load).with('body') subject.send(:yaml) end
0
Ruby
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
vulnerable
it "should fail when a protocol other than :puppet or :file is used" do @request.stubs(:protocol).returns "http" proc { @object.select_terminus(@request) }.should raise_error(ArgumentError) end
0
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
vulnerable
def replica_set_database ENV["MONGOHQ_REPL_NAME"] end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "respects #skip" do users.find(scope: scope).skip(1).one.should eq documents.last end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def rename Log.add_info(request, params.inspect) @mail_folder = MailFolder.find(params[:id]) unless params[:thetisBoxEdit].nil? or params[:thetisBoxEdit].empty? @mail_folder.name = params[:thetisBoxEdit] @mail_folder.save end render(:partial => 'ajax_folder_name', :layout => false) 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 rename Log.add_info(request, params.inspect) return unless request.post? @group = Group.find(params[:id]) unless params[:thetisBoxEdit].blank? @group.rename(params[:thetisBoxEdit]) end render(:partial => 'ajax_group_name', :layout => false) rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_group_name', :layout => false) end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def team_organize Log.add_info(request, params.inspect) team_id = params[:team_id] unless team_id.blank? begin @team = Team.find(team_id) rescue @team = nil ensure if @team.nil? flash[:notice] = t('msg.already_deleted', :name => Team.model_name.human) return end end users = @team.get_users_a end team_members = params[:team_members] created = false modified = false if team_members.nil? or team_members.empty? unless team_id.blank? # @team must not be nil. @team.save if modified = @team.clear_users end else if team_members != users if team_id.blank? item = Item.find(params[:id]) created = true @team = Team.new @team.name = item.title @team.item_id = params[:id] @team.status = Team::STATUS_STANDBY else @team.clear_users end @team.add_users team_members @team.save @team.remove_application team_members modified = true end end if created @team.create_team_folder end @item = @team.item if modified flash[:notice] = t('msg.register_success') end render(:partial => 'ajax_team_info', :layout => false) rescue => evar Log.add_error(request, evar) render(:partial => 'ajax_team_info', :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 update load_object if @user.update(user_params) if params[:user][:password].present? # this logic needed b/c devise wants to log us out after password changes Spree.user_class.reset_password_by_token(params[:user]) if Spree::Auth::Config[:signout_after_password_change] sign_in(@user, event: :authentication) else bypass_sign_in(@user) end end redirect_to spree.account_path, notice: Spree.t(:account_updated) else render :edit end end
1
Ruby
CWE-352
Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
https://cwe.mitre.org/data/definitions/352.html
safe
def install! Moped::Node.class_eval <<-EOS alias _logging logging def logging(operations, &block) Support::Stats.record(self, operations) _logging(operations, &block) end EOS end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def get_workflows Log.add_info(request, params.inspect) @group_id = (params[:id] || '0') # '0' for ROOT SqlHelper.validate_token([@group_id]) ary = TemplatesHelper.get_tmpl_folder unless ary.nil? or ary.empty? @tmpl_workflows_folder = ary[2] end session[:group_id] = params[:id] session[:group_option] = 'workflow' render(:partial => 'ajax_workflows', :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.get_for_group(group_id) SqlHelper.validate_token([group_id]) if group_id.nil? con = 'group_id is null' else con = "group_id=#{group_id.to_i}" end Location.do_expire(con) return Location.where(con).to_a end
1
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
safe
def update(database, collection, selector, change, options = {}) with_node do |node| if safe? node.pipeline do node.update(database, collection, selector, change, options) node.command("admin", { getlasterror: 1 }.merge(safety)) end else node.update(database, collection, selector, change, options) 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 insert(database, collection, documents) process Protocol::Insert.new(database, collection, documents) end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
def get_pacemaker_version() begin stdout, stderror, retval = run_cmd( PCSAuth.getSuperuserSession, PACEMAKERD, "-$" ) rescue stdout = [] end if retval == 0 match = /(\d+)\.(\d+)\.(\d+)/.match(stdout.join()) if match return match[1..3].collect { | x | x.to_i } end end return nil end
0
Ruby
CWE-384
Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
https://cwe.mitre.org/data/definitions/384.html
vulnerable
def add_to_group Log.add_info(request, params.inspect) if params[:thetisBoxSelKeeper].nil? or params[:thetisBoxSelKeeper].empty? render(:partial => 'ajax_groups', :layout => false) return end group_id = params[:thetisBoxSelKeeper].split(':').last unless group_id == '0' # '0' for ROOT begin group = Group.find(group_id) rescue => evar Log.add_error(request, evar) ensure if group.nil? render(:partial => 'ajax_groups', :layout => false) return end end end begin @user = User.find(params[:user_id]) rescue => evar Log.add_error(request, evar) end unless @user.nil? is_modified = false # Change, not simply Add unless params[:current_id] == nil or params[:current_id].empty? if @user.exclude_from(params[:current_id]) is_modified = true end end is_modified = true if @user.add_to(group_id) if is_modified == true # @user.update_attribute(:groups, @user.groups) @user.save! if @user.id == @login_user.id @login_user = @user end end end render(:partial => 'ajax_groups', :layout => false) end
0
Ruby
CWE-89
Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/89.html
vulnerable
it "should get a 200 with html for an authorized user" do def @bus.is_admin_lookup proc { |_| true } end get "/message-bus/_diagnostics" last_response.status.must_equal 200 end
0
Ruby
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
https://cwe.mitre.org/data/definitions/22.html
vulnerable
it "stores the list of seeds" do cluster.seeds.should eq ["127.0.0.1:27017", "127.0.0.1:27018"] end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def do_project_release( params ) User.current ||= User.find_by_login(params[:user]) check_write_access! packages.each do |pkg| pkg.project.repositories.each do |repo| next if params[:repository] and params[:repository] != repo.name repo.release_targets.each do |releasetarget| # release source and binaries release_package(pkg, releasetarget.target_repository.project.name, pkg.name, repo) end 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 get_users if params[:action] == 'get_users' Log.add_info(request, params.inspect) end @group_id = params[:id] =begin # @users = Group.get_users(params[:id]) =end # FEATURE_PAGING_IN_TREE >>> con = ['User.id > 0'] unless @group_id.nil? if @group_id == '0' con << "((groups like '%|0|%') or (groups is null))" else con << SqlHelper.get_sql_like([:groups], "|#{@group_id}|") end end unless params[:keyword].blank? key_array = params[:keyword].split(nil) key_array.each do |key| con << SqlHelper.get_sql_like([:name, :email, :fullname, :address, :organization, :tel1, :tel2, :tel3, :fax, :url, :postalcode, :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 != 'name' order_by << ', 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) # FEATURE_PAGING_IN_TREE <<< session[:group_id] = @group_id session[:group_option] = 'user' render(:partial => 'ajax_group_users', :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 ==(other) resolved_address == other.resolved_address end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
it 'fails when local logins is disabled' do SiteSetting.enable_local_logins = false get "/session/email-login/#{email_token.token}" expect(response.status).to eq(500) end
0
Ruby
NVD-CWE-noinfo
null
null
null
vulnerable
def test_edit get :edit, {:id => hostgroups(:common)}, set_session_user assert_template 'edit' end
1
Ruby
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
def resource_form(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end cib_dom = get_cib_dom(session) @cur_resource = get_resource_by_id(params[:resource], cib_dom) @groups = get_resource_groups(cib_dom) @version = params[:version] if @cur_resource.instance_of?(ClusterEntity::Primitive) and !@cur_resource.stonith @cur_resource_group = @cur_resource.get_group @cur_resource_clone = @cur_resource.get_clone @cur_resource_ms = @cur_resource.get_master @resource = ResourceAgent.new(@cur_resource.agentname) if @cur_resource.provider == 'heartbeat' @resource.required_options, @resource.optional_options, @resource.info = getResourceMetadata(session, HEARTBEAT_AGENTS_DIR + @cur_resource.type) elsif @cur_resource.provider == 'pacemaker' @resource.required_options, @resource.optional_options, @resource.info = getResourceMetadata(session, PACEMAKER_AGENTS_DIR + @cur_resource.type) elsif @cur_resource._class == 'nagios' @resource.required_options, @resource.optional_options, @resource.info = getResourceMetadata(session, NAGIOS_METADATA_DIR + @cur_resource.type + '.xml') end @existing_resource = true if @resource erb :resourceagentform else "Can't find resource" end else "Resource #{params[:resource]} doesn't exist" 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 auth(params, request, session) token = PCSAuth.validUser(params['username'],params['password'], true) # If we authorized to this machine, attempt to authorize everywhere node_list = [] if token and params["bidirectional"] params.each { |k,v| if k.start_with?("node-") node_list.push(v) end } if node_list.length > 0 pcs_auth( session, node_list, params['username'], params['password'], params["force"] == "1" ) end end return token 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 auth_node_configured? ENV["MONGOHQ_SINGLE_PASS"] end
1
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
safe
it "returns a session with the provided options" do safe = session.with(safe: true) safe.options[:safe].should eq true end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe
def test_crlf_injection smtp = Net::SMTP.new 'localhost', 25 smtp.instance_variable_set :@socket, FakeSocket.new assert_raise(ArgumentError) do smtp.mailfrom("foo\r\nbar") end assert_raise(ArgumentError) do smtp.mailfrom("foo\rbar") end assert_raise(ArgumentError) do smtp.mailfrom("foo\nbar") end assert_raise(ArgumentError) do smtp.rcptto("foo\r\nbar") end end
1
Ruby
CWE-93
Improper Neutralization of CRLF Sequences ('CRLF Injection')
The software uses CRLF (carriage return line feeds) as a special element, e.g. to separate lines or records, but it does not neutralize or incorrectly neutralizes CRLF sequences from inputs.
https://cwe.mitre.org/data/definitions/93.html
safe
def ajax_move_mails Log.add_info(request, params.inspect) folder_id = params[:thetisBoxSelKeeper].split(':').last mail_folder = MailFolder.find_by_id(folder_id) if folder_id == '0' \ or mail_folder.nil? \ or mail_folder.user_id != @login_user.id flash[:notice] = 'ERROR:' + t('msg.cannot_save_in_folder') get_mails return end unless params[:check_mail].blank? count = 0 params[:check_mail].each do |email_id, value| if value == '1' begin email = Email.find(email_id) next if email.user_id != @login_user.id email.update_attribute(:mail_folder_id, folder_id) rescue => evar Log.add_error(request, evar) end count += 1 end end flash[:notice] = t('mail.moved', :count => count) end get_mails 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 "adds the server to the list" do cluster.sync_server server cluster.servers.should include server end
0
Ruby
CWE-20
Improper Input Validation
The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
def private_messages_for(user, type) options = @options options.reverse_merge!(per_page: per_page_setting) result = Topic.includes(:allowed_users) result = result.includes(:tags) if SiteSetting.tagging_enabled if type == :group result = result.joins( "INNER JOIN topic_allowed_groups tag ON tag.topic_id = topics.id AND tag.group_id IN (SELECT id FROM groups WHERE LOWER(name) = '#{PG::Connection.escape_string(@options[:group_name].downcase)}')" ) unless user.admin? result = result.joins("INNER JOIN group_users gu ON gu.group_id = tag.group_id AND gu.user_id = #{user.id.to_i}") end elsif type == :user result = result.where("topics.id IN (SELECT topic_id FROM topic_allowed_users WHERE user_id = #{user.id.to_i})") elsif type == :all group_ids = group_with_messages_ids(user) result = result.joins(<<~SQL) LEFT JOIN topic_allowed_users tau ON tau.topic_id = topics.id AND tau.user_id = #{user.id.to_i} LEFT JOIN topic_allowed_groups tag ON tag.topic_id = topics.id #{group_ids.present? ? "AND tag.group_id IN (#{group_ids.join(",")})" : ""} SQL result = result .where("tag.topic_id IS NOT NULL OR tau.topic_id IS NOT NULL") .distinct end result = result.joins("LEFT OUTER JOIN topic_users AS tu ON (topics.id = tu.topic_id AND tu.user_id = #{user.id.to_i})") .order("topics.bumped_at DESC") .private_messages result = result.limit(options[:per_page]) unless options[:limit] == false result = result.visible if options[:visible] || @user.nil? || @user.regular? if options[:page] offset = options[:page].to_i * options[:per_page] result = result.offset(offset) if offset > 0 end result 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 ajax_move_users Log.add_info(request, params.inspect) return unless request.post? org_group_id = params[:id] group_id = params[:thetisBoxSelKeeper].split(':').last SqlHelper.validate_token([org_group_id, group_id]) unless params[:check_user].blank? count = 0 params[:check_user].each do |user_id, value| if value == '1' begin user = User.find(user_id) user.exclude_from(org_group_id) user.add_to(group_id) user.save! rescue => evar user = nil Log.add_error(request, evar) end count += 1 end end flash[:notice] = t('msg.move_success') end get_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 remote_add_node(params, request, session, all=false) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end auto_start = false if params[:auto_start] and params[:auto_start] == "1" auto_start = true end if params[:new_nodename] != nil node = params[:new_nodename] if params[:new_ring1addr] != nil node += ',' + params[:new_ring1addr] end retval, output = add_node(session, node, all, auto_start) end if retval == 0 return [200, JSON.generate([retval, get_corosync_conf()])] end return [400,output] 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 assemble_params(sanitized_params) sanitized_params.collect do |pair| pair_joiner = pair.first.to_s.end_with?("=") ? "" : " " pair.flatten.compact.join(pair_joiner) end.join(" ") end
0
Ruby
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
https://cwe.mitre.org/data/definitions/78.html
vulnerable
def ffi_lib(*names) raise LoadError.new("library names list must not be empty") if names.empty? lib_flags = defined?(@ffi_lib_flags) ? @ffi_lib_flags : FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL ffi_libs = names.map do |name| if name == FFI::CURRENT_PROCESS FFI::DynamicLibrary.open(nil, FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_LOCAL) else libnames = (name.is_a?(::Array) ? name : [ name ]).map { |n| [ n, FFI.map_library_name(n) ].uniq }.flatten.compact lib = nil errors = {} libnames.each do |libname| begin orig = libname lib = FFI::DynamicLibrary.open(libname, lib_flags) break if lib rescue Exception => ex ldscript = false if ex.message =~ /(([^ \t()])+\.so([^ \t:()])*):([ \t])*(invalid ELF header|file too short|invalid file format)/ if File.read($1) =~ /(?:GROUP|INPUT) *\( *([^ \)]+)/ libname = $1 ldscript = true end end if ldscript retry else # TODO better library lookup logic libname = libname.to_s unless libname.start_with?("/") path = ['/usr/lib/','/usr/local/lib/'].find do |pth| File.exist?(pth + libname) end if path libname = path + libname retry end end libr = (orig == libname ? orig : "#{orig} #{libname}") errors[libr] = ex end end end if lib.nil? raise LoadError.new(errors.values.join(".\n")) end # return the found lib lib end end @ffi_libs = ffi_libs end
0
Ruby
CWE-426
Untrusted Search Path
The application searches for critical resources using an externally-supplied search path that can point to resources that are not under the application's direct control.
https://cwe.mitre.org/data/definitions/426.html
vulnerable
def load_file(filename) Gem.load_yaml yaml_errors = [ArgumentError] yaml_errors << Psych::SyntaxError if defined?(Psych::SyntaxError) return {} unless filename and File.exist? filename begin content = YAML.load(File.read(filename)) unless content.kind_of? Hash warn "Failed to load #{filename} because it doesn't contain valid YAML hash" return {} end return content rescue *yaml_errors => e warn "Failed to load #{filename}, #{e}" rescue Errno::EACCES warn "Failed to load #{filename} due to permissions problem." end {} 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 resource_ungroup(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end unless params[:group_id] return [400, 'group_id has to be specified.'] end _, stderr, retval = run_cmd( session, PCS, 'resource', 'ungroup', params[:group_id] ) if retval != 0 return [400, 'Unable to ungroup group ' + "'#{params[:group_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
def ==(other) @host == other.host && @port == other.port end
1
Ruby
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
safe