Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Adding missing tests from RHEL7 STIG v2r4 #113

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

cpoma
Copy link

@cpoma cpoma commented Oct 11, 2019

Adding: V-81009, V-81011, V-81013, V-81015, V-81017, V-81019, V-81021

@aaronlippold
Copy link
Member

It should be our first start that the tagging between r1v4 and r2v2

@trevor-vaughan
Copy link
Member

Could we add a tag that is an array of the STIG versions to which the check applies? That will make it easier to cull over time.

@cpoma cpoma force-pushed the missingTestsRHELSTIGv2R4 branch from 224fc0e to 9ea34a3 Compare October 24, 2019 14:31

describe mount('/dev/shm') do
its('options') { should include 'nodev' }
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This describe statement only takes into consideration what is currently mounted. It is important to indicate that would be mounted if DR happens (node bounces) and auto-mount procedures take place. We normally weight everything that is configurable upon 2 scales. 1) configuration (what happens when the node is rebooted) and 2) cached (what parameters/settings are currently affecting the node). I think in this case you should include the configuration settings. Here is what that would look like.

  describe etc_fstab.where { mount_point == '/dev/shm' } do
    it { should be_configured }
    its('mount_options.flatten') { should include 'nodev' }
  end

It is also important to note that /etc/mtab also indicates the status of a healthy system. It is wholly possible for mount to not indicate proper settings (unlikely, but possible). In that case you might want to take this file into consideration.

  describe etc_fstab('/etc/mtab') { mount_point == '/dev/shm' } do
    it { should be_configured }
    its('mount_options.flatten') { should include 'nodev' }
  end

The last possible location to look for 'proper working order' is /proc/mounts. Quote from the mount manual:

When the proc filesystem is mounted (say at /proc), the files /etc/mtab and /proc/mounts have very similar contents. The former has somewhat more information, such as the mount options used, but is not necessarily up-to-date.

It is also possible that you want to check the cached value in /proc/mounts in newer and newer OS versions due to the adoption of systemd *.mounts files.

Comment on lines +28 to +30
describe mount('/dev/shm') do
its('options') { should include 'nosuid' }
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, but using 'nosuid'

Comment on lines +28 to +30
describe mount('/dev/shm') do
its('options') { should include 'noexec' }
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


if file('/etc/audisp/plugins.d/au-remote.conf').exist?
describe parse_config_file('/etc/audisp/plugins.d/au-remote.conf') do
its('active') { should match %r{yes$} }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using regex here is a bit unneeded. You should trust the parse_config_file, or supply the regex (options + assignment_regex) to extract the exact piece you are looking for. In your case match %r{yes$} is unneeded. Use a more simpler approach, cmp 'yes'

Comment on lines +41 to +44
else
describe "File '/etc/audisp/plugins.d/au-remote.conf' cannot be found. This test cannot be checked in a automated fashion and you must check it manually" do
skip "File '/etc/audisp/plugins.d/au-remote.conf' cannot be found. This check must be performed manually"
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be interesting to see what additional behavior is acceptable, in this case. The STIG does not allow for additional behavior, so I am uncertain why you are coding manual review as optional. This appears to be a clear pass/fail check. I would remove the if/else control structure and just search for the file.

Now the question is, if what you are intending is valid. That is, are there secondary approved options. If this is the case, I would just say implement them here. Give an attribute in that control structure to require organizational documentation stating why this option is valid for their use case. In the end, I would say this is unneeded. What I would expect is exceptions, the likes of which you are allowing to be manually reviewed, to be overridden by organizational inheritance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree on this one. The STIG should be modeled exactly. There is no contingency for the file not being there. If it does not exist or does not contain the prescribed value this is a fail.

Comment on lines +52 to +56
describe parse_config_file('/etc/audisp/plugins.d/au-remote.conf') do
its('direction') { should match %r{out$} }
its('path') { should match %r{/sbin/audisp-remote$} }
its('type') { should match %r{always$} }
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above...

Plus, the STIG specifically calls out direction, path and type, as I see you have noticed and implemented. It also makes mention of type and format. As it wouldn't hurt to include these, for completeness I would implement them as well. This is only a suggestion and not a must. We normally ask that each control can stand alone. So, consider that 'V-81017' is not being used to audit the system.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean it also lists active and format. However, it only prescribes specific values for the three under test here. If there is no direction we can't arbitrarily supply values. Also, if you look at the text of the check they are using cat to show the contents of the file but only asking you to validate the three settings. The others are just incidental in the output from cat.

Comment on lines +58 to +60
describe "File '/etc/audisp/plugins.d/au-remote.conf' cannot be found. This test cannot be checked in a automated fashion and you must check it manually" do
skip "File '/etc/audisp/plugins.d/au-remote.conf' cannot be found. This check must be performed manually"
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as V-81015, this control structure is not needed.


if file('/etc/audisp/audispd.conf').exist?
describe parse_config_file('/etc/audisp/audispd.conf') do
its('overflow_action') { should match %r{syslog$|single$|halt$} }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be more clear to use arrays here vs regex.

its('overflow_action') { should be_in %w(syslog single halt) }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this control also needs to check if the line is commented out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the parse_config_file resource act when the line is commented out and you attempt to match a value? Does it just return null? What the STIG does not say explicitly is that if it is not present at all this is a finding but I'd say we can infer that from the spirit of this control. Therefore, if checking for a value its('param') returns null we can assume that it is either some other value, it's commented out or simply not present. In any case the output will likewise indicate its actual value or the fact that it is null. All of which are findings. I don't see a reason to check for specific cases when we've already effectively accounted for them.

Comment on lines +46 to +48
describe "File '/etc/audisp/audispd.conf' cannot be found. This test cannot be checked in a automated fashion and you must check it manually" do
skip "File '/etc/audisp/audispd.conf' cannot be found. This check must be performed manually"
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above...unneeded control structure.

Comment on lines +47 to +49
describe "File '/etc/audisp/audispd.conf' cannot be found. This test cannot be checked in a automated fashion and you must check it manually" do
skip "File '/etc/audisp/audispd.conf' cannot be found. This check must be performed manually"
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above....unneeded control structure.

@aaronlippold
Copy link
Member

aaronlippold commented Oct 31, 2019 via email

@kevin-j-smith
Copy link

Yep we internally had to restrict to 4.16 or below.

@aaronlippold
Copy link
Member

aaronlippold commented Oct 31, 2019 via email

@aaronlippold aaronlippold requested a review from djhaynes November 5, 2019 16:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants