Skip to content

Commit 87a72ad

Browse files
committed
feat: audit feature
1 parent 64105d9 commit 87a72ad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4623
-8
lines changed

audit-specs/baselines/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Machine Baselines
2+
3+
This directory contains captured baselines from real machines.
4+
5+
## Generating a Baseline
6+
7+
On your target machine:
8+
```bash
9+
sudo nix run github:supabase/ubuntu-cis-audit#cis-generate-spec -- baseline.yaml
10+
```
11+
12+
## Naming Convention
13+
14+
Use descriptive names that identify the machine type or environment:
15+
- `production-db-baseline.yaml` - Production database server
16+
- `staging-api-baseline.yaml` - Staging API server
17+
- `postgres-baseline.yaml` - Standard PostgreSQL server config
18+
19+
## Using Baselines
20+
21+
Copy your baseline to this directory and commit to git. Then use GOSS to audit other machines:
22+
23+
```bash
24+
# On target machine
25+
goss --gossfile audit-specs/baselines/production-db-baseline.yaml validate
26+
```
27+
28+
## Baseline Sources
29+
30+
Document where each baseline came from:
31+
32+
- `postgres-baseline.yaml` - Generated from db-pdnxwzxvlrfwogpyaltm on 2025-11-22
33+
- `production-baseline.yaml` - Generated from prod-server-001 on 2025-11-20

audit-specs/cis_level1_server.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# CIS Ubuntu Level 1 Server Benchmark
2+
# Based on CIS Ubuntu 22.04 LTS Benchmark v1.0.0
3+
4+
file:
5+
/etc/ssh/sshd_config:
6+
exists: true
7+
mode: "0600"
8+
owner: root
9+
group: root
10+
contains:
11+
- "PermitRootLogin no"
12+
- "Protocol 2"
13+
14+
/etc/passwd:
15+
exists: true
16+
mode: "0644"
17+
owner: root
18+
group: root
19+
20+
/etc/shadow:
21+
exists: true
22+
mode: "0640"
23+
owner: root
24+
25+
/etc/login.defs:
26+
exists: true
27+
contains:
28+
- "/PASS_MIN_LEN\\s+14/"
29+
- "/PASS_MAX_DAYS\\s+90/"
30+
31+
package:
32+
aide:
33+
installed: true
34+
35+
xinetd:
36+
installed: false
37+
38+
service:
39+
ufw:
40+
enabled: true
41+
running: true
42+
43+
kernel-param:
44+
net.ipv4.ip_forward:
45+
value: 0
46+
47+
net.ipv6.conf.all.forwarding:
48+
value: 0
49+
50+
net.ipv4.conf.all.accept_source_route:
51+
value: 0
52+
53+
net.ipv4.conf.default.accept_source_route:
54+
value: 0
55+
56+
command:
57+
check-password-fields:
58+
exec: "awk -F: '($2 == \"\") {print}' /etc/shadow | wc -l"
59+
exit-status: 0
60+
stdout:
61+
- "0"
62+
63+
check-ufw-status:
64+
exec: "ufw status"
65+
exit-status: 0
66+
stdout:
67+
- "/Status: active/"

audit-specs/cis_level2_server.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# CIS Ubuntu Level 2 Server Benchmark
2+
# Based on CIS Ubuntu 22.04 LTS Benchmark v1.0.0
3+
# Includes all Level 1 checks plus additional Level 2 requirements
4+
5+
file:
6+
/etc/ssh/sshd_config:
7+
exists: true
8+
mode: "0600"
9+
owner: root
10+
group: root
11+
contains:
12+
- "PermitRootLogin no"
13+
- "Protocol 2"
14+
15+
/etc/passwd:
16+
exists: true
17+
mode: "0644"
18+
owner: root
19+
group: root
20+
21+
/etc/shadow:
22+
exists: true
23+
mode: "0640"
24+
owner: root
25+
26+
/etc/login.defs:
27+
exists: true
28+
contains:
29+
- "/PASS_MIN_LEN\\s+14/"
30+
- "/PASS_MAX_DAYS\\s+90/"
31+
32+
package:
33+
aide:
34+
installed: true
35+
36+
auditd:
37+
installed: true
38+
39+
xinetd:
40+
installed: false
41+
42+
service:
43+
ufw:
44+
enabled: true
45+
running: true
46+
47+
auditd:
48+
enabled: true
49+
running: true
50+
51+
kernel-param:
52+
net.ipv4.ip_forward:
53+
value: 0
54+
55+
net.ipv6.conf.all.forwarding:
56+
value: 0
57+
58+
net.ipv4.conf.all.accept_source_route:
59+
value: 0
60+
61+
net.ipv4.conf.default.accept_source_route:
62+
value: 0
63+
64+
command:
65+
check-password-fields:
66+
exec: "awk -F: '($2 == \"\") {print}' /etc/shadow | wc -l"
67+
exit-status: 0
68+
stdout:
69+
- "0"
70+
71+
check-ufw-status:
72+
exec: "ufw status"
73+
exit-status: 0
74+
stdout:
75+
- "/Status: active/"

nix/apps.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
run-testinfra = mkApp "run-testinfra" "run-testinfra";
2828
cleanup-ami = mkApp "cleanup-ami" "cleanup-ami";
2929
trigger-nix-build = mkApp "trigger-nix-build" "trigger-nix-build";
30+
cis-audit = mkApp "cis-audit" "cis-audit";
31+
cis-generate-spec = mkApp "cis-generate-spec" "cis-generate-spec";
32+
ansible-to-goss = mkApp "ansible-to-goss" "ansible-to-goss";
3033
};
3134
};
3235
}

nix/checks.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@
394394
dbmate-tool
395395
packer
396396
pg_regress
397+
goss
398+
cis-audit
399+
cis-generate-spec
400+
ansible-to-goss
397401
;
398402
}
399403
// pkgs.lib.optionalAttrs (system == "aarch64-linux") {

nix/devShells.nix

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
self'.packages.build-test-ami
5656
self'.packages.run-testinfra
5757
self'.packages.cleanup-ami
58+
self'.packages.cis-audit
59+
self'.packages.cis-generate-spec
60+
self'.packages.ansible-to-goss
61+
self'.packages.goss
5862
dbmate
5963
nushell
6064
pythonEnv

nix/ext/versions.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -572,14 +572,6 @@
572572
}
573573
},
574574
"wrappers": {
575-
"0.3.0": {
576-
"postgresql": [
577-
"15"
578-
],
579-
"hash": "sha256-ogpF8NJ7kW3Ut8jaKMDiKYIXnI38nfRq2mMK4rqFAIA=",
580-
"pgrx": "0.11.3",
581-
"rust": "1.76.0"
582-
},
583575
"0.4.1": {
584576
"postgresql": [
585577
"15"

0 commit comments

Comments
 (0)