Skip to content

Commit

Permalink
Merge pull request dev-sec#22 from TelekomLabs/update-common
Browse files Browse the repository at this point in the history
updating common files
  • Loading branch information
chris-rock committed Oct 20, 2014
2 parents f81fd22 + 56d8d06 commit 8b140c4
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 40 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
source 'https://rubygems.org'

gem 'rake'
gem 'serverspec'
gem 'serverspec', '~> 2.3.0'
gem 'rubocop', '~> 0.23'
gem 'highline', '~> 1.6.0'
4 changes: 0 additions & 4 deletions default/serverspec/os_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

require 'spec_helper'

RSpec.configure do |c|
c.filter_run_excluding skipOn: backend(Serverspec::Commands::Base).check_os[:family]
end


describe command('find / -name \'.rhosts\' | wc -l ') do
its(:stdout) { should match(/^0/) }
Expand Down
18 changes: 7 additions & 11 deletions default/serverspec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
require 'net/ssh'
require 'highline/import'

include Serverspec::Helper::Ssh
include Serverspec::Helper::DetectOS
set :backend, :ssh

RSpec.configure do |c|

Expand All @@ -42,28 +41,25 @@
end

if ENV['ASK_LOGIN_USERNAME']
user = ask("\nEnter login username: ") { |q| q.echo = false }
options[:user] = ask("\nEnter login username: ") { |q| q.echo = false }
else
user = ENV['LOGIN_USERNAME'] || ENV['user'] || Etc.getlogin
options[:user] = ENV['LOGIN_USERNAME'] || ENV['user'] || Etc.getlogin
end

if user.nil?
if options[:user].nil?
puts 'specify login user env LOGIN_USERNAME= or user='
exit 1
end

c.host = ENV['TARGET_HOST']
options.merge(Net::SSH::Config.for(c.host))
c.ssh = Net::SSH.start(c.host, user, options)
c.os = backend.check_os
c.host = ENV['TARGET_HOST']
c.ssh_options = options.merge(Net::SSH::Config.for(c.host))

end

else
require 'serverspec'

include Serverspec::Helper::Exec
include Serverspec::Helper::DetectOS
set :backend, :exec

RSpec.configure do |c|
c.before :all do
Expand Down
6 changes: 1 addition & 5 deletions default/serverspec/sysctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

require 'spec_helper'

RSpec.configure do |c|
c.filter_run_excluding skipOn: backend(Serverspec::Commands::Base).check_os[:family]
end

describe 'IP V4 networking' do


Expand Down Expand Up @@ -204,7 +200,7 @@


# check if we find the nx flag
if command('cat /proc/cpuinfo').return_stdout?(/^flags.*?:.*? nx( .*?)?$/)
if command('cat /proc/cpuinfo').stdout =~ /^flags.*?:.*? nx( .*?)?$/
true
else
# if no nx flag is present, we require exec-shield
Expand Down
4 changes: 0 additions & 4 deletions lockdown/serverspec/os_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

require 'spec_helper'

RSpec.configure do |c|
c.filter_run_excluding skipOn: backend(Serverspec::Commands::Base).check_os[:family]
end


describe command('find / -name \'.rhosts\' | wc -l ') do
its(:stdout) { should match(/^0/) }
Expand Down
18 changes: 7 additions & 11 deletions lockdown/serverspec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
require 'net/ssh'
require 'highline/import'

include Serverspec::Helper::Ssh
include Serverspec::Helper::DetectOS
set :backend, :ssh

RSpec.configure do |c|

Expand All @@ -42,28 +41,25 @@
end

if ENV['ASK_LOGIN_USERNAME']
user = ask("\nEnter login username: ") { |q| q.echo = false }
options[:user] = ask("\nEnter login username: ") { |q| q.echo = false }
else
user = ENV['LOGIN_USERNAME'] || ENV['user'] || Etc.getlogin
options[:user] = ENV['LOGIN_USERNAME'] || ENV['user'] || Etc.getlogin
end

if user.nil?
if options[:user].nil?
puts 'specify login user env LOGIN_USERNAME= or user='
exit 1
end

c.host = ENV['TARGET_HOST']
options.merge(Net::SSH::Config.for(c.host))
c.ssh = Net::SSH.start(c.host, user, options)
c.os = backend.check_os
c.host = ENV['TARGET_HOST']
c.ssh_options = options.merge(Net::SSH::Config.for(c.host))

end

else
require 'serverspec'

include Serverspec::Helper::Exec
include Serverspec::Helper::DetectOS
set :backend, :exec

RSpec.configure do |c|
c.before :all do
Expand Down
4 changes: 0 additions & 4 deletions lockdown/serverspec/sysctl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

require 'spec_helper'

RSpec.configure do |c|
c.filter_run_excluding skipOn: backend(Serverspec::Commands::Base).check_os[:family]
end

describe 'IP V4 networking' do


Expand Down

0 comments on commit 8b140c4

Please sign in to comment.