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