code
stringlengths 23
2.05k
| label_name
stringlengths 6
7
| label
int64 0
37
|
---|---|---|
def has_cookie?
[email protected]?
end | CWE-200 | 10 |
def drop
command dropDatabase: 1
end | CWE-400 | 2 |
def process_invitation
approve_account_if_needed
add_to_private_topics_if_invited
add_user_to_groups
send_welcome_message
notify_invitee
end | CWE-863 | 11 |
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 | CWE-200 | 10 |
def new(options = {})
session = with(options)
session.cluster.reconnect
if block_given?
yield session
else
session
end
end | CWE-20 | 0 |
it "returns the index with the provided key" do
indexes[name: 1]["name"].should eq "name_1"
end | CWE-400 | 2 |
it "removes the socket" do
cluster.should_receive(:remove).with(dead_server)
cluster.socket_for :write
end | CWE-400 | 2 |
it "only aquires the socket once" do
session.cluster.should_receive(:socket_for).
with(:read).once.and_return(mock(Moped::Socket))
session.send(:socket_for, :read)
session.send(:socket_for, :read)
end | CWE-400 | 2 |
it "returns true" do
session.should be_safe
end | CWE-400 | 2 |
it "adds the credentials to the auth cache" do
cluster.login("admin", "username", "password")
cluster.auth.should eq("admin" => ["username", "password"])
end | CWE-400 | 2 |
it "stores the list of seeds" do
cluster.seeds.should eq ["127.0.0.1:27017", "127.0.0.1:27018"]
end | CWE-400 | 2 |
def access?(query)
return false if record.internal == true && !user.permissions?('ticket.agent')
ticket = Ticket.lookup(id: record.ticket_id)
Pundit.authorize(user, ticket, query)
end | CWE-862 | 8 |
it "returns true" do
session.should be_safe
end | CWE-20 | 0 |
def test_destroy
domain = Domain.first
domain.hosts.clear
domain.hostgroups.clear
domain.subnets.clear
delete :destroy, {:id => domain}, set_session_user
assert_redirected_to domains_url
assert !Domain.exists?(domain.id)
end | CWE-200 | 10 |
it "sets the query operation's limit field" do
query.limit(5)
query.operation.limit.should eq 5
end | CWE-20 | 0 |
def test_should_not_destroy_if_used_by_hosts
subnet = subnets(:one)
delete :destroy, {:id => subnet}, set_session_user
assert_redirected_to subnets_url
assert Subnet.exists?(subnet.id)
end | CWE-200 | 10 |
def self.new_from_xml_hash(hash)
r = Review.new
r.state = hash.delete('state') { raise ArgumentError, 'no state' }
r.state = r.state.to_sym
r.by_user = hash.delete('by_user')
r.by_group = hash.delete('by_group')
r.by_project = hash.delete('by_project')
r.by_package = hash.delete('by_package')
r.reviewer = r.creator = hash.delete('who')
r.reason = hash.delete('comment')
begin
r.created_at = Time.zone.parse(hash.delete('when'))
rescue TypeError
# no valid time -> ignore
end
raise ArgumentError, "too much information #{hash.inspect}" if hash.present?
r
end | CWE-862 | 8 |
it "has an empty list of secondaries" do
cluster.secondaries.should be_empty
end | CWE-400 | 2 |
def insert(documents)
documents = [documents] unless documents.is_a? Array
insert = Protocol::Insert.new(database.name, name, documents)
database.session.with(consistency: :strong) do |session|
session.execute insert
end
end | CWE-400 | 2 |
it "updates to a mongo advanced selector" do
query.explain
query.operation.selector.should eq(
"$query" => selector,
"$explain" => true,
"$orderby" => { _id: 1 }
)
end | CWE-20 | 0 |
def test_update_invalid
put :update, {:id => Hostgroup.first, :hostgroup => { :name => '' }}, set_session_user
assert_template 'edit'
end | CWE-200 | 10 |
def test_update_invalid
Medium.any_instance.stubs(:valid?).returns(false)
put :update, {:id => Medium.first, :medium => {:name => nil}}, set_session_user
assert_template 'edit'
end | CWE-200 | 10 |
it "executes a count command" do
database.should_receive(:command).with(
count: collection.name,
query: selector
).and_return("n" => 4)
query.count
end | CWE-400 | 2 |
it "returns only published articles" do
article = create(:article)
create(:comment, article: article)
unpublished_article = create(:article, state: "draft")
create(:comment, article: unpublished_article)
expect(described_class.published).to eq([article])
expect(described_class.bestof).to eq([article])
end | CWE-863 | 11 |
def initialize
# Generate and cache 3 bytes of identifying information from the current
# machine.
@machine_id = Digest::MD5.digest(Socket.gethostname).unpack("C3")
@mutex = Mutex.new
@last_timestamp = nil
@counter = 0
end | CWE-400 | 2 |
def socket_for(mode)
sync unless primaries.any? || (secondaries.any? && mode == :read)
server = nil
while primaries.any? || (secondaries.any? && mode == :read)
if mode == :write || secondaries.empty?
server = primaries.sample
else
server = secondaries.sample
end
if server
socket = server.socket
socket.connect unless socket.connection
if socket.alive?
break server
else
remove server
end
end
end | CWE-20 | 0 |
def write!(headers)
if @orig_disable_profiling != @disable_profiling || @orig_backtrace_level != @backtrace_level || @cookie.nil?
settings = {"p" => "t" }
settings["dp"] = "t" if @disable_profiling
settings["bt"] = @backtrace_level if @backtrace_level
settings_string = settings.map{|k,v| "#{k}=#{v}"}.join(",")
Rack::Utils.set_cookie_header!(headers, COOKIE_NAME, :value => settings_string, :path => '/')
end
end | CWE-200 | 10 |
it 'returns success' do
get "/session/email-login/#{email_token.token}"
expect(response).to redirect_to("/")
end | CWE-287 | 4 |
it "returns the database from the options" do
session.current_database.should eq(database)
end | CWE-400 | 2 |
def reactions_given
params.require(:username)
user = fetch_user_from_params(include_inactive: current_user.try(:staff?) || (current_user && SiteSetting.show_inactive_accounts))
raise Discourse::NotFound unless guardian.can_see_profile?(user)
reaction_users = DiscourseReactions::ReactionUser
.joins(:reaction, :post)
.includes(:user, :post, :reaction)
.where(user_id: user.id)
.where('discourse_reactions_reactions.reaction_users_count IS NOT NULL')
if params[:before_reaction_user_id]
reaction_users = reaction_users
.where('discourse_reactions_reaction_users.id < ?', params[:before_reaction_user_id].to_i)
end
reaction_users = reaction_users
.order(created_at: :desc)
.limit(20)
render_serialized(reaction_users.to_a, UserReactionSerializer)
end | CWE-200 | 10 |
it "inserts the documents" do
session.should_receive(:execute).with do |insert|
insert.documents.should eq [{a: 1}, {b: 2}]
end
collection.insert([{a: 1}, {b: 2}])
end | CWE-400 | 2 |
def set_inboxes
@inbox_ids = if params[:inbox_id]
current_account.inboxes.where(id: params[:inbox_id])
else
@current_user.assigned_inboxes.pluck(:id)
end | CWE-269 | 6 |
it 'returns the right response' do
get "/session/email-login/adasdad"
expect(response.status).to eq(200)
expect(CGI.unescapeHTML(response.body)).to match(
I18n.t('email_login.invalid_token')
)
end | CWE-287 | 4 |
it "initializes with the strings bytes" do
Moped::BSON::ObjectId.should_receive(:new).with(bytes)
Moped::BSON::ObjectId.from_string "4e4d66343b39b68407000001"
end | CWE-400 | 2 |
def restrict_user_fields?(user)
user.trust_level == TrustLevel[0] && anonymous?
end | CWE-200 | 10 |
def more?
@get_more_op.cursor_id != 0
end | CWE-400 | 2 |
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 executed
# if a new request is created (which could fail if User.current
# cannot modify the source_package).
return unless skip_source
target_project = Project.get_by_name(self.target_project)
return unless target_project && target_project.is_a?(Project)
target_package = target_project.packages.find_by_name(self.target_package)
initialize_devel_package = target_project.find_attribute('OBS', 'InitializeDevelPackage')
return if target_package || !initialize_devel_package
source_package = Package.get_by_project_and_name(source_project, self.source_package)
return if !source_package || User.current.can_modify?(source_package)
msg = 'No permission to initialize the source package as a devel package'
raise PostRequestNoPermission, msg
end | CWE-732 | 13 |
it "should return :file if the URI protocol is set to 'file'" do
@request.expects(:protocol).returns "file"
@object.select_terminus(@request).should == :file
end | CWE-200 | 10 |
it "does not change the original session's options" do
original_options = options.dup
session.with(new_options) do |new_session|
session.options.should eql original_options
end
end | CWE-400 | 2 |
it 'returns success' do
get "/session/email-login/#{email_token.token}"
expect(response).to redirect_to("/")
end | CWE-287 | 4 |
it "limits the query" do
session.should_receive(:query) do |query|
query.limit.should eq(-1)
reply
end
session.simple_query(query)
end | CWE-20 | 0 |
def legal?(str)
!!str.match(/^[0-9a-f]{24}$/i)
end | CWE-400 | 2 |
def kill
session.execute kill_cursor_op
end | CWE-400 | 2 |
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 | CWE-400 | 2 |
def handle_meta(message, local, &callback)
method = Channel.parse(message['channel'])[1]
unless META_METHODS.include?(method)
response = make_response(message)
response['error'] = Faye::Error.channel_forbidden(message['channel'])
response['successful'] = false
return callback.call([response])
end
__send__(method, message, local) do |responses|
responses = [responses].flatten
responses.each { |r| advize(r, message['connectionType']) }
callback.call(responses)
end
end | CWE-287 | 4 |
it "inserts the document" do
session.should_receive(:execute).with do |insert|
insert.documents.should eq [{a: 1}]
end
collection.insert(a: 1)
end | CWE-20 | 0 |
it "returns a new Query" do
Moped::Query.should_receive(:new).
with(collection, selector).and_return(query)
collection.find(selector).should eq query
end | CWE-20 | 0 |
def update
article = Ticket::Article.find(params[:id])
authorize!(article)
clean_params = Ticket::Article.association_name_to_id_convert(params)
clean_params = Ticket::Article.param_cleanup(clean_params, true)
# only apply preferences changes (keep not updated keys/values)
clean_params = article.param_preferences_merge(clean_params)
article.update!(clean_params)
if response_expand?
result = article.attributes_with_association_names
render json: result, status: :ok
return
end
if response_full?
full = Ticket::Article.full(params[:id])
render json: full, status: :ok
return
end
render json: article.attributes_with_association_names, status: :ok
end | CWE-862 | 8 |
def known_addresses
[].tap do |addresses|
addresses.concat seeds
addresses.concat dynamic_seeds
addresses.concat servers.map { |server| server.address }
end.uniq
end | CWE-20 | 0 |
def initialize(env)
request = ::Rack::Request.new(env)
@cookie = request.cookies[COOKIE_NAME]
if @cookie
@cookie.split(",").map{|pair| pair.split("=")}.each do |k,v|
@orig_disable_profiling = @disable_profiling = (v=='t') if k == "dp"
@backtrace_level = v.to_i if k == "bt"
end
end
@backtrace_level = nil if !@backtrace_level.nil? && (@backtrace_level == 0 || @backtrace_level > BACKTRACE_NONE)
@orig_backtrace_level = @backtrace_level
end | CWE-200 | 10 |
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 with request but no publickey_dir defined in configuration. Not writing key to disk.")
return
end
if File.directory?(publickey_dir)
if File.exists?(old_keyfile = File.join(publickey_dir, "#{identity}_pub.pem"))
old_key = File.read(old_keyfile).chomp
unless old_key == key
unless lookup_config_option('overwrite_stored_keys', 'n') =~ /^1|y/
Log.warn("Public key sent from '%s' does not match the stored key. Not overwriting." % identity)
else
Log.warn("Public key sent from '%s' does not match the stored key. Overwriting." % identity)
File.open(File.join(publickey_dir, "#{identity}_pub.pem"), 'w') { |f| f.puts key }
end
end
else
Log.debug("Discovered a new public key for '%s'. Writing to '%s'" % [identity, publickey_dir])
File.open(File.join(publickey_dir, "#{identity}_pub.pem"), 'w') { |f| f.puts key }
end
else
raise("Cannot write public key to '%s'. Directory does not exist." % publickey_dir)
end
end | CWE-20 | 0 |
def next
now = Time.new.to_i
counter = @mutex.synchronize do
last_timestamp, @last_timestamp = @last_timestamp, now
if last_timestamp == now
@counter += 1
else
@counter = 0
end
end
generate(now, counter)
end | CWE-400 | 2 |
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
query.remove
end | CWE-400 | 2 |
it "does not drop other indexes" do
indexes[age: -1].should_not be_nil
end | CWE-20 | 0 |
def legal?(string)
string.to_s =~ /^[0-9a-f]{24}$/i ? true : false
end | CWE-400 | 2 |
def test_update_valid
Realm.any_instance.stubs(:valid?).returns(true)
put :update, {:id => Realm.first.name,
:realm => { :realm_proxy_id => SmartProxy.first.id } }, set_session_user
assert_equal SmartProxy.first.id, Realm.first.realm_proxy_id
assert_redirected_to realms_url
end | CWE-200 | 10 |
it 'does not include user or group archived messages' do
UserArchivedMessage.archive!(user.id, group_message)
UserArchivedMessage.archive!(user.id, private_message)
topics = TopicQuery.new(nil).list_private_messages_all(user).topics
expect(topics).to eq([])
GroupArchivedMessage.archive!(user_2.id, group_message)
topics = TopicQuery.new(nil).list_private_messages_all(user_2).topics
expect(topics).to contain_exactly(private_message)
end | CWE-863 | 11 |
it "has an empty list of servers" do
cluster.servers.should be_empty
end | CWE-20 | 0 |
it "sets the query operation's limit field" do
query.limit(5)
query.operation.limit.should eq 5
end | CWE-400 | 2 |
def current_user
User.except_hidden.find_by_login(self.user)
end | CWE-200 | 10 |
def generate(time, inc = 0)
pid = Process.pid % 0xFFFF
[
time >> 24 & 0xFF, # 4 bytes time (network order)
time >> 16 & 0xFF,
time >> 8 & 0xFF,
time & 0xFF,
@machine_id[0], # 3 bytes machine
@machine_id[1],
@machine_id[2],
pid >> 8 & 0xFF, # 2 bytes process id
pid & 0xFF,
inc >> 16 & 0xFF, # 3 bytes increment
inc >> 8 & 0xFF,
inc & 0xFF,
]
end | CWE-20 | 0 |
it "should return :file if the request key is fully qualified" do
@request.expects(:key).returns File.expand_path('/foo')
@object.select_terminus(@request).should == :file
end | CWE-200 | 10 |
it "removes all matching documents" do
session.should_receive(:with, :consistency => :strong).
and_yield(session)
session.should_receive(:execute).with do |delete|
delete.flags.should eq []
delete.selector.should eq query.operation.selector
end
query.remove_all
end | CWE-20 | 0 |
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)
@keywords = @article.tags.map(&:name).join(", ")
render "articles/#{@article.post_type}"
end
format.atom { render_feedback_feed("atom") }
format.rss { render_feedback_feed("rss") }
format.xml { render_feedback_feed("atom") }
end
rescue ActiveRecord::RecordNotFound
error!
end | CWE-863 | 11 |
def merge(server)
previous = servers.find { |other| other == server }
primary = server.primary?
secondary = server.secondary?
if previous
previous.merge(server)
else
servers << server
end
end | CWE-20 | 0 |
it 'fails when local logins via email is disabled' do
SiteSetting.enable_local_logins_via_email = false
get "/session/email-login/#{email_token.token}"
expect(response.status).to eq(404)
end | CWE-287 | 4 |
def test_formats_valid
AuthSourceLdap.any_instance.stubs(:valid?).returns(false)
put :update, {:id => AuthSourceLdap.first.id, :format => "weird", :auth_source_ldap => {:name => AuthSourceLdap.first.name} }, set_session_user
assert_response :success
wierd_id = "#{AuthSourceLdap.first.id}.weird"
put :update, {:id => wierd_id, :auth_source_ldap => {:name => AuthSourceLdap.first.name} }, set_session_user
assert_response :success
parameterized_id = "#{AuthSourceLdap.first.id}-#{AuthSourceLdap.first.name.parameterize}"
put :update, {:id => parameterized_id, :auth_source_ldap => {:name => AuthSourceLdap.first.name} }, set_session_user
assert_response :success
end | CWE-200 | 10 |
it "stores whether the connection is direct" do
cluster.direct.should be_true
end | CWE-400 | 2 |
it "removes the socket" do
cluster.should_receive(:remove).with(dead_server)
cluster.socket_for :write
end | CWE-20 | 0 |
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 | CWE-287 | 4 |
def reset_password
@admin_user = Motor::AdminUser.find(params[:admin_user_id])
authorize!(:manage, @admin_user)
Devise::Mailer.default_url_options = { host: request.host, protocol: request.protocol, port: request.port }
@admin_user.send_reset_password_instructions
head :ok
end | CWE-116 | 15 |
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
result = result.where("topics.id IN (
SELECT topic_id
FROM topic_allowed_users
WHERE user_id = #{user.id.to_i}
UNION ALL
SELECT topic_id FROM topic_allowed_groups
WHERE group_id IN (
SELECT group_id FROM group_users WHERE user_id = #{user.id.to_i}
)
)")
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 | CWE-863 | 11 |
def remove(server)
servers.delete(server)
end | CWE-400 | 2 |
def simple_query(query)
query.limit = -1
query(query).documents.first
end | CWE-20 | 0 |
it "does not change the original session's options" do
original_options = options.dup
session.with(new_options) do |new_session|
session.options.should eql original_options
end
end | CWE-20 | 0 |
it "updates all records matching selector with change" do
query.should_receive(:update).with(change, [:multi])
query.update_all change
end | CWE-20 | 0 |
it "does not activate user invited via links" do
invite = Fabricate(:invite, email: '[email protected]', emailed_status: Invite.emailed_status_types[:not_required])
user = InviteRedeemer.create_user_from_invite(invite: invite, email: invite.email, username: 'walter', name: 'Walter White')
expect(user.username).to eq('walter')
expect(user.name).to eq('Walter White')
expect(user.email).to eq('[email protected]')
expect(user.approved).to eq(true)
expect(user.active).to eq(false)
end | CWE-863 | 11 |
it "should escape evil haxxor attemptes" do
Mail.defaults do
delivery_method :sendmail, :arguments => nil
end
mail = Mail.new do
from '"foo\";touch /tmp/PWNED;\""@blah.com'
to '[email protected]'
subject 'invalid RFC2822'
end
Mail::Sendmail.should_receive(:call).with('/usr/sbin/sendmail',
"-f \"\\\"foo\\\\\\\"\\;touch /tmp/PWNED\\;\\\\\\\"\\\"@blah.com\"",
'[email protected]',
mail)
mail.deliver!
end | CWE-20 | 0 |
def index
@applications = Doorkeeper.config.application_model.authorized_for(current_resource_owner)
respond_to do |format|
format.html
format.json { render json: @applications }
end
end | CWE-862 | 8 |
def test_destroy
auth_source_ldap = AuthSourceLdap.first
User.where(:auth_source_id => auth_source_ldap.id).update_all(:auth_source_id => nil)
delete :destroy, {:id => auth_source_ldap}, set_session_user
assert_redirected_to auth_source_ldaps_url
assert !AuthSourceLdap.exists?(auth_source_ldap.id)
end | CWE-200 | 10 |
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 | CWE-863 | 11 |
it "initializes with the strings bytes" do
Moped::BSON::ObjectId.should_receive(:new).with(bytes)
Moped::BSON::ObjectId.from_string "4e4d66343b39b68407000001"
end | CWE-20 | 0 |
def create
@application = Doorkeeper.config.application_model.new(application_params)
if @application.save
flash[:notice] = I18n.t(:notice, scope: %i[doorkeeper flash applications create])
flash[:application_secret] = @application.plaintext_secret
respond_to do |format|
format.html { redirect_to oauth_application_url(@application) }
format.json { render json: @application }
end
else
respond_to do |format|
format.html { render :new }
format.json do
errors = @application.errors.full_messages
render json: { errors: errors }, status: :unprocessable_entity
end
end
end
end | CWE-862 | 8 |
it "delegates to the cluster" do
session.cluster.should_receive(:socket_for).with(:read)
session.send(:socket_for, :read)
end | CWE-20 | 0 |
def reconnect
@servers = servers.map { |server| Server.new(server.address) }
end | CWE-400 | 2 |
it 'should not overwrite an existing file if overwrite_stored_key is not set' do
@plugin.stubs(:lookup_config_option).with('learn_public_keys').returns('1')
@plugin.stubs(:lookup_config_option).with('publickey_dir').returns('ssh/pkd')
@plugin.stubs(:lookup_config_option).with('overwrite_stored_keys', 'n').returns('n')
File.stubs(:directory?).with('ssh/pkd').returns(true)
File.stubs(:exists?).with('ssh/pkd/rspec_pub.pem').returns(true)
File.stubs(:read).with('ssh/pkd/rspec_pub.pem').returns('ssh-rsa dcba')
Log.expects(:warn)
File.expects(:open).never
@plugin.send(:write_key_to_disk, 'ssh-rsa abcd', 'rspec')
end | CWE-20 | 0 |
it "returns the living socket" do
cluster.socket_for(:write).should eq socket
end | CWE-400 | 2 |
it "returns false" do
session.should_not be_safe
end | CWE-400 | 2 |
def match?(name, ip)
ip? ? pattern.include?(IPAddr.new(ip)) : matchname?(name)
end | CWE-287 | 4 |
it "yields a session" do
session.with(new_options) do |new_session|
new_session.should be_a Moped::Session
end
end | CWE-20 | 0 |
def test_nest
get :nest, {:id => Hostgroup.first.id}, set_session_user
assert_template 'new'
end | CWE-200 | 10 |
it "recognizes and generates #destroy" do
{ :delete => "/users/1" }.should route_to(:controller => "users", :action => "destroy", :id => "1")
end | CWE-200 | 10 |
it "inserts the document" do
session.should_receive(:execute).with do |insert|
insert.documents.should eq [{a: 1}]
end
collection.insert(a: 1)
end | CWE-400 | 2 |
it "returns the document" do
session.simple_query(query).should eq(a: 1)
end | CWE-20 | 0 |
it "returns the same hash" do
Moped::BSON::ObjectId.new(bytes).hash.should eq Moped::BSON::ObjectId.new(bytes).hash
end | CWE-400 | 2 |
it "recognizes and generates #index" do
{ :get => "/users" }.should route_to(:controller => "users", :action => "index")
end | CWE-200 | 10 |
def initialize(seeds, options = {})
@cluster = Cluster.new(seeds)
@options = options
@options[:consistency] ||= :eventual
end | CWE-20 | 0 |
it "stores the selector" do
query.selector.should eq selector
end | CWE-20 | 0 |
it "memoizes the database" do
database = session.current_database
session.current_database.should equal(database)
end | CWE-20 | 0 |
def __bson_dump__(io, key)
io << Types::OBJECT_ID
io << key
io << NULL_BYTE
io << data.pack('C12')
end | CWE-20 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.