code stringlengths 12 2.05k | label int64 0 1 | programming_language stringclasses 9
values | cwe_id stringlengths 6 14 | cwe_name stringlengths 5 103 ⌀ | description stringlengths 36 1.23k ⌀ | url stringlengths 36 48 ⌀ | label_name stringclasses 2
values |
|---|---|---|---|---|---|---|---|
def create_workflow
Log.add_info(request, params.inspect)
return unless request.post?
@tmpl_folder, @tmpl_workflows_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_WORKFLOWS)
@group_id = params[:group_id]
SqlHelper.validate_token([@group_id])
if @group_id.blank?
@gr... | 1 | Ruby | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
def upload
Log.add_info(request, '') # Not to show passwords.
return unless request.post?
if params[:file].nil? or params[:file].size <= 0
render(:text => '')
return
end
post_item = ZeptairPostHelper.get_item_for(@login_user)
Attachment.create(params, post_item, 0)
post_... | 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_login_with_suburi_should_not_redirect_to_another_suburi
@relative_url_root = Redmine::Utils.relative_url_root
Redmine::Utils.relative_url_root = '/redmine'
back_urls = [
'http://test.host/',
'http://test.host/fake',
'http://test.host/fake/issues',
'http://test.host/redmin... | 1 | Ruby | NVD-CWE-Other | Other | NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset. | https://nvd.nist.gov/vuln/categories | safe |
it 'should authenticate user and delete token' do
user = Fabricate(:user)
get "/session/current.json"
expect(response.status).to eq(404)
token = SecureRandom.hex
$redis.setex "otp_#{token}", 10.minutes, user.username
get "/session/otp/#{token}"
... | 0 | Ruby | NVD-CWE-noinfo | null | null | null | vulnerable |
def rd.length
1024 * 1024 * 8
end | 1 | Ruby | CWE-119 | Improper Restriction of Operations within the Bounds of a Memory Buffer | The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer. | https://cwe.mitre.org/data/definitions/119.html | safe |
def generation_time
Time.at(data.unpack("N")[0]).utc
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 format_object(object, html=true, &block)
if block_given?
object = yield object
end
case object.class.name
when 'Array'
formatted_objects = object.map {|o| format_object(o, html)}
html ? safe_join(formatted_objects, ', ') : formatted_objects.join(', ')
when 'Time'
format... | 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 self.get_sql_like(attr_names, keyword)
key = SqlHelper.quote("%#{SqlHelper.escape_for_like(keyword)}%")
con = []
attr_names.each do |attr_name|
con << "(#{attr_name} like #{key})"
end
sql = con.join(' or ')
sql = '(' + sql + ')' if con.length > 1
return sql
end | 1 | Ruby | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
it "should return HTTP_X_FORWARDED_FOR as remote_address" do
@connection.request.env['HTTP_X_FORWARDED_FOR'] = '1.2.3.4'
@connection.remote_address.should == '1.2.3.4'
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 mget(*keys)
options = (keys.pop if keys.last.is_a? Hash) || {}
if keys.any?
# Marshalling gets extended before Namespace does, so we need to pass options further
if singleton_class.ancestors.include? Marshalling
super(*keys.map {|key| interpolate(key) }, options... | 0 | Ruby | CWE-502 | Deserialization of Untrusted Data | The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid. | https://cwe.mitre.org/data/definitions/502.html | vulnerable |
it "returns the first matching document" do
users.find(scope: scope).one.should eq documents.first
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 initiate
primary, *secondaries = @nodes.shuffle
primary.promote
secondaries.each &:demote
return primary, secondaries
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 initialize(file, name, content_type)
@file = file
@name = name
@content_type = content_type || ""
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 scope_allowed_tags(tags)
Rails::Html::WhiteListSanitizer.allowed_tags = tags
yield Rails::Html::WhiteListSanitizer.new
ensure
Rails::Html::WhiteListSanitizer.allowed_tags = nil
end | 0 | Ruby | CWE-79 | Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') | The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. | https://cwe.mitre.org/data/definitions/79.html | vulnerable |
it "changes the current database" do
session.use "moped_test_2"
session.command(dbStats: 1)["db"].should eq "moped_test_2"
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 resource_metadata(params, request, session)
if not allowed_for_local_cluster(session, Permissions::READ)
return 403, 'Permission denied'
end
return 200 if not params[:resourcename] or params[:resourcename] == ""
resource_name = params[:resourcename][params[:resourcename].rindex(':')+1..-1]
class_provi... | 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 entries(path=nil, identifier=nil, options={})
p1 = scm_iconv(@path_encoding, 'UTF-8', path)
manifest = hg('rhmanifest', '-r', CGI.escape(hgrev(identifier)),
CGI.escape(without_leading_slash(p1.to_s))) do |io|
output = io.read.force_encoding('UTF-8')
... | 0 | Ruby | NVD-CWE-noinfo | null | null | null | vulnerable |
def show_article
auto_discovery_feed
respond_to do |format|
format.html do
@comment = Comment.new
@page_title = this_blog.article_title_template.to_title(@article, this_blog, params)
@description = this_blog.article_desc_template.to_title(@article, this_blog, params)
@ke... | 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 unstage user" do
staged_user = Fabricate(:staged, email: 'staged@account.com', active: true, username: 'staged1', name: 'Stage Name')
invite = Fabricate(:invite, email: 'staged@account.com')
user = InviteRedeemer.create_user_from_invite(invite: invite, email: invite.email, username: 'wa... | 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 remove(server)
servers.delete(server)
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 data
@data ||= @@generator.next
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.exists_copies_folder?(user_id)
my_folder = User.get_my_folder(user_id)
unless my_folder.nil?
con = "(parent_id=#{my_folder.id}) and (name='#{Item.copies_folder}')"
begin
copies_folder = Folder.where(con).first
rescue
end
end
return !copies_folder.nil?
end | 0 | Ruby | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | vulnerable |
it "returns the index with the provided key" do
indexes[name: 1]["name"].should eq "name_1"
end | 0 | Ruby | CWE-400 | Uncontrolled Resource Consumption | The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | vulnerable |
def add_meta_attr(session, resource, key, value)
stdout, stderr, retval = run_cmd(
session, PCS, "resource", "meta", resource, key.to_s + "=" + value.to_s
)
return retval
end | 0 | Ruby | CWE-384 | Session Fixation | Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions. | https://cwe.mitre.org/data/definitions/384.html | vulnerable |
def destroy
Log.add_info(request, params.inspect)
return unless request.post?
begin
team = Team.find(params[:id])
Item.destroy(team.item_id)
rescue => evar
Log.add_error(request, evar)
end
list
flash[:notice] = t('msg.delete_success')
render(:action => 'list')
en... | 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 promote
@primary = true
@secondary = false
hiccup
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 "does not activate user invited via links" do
invite = Fabricate(:invite, email: 'walter.white@email.com', emailed_status: Invite.emailed_status_types[:not_required])
user = InviteRedeemer.create_user_from_invite(invite: invite, email: invite.email, username: 'walter', name: 'Walter White')
ex... | 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 calculated_content_type
@calculated_content_type ||= type_from_file_command.chomp
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 auth
@auth ||= {}
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 "closes open cursors" do
users.insert(100.times.map { Hash["scope" => scope] })
stats = Support::Stats.collect do
users.find(scope: scope).limit(5).entries
end
stats[node_for_reads].grep(Moped::Protocol::KillCursors).count.should eq 1
end | 1 | Ruby | CWE-400 | Uncontrolled Resource Consumption | The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
it "sanitizes Pathname param key" do
cl = subject.build("true", Pathname.new("/usr/bin/ruby") => nil)
expect(cl).to eq "true /usr/bin/ruby"
end | 1 | Ruby | CWE-78 | Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') | The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/78.html | safe |
def do_send
Log.add_info(request, params.inspect)
return unless request.post?
begin
email = Email.find(params[:id])
if email.status != Email::STATUS_DRAFT
# Ignore clicked Send button twice or more at once.
raise('ERROR:' + 'Specified E-mail is not a draft.')
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 to_json(options = nil)
[name].to_json
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 authenticate!
unless Setting['oauth_active']
Rails.logger.warn 'Trying to authenticate with OAuth, but OAuth is not active'
return nil
end
unless (incoming_key = OAuth::RequestProxy.proxy(request).oauth_consumer_key) == Setting['oauth_consumer_key']
Rails.logger.warn "... | 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 set_workflow
Log.add_info(request, params.inspect)
return unless request.post?
@item = Item.find(params[:id])
orders_hash = params.dup
orders_hash.reject! { |key, value|
key.index(/order-/) != 0
}
orders_hash.sort_by { |key, value|
key.split('-').last.to_i
}
ord... | 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.search_by_host(key, operator, value)
conditions = "hosts.name #{operator} '#{value_to_sql(operator, value)}'"
direct = Puppetclass.all(:conditions => conditions, :joins => :hosts, :select => 'puppetclasses.id').map(&:id).uniq
hostgroup = Hostgroup.joins(:hosts).where(conditions).first
in... | 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 "yields the new session" do
session.stub(with: new_session)
session.new(new_options) do |session|
session.should eql new_session
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 nodes
# Find the nodes that were down but are ready to be refreshed, or those
# with stale connection information.
needs_refresh, available = @nodes.partition do |node|
(node.down? && node.down_at < (Time.new - @options[:down_interval])) ||
node.needs_refresh?(Time.new - @opt... | 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 destroy
return unless request.post?
if params[:check_log].nil?
list
render(:action => 'list')
return
end
count = 0
params[:check_log].each do |key, value|
if value == '1'
Log.delete(key)
count += 1
end
end
list
flash[:notice] = coun... | 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 "reconnects without raising an exception" 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 get_sw_versions(params, request, session)
versions = {
"rhel" => get_rhel_version(),
"pcs" => get_pcsd_version(),
"pacemaker" => get_pacemaker_version(),
"corosync" => get_corosync_version(),
"cman" => get_cman_version(),
}
return JSON.generate(versions)
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 show
Log.add_info(request, params.inspect)
@group_id = params[:group_id]
official_title_id = params[:id]
SqlHelper.validate_token([@group_id, official_title_id])
unless official_title_id.blank?
@official_title = OfficialTitle.find(official_title_id)
end
render(:layout => (!req... | 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 reconnect
@servers = servers.map { |server| Server.new(server.address) }
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 logout
session.context.logout(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 |
def update_order
Log.add_info(request, params.inspect)
mail_account_id = params[:mail_account_id]
order_arr = params[:mail_filters_order]
SqlHelper.validate_token([mail_account_id])
@mail_account = MailAccount.find(mail_account_id)
if @mail_account.user_id != @login_user.id
render(:t... | 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_update_invalid
Subnet.any_instance.stubs(:valid?).returns(false)
put :update, {:id => Subnet.first, :subnet => {:network => nil}}, set_session_user
assert_template 'edit'
end | 0 | Ruby | CWE-200 | Exposure of Sensitive Information to an Unauthorized Actor | The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information. | https://cwe.mitre.org/data/definitions/200.html | vulnerable |
def with_taxonomy_scope(loc = Location.current, org = Organization.current, inner_method = :subtree_ids)
self.which_ancestry_method = inner_method
self.which_location = Location.expand(loc) if SETTINGS[:locations_enabled]
self.which_organization = Organization.expand(org) if SETTINGS[:or... | 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 write_key_to_disk(key, identity)
# Writing is disabled. Don't bother checking any other states.
return unless lookup_config_option('learn_public_keys') =~ /^1|y/
publickey_dir = lookup_config_option('publickey_dir')
unless publickey_dir
Log.info("Public key sent wi... | 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 check_action_permission!(skip_source = nil)
super(skip_source)
# only perform the following check, if we are called from
# BsRequest.permission_check_change_state! (that is, if
# skip_source is set to true). Always executing this check
# would be a regression, because this code is also execute... | 1 | Ruby | CWE-862 | Missing Authorization | The software does not perform an authorization check when an actor attempts to access a resource or perform an action. | https://cwe.mitre.org/data/definitions/862.html | safe |
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-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 remove
delete = Protocol::Delete.new(
operation.database,
operation.collection,
operation.selector,
flags: [:remove_first]
)
session.with(consistency: :strong) do |session|
session.execute delete
end
end | 0 | Ruby | CWE-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 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)
... | 0 | Ruby | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | vulnerable |
it "returns the living socket" do
cluster.socket_for(:write).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_fence_levels(session, cib_dom=nil)
unless cib_dom
cib_dom = get_cib_dom(session)
return {} unless cib_dom
end
fence_levels = {}
cib_dom.elements.each(
'/cib/configuration/fencing-topology/fencing-level'
) { |e|
target = e.attributes['target']
fence_levels[target] ||= []
fence_... | 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 each
cursor = Cursor.new(session.with(retain_socket: true), operation)
cursor.to_enum.tap do |enum|
enum.each do |document|
yield document
end if block_given?
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 pipeline
Threaded.begin :pipeline
begin
yield
ensure
Threaded.end :pipeline
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.dump(object)
MultiJson.dump object,
mode: :compat, escape_mode: :xss_safe, time_format: :ruby
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 to_io
@server
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 logging(operations)
instrument_start = (logger = Moped.logger) && logger.debug? && Time.new
yield
ensure
log_operations(logger, operations, Time.new - instrument_start) if instrument_start && !$!
end | 1 | Ruby | CWE-400 | Uncontrolled Resource Consumption | The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
def read_lines(filename, selector)
if selector
IO.foreach(filename).select.with_index(1, &selector)
else
URI.open(filename, &:read)
end
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 save_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
new_tokens = {}
params.each{|nodes|
if nodes[0].start_with?"node:" and nodes[0].length > 5
node ... | 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 remove_acl_usergroup(session, role_id, usergroup_id)
stdout, stderror, retval = run_cmd(
session, PCS, "acl", "role", "unassign", role_id.to_s, usergroup_id.to_s,
"--autodelete"
)
if retval != 0
if stderror.empty?
return "Error removing user / group"
else
return stderror.join("\n")... | 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 authenticate(*credentials, &block)
raise ArgumentError, 'at least 2 arguments required' if credentials.size < 2
if credentials[0].blank?
return authentication_response(return_value: false, failure: :invalid_login, &block)
end
if @sorcery_config.downcase_username_bef... | 0 | Ruby | CWE-307 | Improper Restriction of Excessive Authentication Attempts | The software does not implement sufficient measures to prevent multiple failed authentication attempts within in a short time frame, making it more susceptible to brute force attacks. | https://cwe.mitre.org/data/definitions/307.html | vulnerable |
def start
Log.add_info(request, params.inspect)
return unless request.post?
tmpl_folder, tmpl_q_folder = TemplatesHelper.get_tmpl_subfolder(TemplatesHelper::TMPL_RESEARCH)
if tmpl_q_folder.nil?
ary = TemplatesHelper.setup_tmpl_folder
tmpl_q_folder = ary[4]
end
items = Folder.ge... | 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_attachment_info
Log.add_info(request, params.inspect)
return unless request.post?
attachment = Attachment.find(params[:attachment_id])
# Getting Item at first for the case of resetting the db connection by an error.
@item = Item.find(attachment.item_id)
unless @item.check_user_a... | 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 set_member_and_redirect(member)
set_member member
Member::ActivityLog.create(
cur_site: @cur_site,
cur_member: member,
activity_type: "login",
remote_addr: remote_addr,
user_agent: request.user_agent)
ref = URI::decode(params[:ref] || flash[:ref] || "")
ref = redirec... | 0 | Ruby | CWE-601 | URL Redirection to Untrusted Site ('Open Redirect') | A web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a Redirect. This simplifies phishing attacks. | https://cwe.mitre.org/data/definitions/601.html | vulnerable |
it "stores the options provided" do
session.options.should eq(options)
end | 0 | Ruby | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
def set_corosync_conf(params, request, session)
if not allowed_for_local_cluster(session, Permissions::FULL)
return 403, 'Permission denied'
end
if params[:corosync_conf] != nil and params[:corosync_conf].strip != ""
Cfgsync::CorosyncConf.backup()
Cfgsync::CorosyncConf.from_text(params[:corosync_conf]... | 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 "stores the database" do
collection.database.should eq database
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_data(data)
id = allocate
id.instance_variable_set :@data, data
id
end | 1 | Ruby | CWE-400 | Uncontrolled Resource Consumption | The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources. | https://cwe.mitre.org/data/definitions/400.html | safe |
def update_config
Log.add_info(request, params.inspect)
@yaml = ApplicationHelper.get_config_yaml
unless params[:desktop].nil? or params[:desktop].empty?
@yaml[:desktop] = Hash.new if @yaml[:desktop].nil?
params[:desktop].each do |key, val|
@yaml[:desktop][key] = val
end
... | 0 | Ruby | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | vulnerable |
def get_wizard(params, request, session)
if not allowed_for_local_cluster(session, Permissions::READ)
return 403, 'Permission denied'
end
wizard = PCSDWizard.getWizard(params["wizard"])
if wizard != nil
return erb wizard.collection_page
else
return "Error finding Wizard - #{params["wizard"]}"
en... | 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 all other known hosts" do
cluster.sync_server(server).should =~ ["localhost:61085", "localhost:61086", "localhost:61084"]
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_account_roots_for(user)
return nil if user.nil?
if user.kind_of?(User)
user_id = user.id
else
user_id = user.to_s
end
SqlHelper.validate_token([user_id])
con = []
con << "(user_id=#{user_id})"
con << "(xtype='#{MailFolder::XTYPE_ACCOUNT_ROOT}')"
order_... | 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?
@cursor_id != 0
end | 1 | Ruby | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | safe |
it "removes the first matching document" do
session.should_receive(:with, :consistency => :strong).
and_yield(session)
session.should_receive(:execute).with do |delete|
delete.flags.should eq [:remove_first]
delete.selector.should eq query.operation.selector
end
que... | 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 "should warn when matching against IP addresses" do
add_rule("allow 10.1.1.1")
@auth.should allow(request)
@logs.should be_any {|log| log.level == :warning and log.message =~ /Authentication based on IP address is deprecated/}
end | 1 | 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 | safe |
it "should not display completed tasks" do
task_1 = FactoryGirl.create(:task, :user_id => current_user.id, :name => "Your first task", :bucket => "due_asap", :assigned_to => current_user.id)
task_2 = FactoryGirl.create(:task, :user_id => current_user.id, :name => "Completed task", :bucket => "due_asap",... | 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_q_ctrl
Log.add_info(request, params.inspect)
return unless request.post?
Research.trim_config_yaml nil
settings
render(:partial => 'ajax_q_ctrls')
rescue => evar
Log.add_error(request, evar)
render(:partial => 'ajax_q_ctrls')
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 users
Log.add_info(request, params.inspect)
con = []
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], key)
end
end
@group_id = nil
... | 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 supplied_type_mismatch?
supplied_media_type.present? && !media_types_from_name.include?(supplied_media_type)
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 next(time = nil)
@mutex.lock
begin
count = @counter = (@counter + 1) % 0xFFFFFF
ensure
@mutex.unlock rescue nil
end
generate(time || ::Time.new.to_i, count)
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 crop_command
target = @attachment.instance
if target.cropping?(@attachment.name)
begin
w = Integer(target.send :"#{@attachment.name}_crop_w")
h = Integer(target.send :"#{@attachment.name}_crop_h")
x = Integer(target.send :"#{@attachment.name}_crop_x")
... | 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 filename_extension
File.extname(@name.to_s.downcase).sub(/^\./, '').to_sym
end | 0 | Ruby | CWE-79 | Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') | The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. | https://cwe.mitre.org/data/definitions/79.html | vulnerable |
it "sanitizes Pathname param key" do
cl = subject.build_command_line("true", Pathname.new("/usr/bin/ruby") => nil)
expect(cl).to eq "true /usr/bin/ruby"
end | 0 | Ruby | CWE-78 | Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') | The software constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/78.html | vulnerable |
it "drops the current database" do
session.with(database: "moped_test_2") do |session|
session.drop.should eq("dropped" => "moped_test_2", "ok" => 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 replica_set_credentials
[ENV["MONGOHQ_REPL_USER"], ENV["MONGOHQ_REPL_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 |
def self.prepare_rdoc root
debug, verbose = false, false
prepare_script = Pathname.new(Rails.root) + "script/rdoc_prepare_script.rb"
if prepare_script.executable?
dirs = Environment.puppetEnvs.values.join(":").split(":").uniq.sort.join(" ")
puts "Running #{prepare_script} #{dirs}" if debug
... | 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 "has an empty list of servers" do
cluster.servers.should be_empty
end | 0 | Ruby | CWE-20 | Improper Input Validation | The product receives input or data, but it does
not validate or incorrectly validates that the input has the
properties that are required to process the data safely and
correctly. | https://cwe.mitre.org/data/definitions/20.html | vulnerable |
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-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 add_constraint_rule_remote(params, request, session)
if not allowed_for_local_cluster(session, Permissions::WRITE)
return 403, 'Permission denied'
end
if params["c_type"] == "loc"
retval, error = add_location_constraint_rule(
session,
params["res_id"], params["rule"], params["score"], para... | 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 generate(time, counter = 0)
[time, @machine_id, Process.pid, counter << 8].pack("N NX lXX NX")
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 load
consistency = session.consistency
@options[:flags] |= [:slave_ok] if consistency == :eventual
reply, @node = session.context.with_node do |node|
[node.query(@database, @collection, @selector, @options), node]
end
@limit -= reply.count if limited?
@cursor_id = r... | 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 sign(*); 'fake_sig'; end | 1 | Ruby | CWE-347 | Improper Verification of Cryptographic Signature | The software does not verify, or incorrectly verifies, the cryptographic signature for data. | https://cwe.mitre.org/data/definitions/347.html | safe |
def update_images_order
Log.add_info(request, params.inspect)
return unless request.post?
order_ary = params[:images_order]
item = Item.find(params[:id])
item.images_without_content.each do |img|
class << img
def record_timestamps; false; end
end
img.update_attribute... | 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 limited?
@query_op.limit > 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 check_owner
return if params[:id].blank? or @login_user.nil?
email = Email.find(params[:id])
if !@login_user.admin?(User::AUTH_MAIL) and email.user_id != @login_user.id
Log.add_check(request, '[check_owner]'+request.to_s)
flash[:notice] = t('msg.need_to_be_owner')
redirect_to(:co... | 1 | Ruby | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
it "should reject a critical extension that isn't on the whitelist" do
@request.stubs(:request_extensions).returns [{ "oid" => "banana",
"value" => "yumm",
"critical" => true }]
expect { @... | 1 | Ruby | CWE-264 | Permissions, Privileges, and Access Controls | Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control. | https://cwe.mitre.org/data/definitions/264.html | safe |
def self.get_tree(folder_tree, conditions, parent, admin)
if parent.instance_of?(Folder)
tree_id = parent.id.to_s
else
tree_id = parent.to_s
parent = nil
if tree_id != '0'
begin
parent = Folder.find(tree_id)
rescue
end
return folder_tree if pa... | 1 | Ruby | CWE-89 | Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') | The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. | https://cwe.mitre.org/data/definitions/89.html | safe |
it "with dofollowify disabled, links should be nofollowed" do
@blog.dofollowify = false
@blog.save
expect(nofollowify_links('<a href="http://myblog.net">my blog</a>')).
to eq('<a href="http://myblog.net" rel="nofollow">my blog</a>')
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.