mirror of
https://github.com/inspec/inspec
synced 2024-11-10 07:04:15 +00:00
Changed a bunch of profiles to use / instead of /tmp for Windows compat.
This commit is contained in:
parent
2eaebe510c
commit
4242937bea
16 changed files with 45 additions and 54 deletions
|
@ -1,6 +1,6 @@
|
|||
control 'tmp-1.0' do
|
||||
impact 0.7
|
||||
title 'Create /tmp directory'
|
||||
title 'Create / directory'
|
||||
description 'Default description'
|
||||
description rational: 'Rational for the metadata test control'
|
||||
description 'something else': 'Even more metadata for the test control'
|
||||
|
|
|
@ -12,9 +12,9 @@ include_controls 'profile_c'
|
|||
# you add controls here
|
||||
control 'profilea-1' do # A unique ID for this control
|
||||
impact 0.7 # The criticality, if this control fails.
|
||||
title 'Create /tmp directory' # A human-readable title
|
||||
title 'Create / directory' # A human-readable title
|
||||
desc 'An optional description...'
|
||||
describe file('/tmp') do # The actual test
|
||||
describe file('/') do # The actual test
|
||||
it { should be_directory }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,9 +6,9 @@ include_controls 'profile_d'
|
|||
# you add controls here
|
||||
control 'profileb-1' do # A unique ID for this control
|
||||
impact 0.7 # The criticality, if this control fails.
|
||||
title 'Create /tmp directory' # A human-readable title
|
||||
title 'Create / directory' # A human-readable title
|
||||
desc 'An optional description...'
|
||||
describe file('/tmp') do # The actual test
|
||||
describe file('/') do # The actual test
|
||||
it { should be_directory }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ control 'profilec-1' do # A unique ID for this control
|
|||
impact 0.7 # The criticality, if this control fails.
|
||||
title 'Create /tmp directory' # A human-readable title
|
||||
desc 'An optional description...'
|
||||
describe file('/tmp') do # The actual test
|
||||
describe file('/') do # The actual test
|
||||
it { should be_directory }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# you add controls here
|
||||
control 'profiled-1' do # A unique ID for this control
|
||||
impact 0.7 # The criticality, if this control fails.
|
||||
title 'Create /tmp directory (profile d)' # A human-readable title
|
||||
title 'Create / directory (profile d)' # A human-readable title
|
||||
desc 'An optional description...'
|
||||
describe file('/tmp') do # The actual test
|
||||
describe file('/') do # The actual test
|
||||
it { should be_directory }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# you add controls here
|
||||
control 'tmp-1.0' do # A unique ID for this control
|
||||
impact 0.7 # The criticality, if this control fails.
|
||||
title 'Create /tmp directory' # A human-readable title
|
||||
title 'Create / directory' # A human-readable title
|
||||
desc 'An optional description...'
|
||||
describe file('/tmp') do # The actual test
|
||||
describe file('/') do # The actual test
|
||||
it { should be_directory }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
# copyright: 2015, Chef Software, Inc.
|
||||
|
||||
title 'failures /tmp profile'
|
||||
title 'failures / profile'
|
||||
|
||||
# control, first test passes, second fails
|
||||
control "tmp-1.0" do # A unique ID for this control
|
||||
impact 0.7 # The criticality, if this control fails.
|
||||
title "Create /tmp directory" # A human-readable title
|
||||
title "Create / directory" # A human-readable title
|
||||
desc "An optional description..." # Describe why this is needed
|
||||
tag data: "temp data" # A tag allows you to associate key information
|
||||
tag "security" # to the test
|
||||
ref "Document A-12", url: 'http://...' # Additional references
|
||||
|
||||
describe file('/tmp') do # The actual test
|
||||
describe file('/') do # The actual test
|
||||
it { should be_directory }
|
||||
it { should_not be_directory }
|
||||
end
|
||||
end
|
||||
|
||||
# anonymous describe block, first passes, second is syntax error
|
||||
describe file('/tmp') do
|
||||
describe file('/') do
|
||||
it { should be_directory }
|
||||
it { should_nota be_directory }
|
||||
end
|
||||
|
||||
# anonymous describe block, first fails, second passes
|
||||
describe file('/tmp') do
|
||||
describe file('/') do
|
||||
it { should_not be_directory }
|
||||
it { should be_directory }
|
||||
its('mode') { should cmp '01147' }
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
describe file('/tmp/foo') do
|
||||
describe file('/foo') do
|
||||
it { should exist }
|
||||
end
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
# copyright: 2015, Chef Software, Inc.
|
||||
|
||||
title '/tmp profile'
|
||||
title '/ profile'
|
||||
|
||||
# you add controls here
|
||||
control 'tmp-1.0' do # A unique ID for this control
|
||||
impact 0.7 # The criticality, if this control fails.
|
||||
title 'Create /tmp directory' # A human-readable title
|
||||
title 'Create / directory' # A human-readable title
|
||||
desc 'An optional description...' # Describe why this is needed
|
||||
desc 'label', 'An optional description with a label' # Pair a part of the description with a label
|
||||
tag data: 'temp data' # A tag allows you to associate key information
|
||||
tag 'security' # to the test
|
||||
ref 'Document A-12', url: 'http://...' # Additional references
|
||||
|
||||
describe file('/tmp') do # The actual test
|
||||
describe file('/') do # The actual test
|
||||
it { should be_directory }
|
||||
end
|
||||
end
|
||||
|
||||
# you can also use plain tests
|
||||
describe file('/tmp') do
|
||||
describe file('/') do
|
||||
it { should be_directory }
|
||||
end
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
title 'sample section'
|
||||
|
||||
# you can also use plain tests
|
||||
describe file('/tmp') do
|
||||
describe file('/') do
|
||||
it { should be_directory }
|
||||
end
|
||||
|
||||
# you add controls here
|
||||
control 'tmp-1.0' do # A unique ID for this control
|
||||
impact 0.7 # The criticality, if this control fails.
|
||||
title 'Create /tmp directory' # A human-readable title
|
||||
title 'Create / directory' # A human-readable title
|
||||
desc 'An optional description...'
|
||||
describe file('/tmp') do # The actual test
|
||||
describe file('/') do # The actual test
|
||||
it { should be_directory }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
include_controls 'failures'
|
||||
|
||||
describe file('/tmp') do
|
||||
describe file('/') do
|
||||
it { should be_directory }
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
control 'tmp-1.0' do
|
||||
impact 0.7
|
||||
title 'Create /tmp directory'
|
||||
title 'Create / directory'
|
||||
desc 'An optional description...'
|
||||
describe file('/tmp') do
|
||||
describe file('/') do
|
||||
it { should be_directory }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,9 +3,9 @@ Inspec::Log.warn 'This is another warn call!'
|
|||
|
||||
control 'tmp-1.0' do # A unique ID for this control
|
||||
impact 0.7 # The criticality, if this control fails.
|
||||
title 'Create /tmp directory' # A human-readable title
|
||||
title 'Create / directory' # A human-readable title
|
||||
desc 'An optional description...'
|
||||
describe file('/tmp') do # The actual test
|
||||
describe file('/') do # The actual test
|
||||
it { should be_directory }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -158,9 +158,15 @@ describe "inspec exec with json formatter" do
|
|||
})
|
||||
|
||||
_(groups.sort_by { |x| x["id"] }).must_equal([
|
||||
{ "id" => "controls/example-tmp.rb", "title" => "/tmp profile", "controls" => ["tmp-1.0", key] },
|
||||
{ "id" => "controls/example.rb", "title" => "Example Config Checks", "controls" => ["example-1.0"] },
|
||||
{ "id" => "controls/meta.rb", "title" => "SSH Server Configuration", "controls" => ["ssh-1"] },
|
||||
{ "id" => "controls/example-tmp.rb",
|
||||
"title" => "/ profile",
|
||||
"controls" => ["tmp-1.0", key] },
|
||||
{ "id" => "controls/example.rb",
|
||||
"title" => "Example Config Checks",
|
||||
"controls" => ["example-1.0"] },
|
||||
{ "id" => "controls/meta.rb",
|
||||
"title" => "SSH Server Configuration",
|
||||
"controls" => ["ssh-1"] },
|
||||
])
|
||||
end
|
||||
|
||||
|
@ -187,37 +193,23 @@ describe "inspec exec with json formatter" do
|
|||
|
||||
result = actual.delete("results")[0]
|
||||
_(result).wont_be :nil?
|
||||
skip_windows!
|
||||
|
||||
_(result["status"]).must_equal "passed"
|
||||
_(result["code_desc"]).must_equal "File /tmp should be directory"
|
||||
_(result["code_desc"]).must_equal "File / should be directory"
|
||||
_(result["run_time"]).wont_be :nil?
|
||||
_(result["start_time"]).wont_be :nil?
|
||||
|
||||
example_rb_code = <<~END
|
||||
control 'tmp-1.0' do # A unique ID for this control
|
||||
impact 0.7 # The criticality, if this control fails.
|
||||
title 'Create /tmp directory' # A human-readable title
|
||||
desc 'An optional description...' # Describe why this is needed
|
||||
desc 'label', 'An optional description with a label' # Pair a part of the description with a label
|
||||
tag data: 'temp data' # A tag allows you to associate key information
|
||||
tag 'security' # to the test
|
||||
ref 'Document A-12', url: 'http://...' # Additional references
|
||||
|
||||
describe file('/tmp') do # The actual test
|
||||
it { should be_directory }
|
||||
end
|
||||
end
|
||||
END
|
||||
code = actual.delete "code"
|
||||
_(code).must_include "control 'tmp-1.0' do"
|
||||
|
||||
_(actual).must_equal({
|
||||
"id" => "tmp-1.0",
|
||||
"title" => "Create /tmp directory",
|
||||
"title" => "Create / directory",
|
||||
"desc" => "An optional description...",
|
||||
"descriptions" => [{ "label" => "default", "data" => "An optional description..." }, { "label" => "label", "data" => "An optional description with a label" }],
|
||||
"impact" => 0.7,
|
||||
"refs" => [{ "url" => "http://...", "ref" => "Document A-12" }],
|
||||
"tags" => { "data" => "temp data", "security" => nil },
|
||||
"code" => example_rb_code,
|
||||
"waiver_data" => {},
|
||||
})
|
||||
end
|
||||
|
|
|
@ -43,7 +43,6 @@ describe "inspec exec" do
|
|||
end
|
||||
|
||||
describe "execute a profile with mini json formatting" do
|
||||
let(:json) { JSON.load(inspec("exec " + example_profile + " --reporter json-min --no-create-lockfile").stdout) }
|
||||
let(:controls) { json["controls"] }
|
||||
let(:ex1) { controls.find { |x| x["id"] == "tmp-1.0" } }
|
||||
let(:ex2) { controls.find { |x| x["id"] =~ /generated/ } }
|
||||
|
@ -62,7 +61,7 @@ describe "inspec exec" do
|
|||
end
|
||||
|
||||
it "has a code_desc" do
|
||||
_(ex1["code_desc"]).must_equal "File /tmp should be directory"
|
||||
_(ex1["code_desc"]).must_equal "File / should be directory"
|
||||
_(controls.find { |ex| !ex.key? "code_desc" }).must_be :nil?
|
||||
end
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ describe "inspec exec with junit formatter" do
|
|||
_(suite.attribute("failed").value).must_equal "0"
|
||||
end
|
||||
|
||||
it 'has 2 elements named "File /tmp should be directory"' do
|
||||
_(REXML::XPath.match(suite, "//testcase[@name='File /tmp should be directory']").length).must_equal 2
|
||||
it 'has 2 elements named "File / should be directory"' do
|
||||
_(REXML::XPath.match(suite, "//testcase[@name='File / should be directory']").length).must_equal 2
|
||||
end
|
||||
|
||||
describe 'the testcase named "example_config Can\'t find file ..."' do
|
||||
|
|
Loading…
Reference in a new issue