-
-
Notifications
You must be signed in to change notification settings - Fork 274
/
Copy pathfstab.bats
209 lines (168 loc) · 5.91 KB
/
fstab.bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/usr/bin/env bats
load test_helper
@test "Ensure a floppy is not present in /etc/fstab" {
run bash -c "grep floppy /etc/fstab"
[ "$status" -eq 1 ]
}
@test "Ensure a floppy is not mounted" {
run bash -c "grep floppy /proc/mounts"
[ "$status" -eq 1 ]
}
@test "Ensure /tmp is not present in /etc/fstab" {
run bash -c "grep -e '[[:space:]]/tmp[[:space:]]' /etc/fstab"
[ "$status" -eq 1 ]
}
@test "Verify that tmp.mount is enabled" {
run bash -c "systemctl is-enabled tmp.mount"
[ "$status" -eq 0 ]
}
@test "Verify /tmp nodev option" {
tmpMount=$(fragmentPath tmp.mount)
run bash -c "grep '^Options=.*nodev.*' $tmpMount"
[ "$status" -eq 0 ]
}
@test "Verify /tmp nosuid option" {
tmpMount=$(fragmentPath tmp.mount)
run bash -c "grep '^Options=.*nosuid.*' $tmpMount"
[ "$status" -eq 0 ]
}
@test "Verify /tmp noexec option" {
tmpMount=$(fragmentPath tmp.mount)
run bash -c "grep '^Options=.*noexec.*' $tmpMount"
[ "$status" -eq 0 ]
}
@test "Verify /var/tmp nodev option" {
varTmpMount=$(fragmentPath var-tmp.mount)
run bash -c "grep '^Options=.*nodev.*' $varTmpMount"
[ "$status" -eq 0 ]
}
@test "Verify /var/tmp nosuid option" {
varTmpMount=$(fragmentPath var-tmp.mount)
run bash -c "grep '^Options=.*nosuid.*' $varTmpMount"
[ "$status" -eq 0 ]
}
@test "Verify /var/tmp noexec option" {
varTmpMount=$(fragmentPath var-tmp.mount)
run bash -c "grep '^Options=.*noexec.*' $varTmpMount"
[ "$status" -eq 0 ]
}
@test "Verify that /var/tmp is mounted with nodev" {
run bash -c "grep '[[:space:]]/var/tmp[[:space:]].*nodev.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /var/tmp is mounted with nosuid" {
run bash -c "grep '[[:space:]]/var/tmp[[:space:]].*nosuid.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /var/tmp is mounted with noexec" {
run bash -c "grep '[[:space:]]/var/tmp[[:space:]].*noexec.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /tmp is mounted with nodev" {
run bash -c "grep '[[:space:]]/tmp[[:space:]].*nodev.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /tmp is mounted with nosuid" {
run bash -c "grep '[[:space:]]/tmp[[:space:]].*nosuid.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /tmp is mounted with noexec" {
run bash -c "grep '[[:space:]]/tmp[[:space:]].*noexec.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /boot is a separate partition" {
run bash -c "grep '[[:space:]]/boot[[:space:]]' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /boot is mounted with nodev" {
run bash -c "grep '[[:space:]]/boot[[:space:]].*nodev.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /boot is mounted with nosuid" {
run bash -c "grep '[[:space:]]/boot[[:space:]].*nosuid.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /home is a separate partition" {
run bash -c "grep '[[:space:]]/home[[:space:]]' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /home is mounted with nodev" {
run bash -c "grep '[[:space:]]/home[[:space:]].*nodev.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /home is mounted with nosuid" {
run bash -c "grep '[[:space:]]/home[[:space:]].*nosuid.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /var/log/audit is a separate partition" {
run bash -c "grep '[[:space:]]/var/log/audit[[:space:]]' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /var/log/audit is mounted with nodev" {
run bash -c "grep '[[:space:]]/var/log/audit[[:space:]].*nodev.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /var/log/audit is mounted with nosuid" {
run bash -c "grep '[[:space:]]/var/log/audit[[:space:]].*nosuid.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /var/log/audit is mounted with noexec" {
run bash -c "grep '[[:space:]]/var/log/audit[[:space:]].*noexec.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /var/log is a separate partition" {
run bash -c "grep '[[:space:]]/var/log[[:space:]]' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /var/log is mounted with nodev" {
run bash -c "grep '[[:space:]]/var/log[[:space:]].*nodev.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /var/log is mounted with nosuid" {
run bash -c "grep '[[:space:]]/var/log[[:space:]].*nosuid.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /var/log is mounted with noexec" {
run bash -c "grep '[[:space:]]/var/log[[:space:]].*noexec.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /proc is mounted with nodev" {
run bash -c "grep '[[:space:]]/proc[[:space:]].*nodev.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /proc is mounted with nosuid" {
run bash -c "grep '[[:space:]]/proc[[:space:]].*nosuid.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /proc is mounted with noexec" {
run bash -c "grep '[[:space:]]/proc[[:space:]].*noexec.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /proc is mounted with hidepid" {
run bash -c "grep '[[:space:]]/proc[[:space:]].*hidepid=.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /dev/shm is mounted with nodev" {
run bash -c "grep '[[:space:]]/dev/shm[[:space:]].*nodev.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /dev/shm is mounted with nosuid" {
run bash -c "grep '[[:space:]]/dev/shm[[:space:]].*nosuid.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /dev/shm is mounted with noexec" {
run bash -c "grep '[[:space:]]/dev/shm[[:space:]].*noexec.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /run/shm is mounted with nodev" {
run bash -c "grep '[[:space:]]/run/shm[[:space:]].*nodev.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /run/shm is mounted with nosuid" {
run bash -c "grep '[[:space:]]/run/shm[[:space:]].*nosuid.*' /proc/mounts"
[ "$status" -eq 0 ]
}
@test "Verify that /run/shm is mounted with noexec" {
run bash -c "grep '[[:space:]]/run/shm[[:space:]].*noexec.*' /proc/mounts"
[ "$status" -eq 0 ]
}