Skip to content

Add resource type linux_audit_system - #527

Merged
mizzy merged 4 commits into
mizzy:masterfrom
aschmidt75:master
Aug 8, 2015
Merged

Add resource type linux_audit_system#527
mizzy merged 4 commits into
mizzy:masterfrom
aschmidt75:master

Conversation

@aschmidt75

Copy link
Copy Markdown
Contributor

Allow checking the configuration of linux audit system via /sbin/auditctl. Suitable for server hardening.

be_running

To make sure that the audit system is running.

describe linux_audit_system do
  it { should be_running }
end

be_enabled

To make sure that the audit system is enabled (mode '1').

describe linux_audit_system do
  it { should be_enabled }
end

have_audit_rule

To check that auditd has a given auditing rule. Argument can be a string for equality comparison or a regular expression.

describe linux_audit_system do
  it { should have_audit_rule '-w /etc/audit/ -p wa' }
  it { should have_audit_rule '-w /var/lib/ -p wa' }
  it { should have_audit_rule /\/var\/lib\// }
  it { should_not have_audit_rule /\/var\/log\// }
end

@mizzy

mizzy commented Aug 5, 2015

Copy link
Copy Markdown
Owner

Thanks!

I think have_audit_rule is not needed. It can be substituted like this.

describe linux_audit_system do
  its(:rules) { should include '-w /etc/audit/ -p wa' }
  its(:rules) { should include '-w /var/lib/ -p wa' }
  its(:rules) { should include %r!/var/lib/! }
  its(:rules) { should_not include %r!/var/log! }
end

We should use standard RSpec matchers as much as we can.

And tests failed in Ruby 1.8.7. Please fix this.
https://travis-ci.org/mizzy/serverspec/builds/74105963

@aschmidt75

Copy link
Copy Markdown
Contributor Author

Thanks for the hints, implemented it as suggested, 1.8.7 is ok now.

rules

To check that auditd has a given auditing rule. Argument can be a string for equality comparison or a regular expression.

describe linux_audit_system do
  its(:rules) { should include '-w /etc/audit/ -p wa' }
  its(:rules) { should include '-w /var/lib/ -p wa' }
  its(:rules) { should include %r!/var/lib/! }
  its(:rules) { should_not include %r!/var/log! }
end

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This should be a public method.

@mizzy

mizzy commented Aug 8, 2015

Copy link
Copy Markdown
Owner

LGTM!

mizzy added a commit that referenced this pull request Aug 8, 2015
Add resource type linux_audit_system
@mizzy
mizzy merged commit 8139e84 into mizzy:master Aug 8, 2015
@mizzy

mizzy commented Aug 8, 2015

Copy link
Copy Markdown
Owner

Released as v2.21.0.

@aschmidt75

Copy link
Copy Markdown
Contributor Author

Great, thanks for merging! I'm going to provide docs within the next days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants