-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(SIMP-6708) Create and ensure inspec tests work by module (#52)
* Create CentOS-7-disa_stig * Delete CentOS-7-disa_stig * Create 00_Control_Selector.rb * Add files via upload * Create 00_Control_Selector.rb * Create inspec.yml * Update .fixtures.yml * Added inspec profile to run Aide specific tests * Fix Red hat inspec profile * Adds capability to run inspec compliance tests * Delete 00_Control_Selector.rb * Update Inspec.yml * Created redhat symlink * Updated method for choosing hosts * Added nodeset symlink * Ensure that STIG mode is enforced during compliance checks * run puppet after reboot for auditd cleanup * update SSG checks * Version Bump * Skipped a failing test and added a ticket to look into it on the backlog.
- Loading branch information
1 parent
b2d89e3
commit 4ae47cc
Showing
15 changed files
with
278 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
* Wed Aug 14 2019 Trevor Vaughan <[email protected]> - 6.3.1-0 | ||
- With contributions from ischmidt1235 on GitHub | ||
- Add InSpec compliance tests | ||
- Fix bug in Compliance Engine data | ||
- Add SCAP compliance tests | ||
|
||
* Thu Jun 06 2019 Steven Pritchard <[email protected]> - 6.3.0-0 | ||
- Add v2 compliance_markup data | ||
- Drop support for Puppet 4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
spec/acceptance/suites/compliance/00_simp_profile_install_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
test_name 'aide STIG enforcement of simp profile' | ||
|
||
describe 'aide STIG enforcement of simp profile' do | ||
|
||
let(:manifest) { | ||
<<-EOS | ||
include 'aide' | ||
EOS | ||
} | ||
|
||
let(:hieradata) { <<-EOF | ||
--- | ||
simp_options::pki: true | ||
simp_options::pki::source: '/etc/pki/simp-testing/pki' | ||
compliance_markup::enforcement: | ||
- disa_stig | ||
EOF | ||
} | ||
|
||
hosts.each do |host| | ||
|
||
let(:hiera_yaml) { <<-EOM | ||
--- | ||
version: 5 | ||
hierarchy: | ||
- name: Common | ||
path: common.yaml | ||
- name: Compliance | ||
lookup_key: compliance_markup::enforcement | ||
defaults: | ||
data_hash: yaml_data | ||
datadir: "#{hiera_datadir(host)}" | ||
EOM | ||
} | ||
|
||
context 'when enforcing the STIG' do | ||
it 'should work with no errors' do | ||
create_remote_file(host, host.puppet['hiera_config'], hiera_yaml) | ||
write_hieradata_to(host, hieradata) | ||
|
||
apply_manifest_on(host, manifest, :catch_failures => true) | ||
end | ||
|
||
it 'should reboot and then run puppet for audit updates' do | ||
host.reboot | ||
|
||
apply_manifest_on(host, manifest, :catch_failures => true) | ||
end | ||
|
||
it 'should be idempotent' do | ||
apply_manifest_on(host, manifest, :catch_changes => true) | ||
end | ||
end | ||
end | ||
end |
65 changes: 65 additions & 0 deletions
65
spec/acceptance/suites/compliance/01_simp_profile_inspec_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
require 'spec_helper_acceptance' | ||
require 'json' | ||
|
||
test_name 'Check Inspec for simp profile' | ||
|
||
describe 'run inspec against the appropriate fixtures for simp audit profile' do | ||
|
||
profiles_to_validate = ['disa_stig'] | ||
|
||
hosts.each do |host| | ||
profiles_to_validate.each do |profile| | ||
context "for profile #{profile}" do | ||
context "on #{host}" do | ||
profile_path = File.join( | ||
fixtures_path, | ||
'inspec_profiles', | ||
"#{fact_on(host, 'operatingsystem')}-#{fact_on(host, 'operatingsystemmajrelease')}-#{profile}" | ||
) | ||
|
||
unless File.exist?(profile_path) | ||
it 'should run inspec' do | ||
skip("No matching profile available at #{profile_path}") | ||
end | ||
else | ||
before(:all) do | ||
@inspec = Simp::BeakerHelpers::Inspec.new(host, profile) | ||
@inspec_report = {:data => nil} | ||
end | ||
|
||
it 'should run inspec' do | ||
@inspec.run | ||
end | ||
|
||
it 'should have an inspec report' do | ||
@inspec_report[:data] = @inspec.process_inspec_results | ||
|
||
info = [ | ||
'Results:', | ||
" * Passed: #{@inspec_report[:data][:passed]}", | ||
" * Failed: #{@inspec_report[:data][:failed]}", | ||
" * Skipped: #{@inspec_report[:data][:skipped]}" | ||
] | ||
|
||
puts info.join("\n") | ||
|
||
@inspec.write_report(@inspec_report[:data]) | ||
end | ||
|
||
it 'should have run some tests' do | ||
expect(@inspec_report[:data][:failed] + @inspec_report[:data][:passed]).to be > 0 | ||
end | ||
|
||
it 'should not have any failing tests' do | ||
if @inspec_report[:data][:failed] > 0 | ||
puts @inspec_report[:data][:report] | ||
end | ||
|
||
expect( @inspec_report[:data][:failed] ).to eq(0) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
63 changes: 63 additions & 0 deletions
63
spec/acceptance/suites/compliance/10_stig_profile_oscap_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
test_name 'Check SCAP for stig profile' | ||
|
||
describe 'run the SSG against the appropriate fixtures for stig aide profile' do | ||
|
||
hosts.each do |host| | ||
context "on #{host}" do | ||
before(:all) do | ||
@os_str = fact_on(host, 'operatingsystem') + ' ' + fact_on(host, 'operatingsystemrelease') | ||
|
||
@ssg_supported = true | ||
|
||
begin | ||
@ssg = Simp::BeakerHelpers::SSG.new(host) | ||
rescue | ||
@ssg_supported = false | ||
end | ||
|
||
# If we don't do this, the variable gets reset | ||
@ssg_report = { :data => nil } | ||
end | ||
|
||
it 'should run the SSG' do | ||
pending("SSG support for #{@os_str}") unless @ssg_supported | ||
|
||
profile = 'xccdf_org.ssgproject.content_profile_stig' | ||
|
||
@ssg.evaluate(profile) | ||
end | ||
|
||
it 'should have an SSG report' do | ||
pending("SSG support for #{@os_str}") unless @ssg_supported | ||
|
||
# Filter on records containing '_aide_' | ||
# This isn't perfect, but it should be partially OK | ||
@ssg_report[:data] = @ssg.process_ssg_results('rule_aide_') | ||
|
||
expect(@ssg_report[:data]).to_not be_nil | ||
|
||
@ssg.write_report(@ssg_report[:data]) | ||
end | ||
|
||
it 'should have run some tests' do | ||
pending("SSG support for #{@os_str}") unless @ssg_supported | ||
|
||
expect(@ssg_report[:data][:failed].count + @ssg_report[:data][:passed].count).to be > 0 | ||
end | ||
|
||
it 'should not have any failing tests' do | ||
pending("SSG support for #{@os_str}") unless @ssg_supported | ||
|
||
if @ssg_report[:data][:failed].count > 0 | ||
puts @ssg_report[:data][:report] | ||
end | ||
|
||
# TODO: See if we can get the SSG to update to a more reasonable set of checks | ||
pending('SSG Checks Getting Fixed') | ||
expect(@ssg_report[:data][:score]).to eq(100) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../nodesets |
39 changes: 39 additions & 0 deletions
39
spec/fixtures/inspec_profiles/CentOS-7-disa_stig/controls/00_Control_Selector.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
skips = { | ||
'V-71975' => "Skipping: No mail server is configured. SIMP-7220 ticket created" | ||
} | ||
overrides = [] | ||
subsystems = [ 'aide' ] | ||
|
||
require_controls 'disa_stig-el7-baseline' do | ||
skips.each_pair do |ctrl, reason| | ||
control ctrl do | ||
describe "Skip #{ctrl}" do | ||
skip "Reason: #{skips[ctrl]}" do | ||
end | ||
end | ||
end | ||
end | ||
|
||
@conf['profile'].info[:controls].each do |ctrl| | ||
next if (overrides + skips.keys).include?(ctrl[:id]) | ||
|
||
tags = ctrl[:tags] | ||
if tags && tags[:subsystems] | ||
subsystems.each do |subsystem| | ||
if tags[:subsystems].include?(subsystem) | ||
control ctrl[:id] | ||
end | ||
end | ||
end | ||
end | ||
|
||
## Overrides ## | ||
|
||
# # USEFUL DESCRIPTION | ||
# control 'V-IDENTIFIER' do | ||
# # Enhancement, leave this out if you just want to add a different test | ||
# overrides << self.to_s | ||
# | ||
# only_if { file('whatever').exist? } | ||
# end | ||
end |
14 changes: 14 additions & 0 deletions
14
spec/fixtures/inspec_profiles/CentOS-7-disa_stig/inspec.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: EL7 Aide STIG | ||
title: Aide STIG for EL 7 | ||
supports: | ||
- os-family: redhat | ||
maintainer: SIMP Team | ||
copyright: Onyx Point, Inc. | ||
copyright_email: [email protected] | ||
license: Apache-2.0 | ||
summary: | | ||
A collection of InSpec tests for the aide subsystem | ||
version: 0.0.1 | ||
depends: | ||
- name: disa_stig-el7-baseline | ||
path: ../../inspec_deps/inspec_profiles/profiles/disa_stig-el7-baseline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CentOS-7-disa_stig/ |