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

Allow exe exclude rules #97

Merged
merged 6 commits into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ fi
SCRIPT

Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.box = "ubuntu/impish64"
config.vm.network :forwarded_port, guest: 22, host: 2228, id: "ssh", auto_correct: true
config.vm.provision "shell", inline: create_symlink, privileged: false
config.vm.provision "shell", inline: install_gvm, privileged: false
config.vm.provision "shell", inline: "apt-get update && apt-get install -y make gcc python3 python3-pip python3-venv git"
config.vm.provision "shell", inline: "apt-get update && apt-get install -y make gcc python3 python3-pip python3-venv git auditd"
config.vm.provision "shell", inline: "systemctl stop auditd"
config.vm.provision "shell", inline: "systemctl disable auditd"
end
8 changes: 6 additions & 2 deletions rule/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,12 @@ func (d ruleData) toAuditRuleData() (*auditRuleData, error) {
}

if d.allSyscalls {
for i := 0; i < len(rule.Mask)-1; i++ {
for i := range rule.Mask {
efd6 marked this conversation as resolved.
Show resolved Hide resolved
rule.Mask[i] = 0xFFFFFFFF
}
// NOTE: This was added to match the binary output when listing rules
// from the kernel.
efd6 marked this conversation as resolved.
Show resolved Hide resolved
rule.Mask[len(rule.Mask)-1] = 0x0000FFFF
} else {
for _, syscallNum := range d.syscalls {
word := syscallNum / 32
Expand Down Expand Up @@ -622,7 +625,8 @@ func addFilter(rule *ruleData, lhs, comparator, rhs string) error {
switch field {
case pidField, uidField, gidField, auidField, msgTypeField,
subjectUserField, subjectRoleField, subjectTypeField,
subjectSensitivityField, subjectClearanceField:
subjectSensitivityField, subjectClearanceField,
exeField, pathField, dirField:
andrewkroh marked this conversation as resolved.
Show resolved Hide resolved
default:
return errors.Errorf("field '%v' cannot be used the exclude flag", lhs)
}
Expand Down
8 changes: 5 additions & 3 deletions rule/testdata/20-dont-audit.rules
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
## This is for don't audit rules. We put these early because audit
### is a first match wins system. Uncomment the rules you want.
## is a first match wins system. Uncomment the rules you want.

## Cron jobs fill the logs with stuff we normally don't want
-a never,user -F subj_type=crond_t

## This prevents chrony from overwhelming the logs
-a never,exit -F arch=x86_64 -S adjtimex -F auid=unset -F uid=20 -F subj_type=chronyd_t

### This is not very interesting and wastes a lot of space if
### the server is public facing
## This is not very interesting and wastes a lot of space if
## the server is public facing
-a always,exclude -F msgtype=CRYPTO_KEY_USER

## Filter syscall events for ls.
-a exclude,always -F exe=/bin/ls
andrewkroh marked this conversation as resolved.
Show resolved Hide resolved
30 changes: 26 additions & 4 deletions rule/testdata/20-dont-audit.rules.golden.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Linux dd81ed8942a5 4.9.27-moby #1 SMP Thu May 11 04:01:18 UTC 2017 x86_64 GNU/Linux
# auditctl version 2.6.7
# Linux ubuntu-impish 5.13.0-27-generic #29-Ubuntu SMP Wed Jan 12 17:36:47 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
# auditctl version 3.0
rules:
- flags: -a never,user -F subj_type=crond_t
bytes: !!binary |
Expand All @@ -8,7 +8,7 @@ rules:
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//AAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
////8AAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Expand Down Expand Up @@ -53,7 +53,7 @@ rules:
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//AAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
////8AAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Expand All @@ -68,3 +68,25 @@ rules:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
- flags: -a exclude,always -F exe=/bin/ls
bytes: !!binary |
BQAAAAIAAAABAAAA//////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
////8AAHAAAAAAAA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AAAAAAcAAAAvYmluL2xzAA==
4 changes: 2 additions & 2 deletions rule/testdata/22-ignore-chrony.rules.golden.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Linux dd81ed8942a5 4.9.27-moby #1 SMP Thu May 11 04:01:18 UTC 2017 x86_64 GNU/Linux
# auditctl version 2.6.7
# Linux ubuntu-impish 5.13.0-27-generic #29-Ubuntu SMP Wed Jan 12 17:36:47 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
# auditctl version 3.0
rules:
- flags: -a never,exit -F arch=b64 -S adjtimex -F auid=unset -F uid=20 -F subj_type=chronyd_t
bytes: !!binary |
Expand Down
Loading