Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework auditd_rules resource #312

Closed
arlimus opened this issue Dec 10, 2015 · 3 comments
Closed

rework auditd_rules resource #312

arlimus opened this issue Dec 10, 2015 · 3 comments
Labels
Aspect: Docs Write the Fine Manual Type: Bug Feature not working as expected
Milestone

Comments

@arlimus
Copy link
Contributor

arlimus commented Dec 10, 2015

A typical use-case will have multiple rules listed. If we can find a better matcher than checking for a regex and also making giving the user nice output if the rule isn't found in the list. Let's find real-life LIST_RULES examples and use them for our docs. The current format may lead to confusion.

@arlimus arlimus added Type: Bug Feature not working as expected Aspect: Docs Write the Fine Manual labels Dec 10, 2015
@chris-rock chris-rock added this to the 0.9.10 milestone Jan 19, 2016
@chris-rock chris-rock modified the milestones: 0.9.11, 0.9.10 Jan 22, 2016
@srenatus srenatus changed the title auditd_rules LIST_RULES docs rework auditd_rules resource Jan 22, 2016
@srenatus
Copy link
Contributor

Currently, the resource just exposes the lines it reads. The user experience would be way better if this supported something handier.

I'd also propose renaming the resource to audit, e.g.:

describe audit.syscall('openat') do
  its('action') { should eq('always') }
  its('list') { should eq('exit') }
end

describe audit.file('/etc/passwd') do
  its('action') { should eq('always') }
  its('perms') { should match('.*w.*') }
end

@srenatus
Copy link
Contributor

Since there can be multiple rules relating to one syscall (or one file), I wonder what a good strategy for writing tests would be.

For example, two rules for open:

# auditctl -l
-a always,exit -F arch=b64 -S open -F success=0
-a always,exit -F arch=b64 -S open -F auid=1001

Now e.g. audit.syscall('open').rules could be

[
{ action: 'always', list: 'exit', fields: { arch: 'b64', success: 0 } },
{ action: 'always', list: 'exit', fields: { arch: 'b64', auid: 1001 } }
]

but then we cannot use RSpec's default include matcher, because it works with either Hashes or Arrays, not with Arrays of Hashes.

At the same time, we cannot use something like audit.syscall('open').actions, combining the separate rules, without losing information.

@chris-rock @arlimus: What's your take on this?

@arlimus
Copy link
Contributor Author

arlimus commented Jan 26, 2016

I fully agree with your assessment of multiple rules, especially the part about the include matcher and similar ones. We should find a better way to expose those. I also think it's conceptually similar to other areas that have multiple very similar looking lines (e.g. iptables to a limited degree).

Let's consider use-cases:

  • User wants to test if rules for syscall open exist; that could be done with auditd_rules.syscall('open').rules != empty
  • User wants to consider inter-field comparisons and see if rule exists or doesn't: auditd_rules.syscall('open').field('auid=1001').rules != empty or just add action to the mix; basically moving the complicated parts further up the chain into a resource qualifier, instead of the matcher

(^^ first thoughts, naming prone to change; but the idea is to further specify the resource for what we are interested in )

Naming: Imho audit can quickly be confused with other mechanisms, while auditd is very specific. Let's tackle that separately.

@chris-rock chris-rock modified the milestones: 0.9.12, 0.9.11, 0.9.13 Jan 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Aspect: Docs Write the Fine Manual Type: Bug Feature not working as expected
Projects
None yet
Development

No branches or pull requests

3 participants