Debian Codegraph @

tests/DS/signed/all.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 . $builddir/tests/test_common.sh
4 set -e -o pipefail
5
6 echoscip-shell system . . echo. "Test a signed SCAP source data stream with a valid signature"
7 stdout=$(mktempscip-shell system . . mktemp.)
8 stderr=$(mktempscip-shell system . . mktemp.)
9 verbose=$(mktempscip-shell system . . mktemp.)
10 result=$(mktempscip-shell system . . mktemp.)
11 $OSCAP xccdf eval --verbose INFO --verbose-log-file $verbose --results-arf $result $srcdir/simple_ds_valid_sign.xml >$stdout 2>$stderr
12 ! [scip-shell system . . `[`. -s $stderr ]
13 grepscip-shell system . . grep. -q "XML signature is valid." $stdout
14 grepscip-shell system . . grep. -q "Validating XML signature" $verbose
15 grepscip-shell system . . grep. -q "Signature is OK" $verbose
16 grepscip-shell system . . grep. -q "SignedInfo references (ok/all): 3/3" $verbose
17 grepscip-shell system . . grep. -q "Manifests references (ok/all): 2/2" $verbose
18 assert_exists 1 '//TestResult/rule-result[@idref="xccdf_com.example.www_rule_test-pass"]/result[text()="pass"]'
19 rmscip-shell system . . rm. -f $stdout
20 rmscip-shell system . . rm. -f $stderr
21 rmscip-shell system . . rm. -f $verbose
22 rmscip-shell system . . rm. -f $result
23
24 echoscip-shell system . . echo. "Test a signed SCAP source data stream with an invalid signature"
25 stdout=$(mktempscip-shell system . . mktemp.)
26 stderr=$(mktempscip-shell system . . mktemp.)
27 verbose=$(mktempscip-shell system . . mktemp.)
28 result=$(mktempscip-shell system . . mktemp.)
29 $OSCAP xccdf eval --verbose INFO --verbose-log-file $verbose --results-arf $result $srcdir/simple_ds_invalid_sign.xml >$stdout 2>$stderr || ret=$?
30 [scip-shell system . . `[`. $ret = 1 ]
31 [scip-shell system . . `[`. -s $stderr ]
32 ! [scip-shell system . . `[`. -s $result ]
33 ! grepscip-shell system . . grep. -q "XML signature is valid." $stdout
34 grepscip-shell system . . grep. -q "OpenSCAP Error: Invalid signature in SCAP Source Datastream (1.3) content in $srcdir/simple_ds_invalid_sign.xml" $stderr
35 grepscip-shell system . . grep. -q "Validating XML signature" $verbose
36 grepscip-shell system . . grep. -q "Signature is invalid" $verbose
37 grepscip-shell system . . grep. -q "SignedInfo references (ok/all): 3/3" $verbose
38 grepscip-shell system . . grep. -q "Manifests references (ok/all): 2/2" $verbose
39 rmscip-shell system . . rm. -f $stdout
40 rmscip-shell system . . rm. -f $stderr
41 rmscip-shell system . . rm. -f $verbose
42 rmscip-shell system . . rm. -f $result
43
44 echoscip-shell system . . echo. "Test skipping signature validation on a signed SCAP source data stream with an invalid signature"
45 stdout=$(mktempscip-shell system . . mktemp.)
46 stderr=$(mktempscip-shell system . . mktemp.)
47 verbose=$(mktempscip-shell system . . mktemp.)
48 result=$(mktempscip-shell system . . mktemp.)
49 $OSCAP xccdf eval --verbose INFO --verbose-log-file $verbose --skip-signature-validation --results-arf $result $srcdir/simple_ds_invalid_sign.xml >$stdout 2>$stderr
50 ! [scip-shell system . . `[`. -s $stderr ]
51 ! grepscip-shell system . . grep. -q "XML signature is valid." $stdout
52 ! grepscip-shell system . . grep. -q "Validating XML signature" $verbose
53 assert_exists 1 '//TestResult/rule-result[@idref="xccdf_com.example.www_rule_test-pass"]/result[text()="pass"]'
54 rmscip-shell system . . rm. -f $stdout
55 rmscip-shell system . . rm. -f $stderr
56 rmscip-shell system . . rm. -f $verbose
57 rmscip-shell system . . rm. -f $result
58
59 echoscip-shell system . . echo. "Test a signed SCAP source data stream with modified SCAP content"
60 stdout=$(mktempscip-shell system . . mktemp.)
61 stderr=$(mktempscip-shell system . . mktemp.)
62 verbose=$(mktempscip-shell system . . mktemp.)
63 result=$(mktempscip-shell system . . mktemp.)
64 $OSCAP xccdf eval --verbose INFO --verbose-log-file $verbose --results-arf $result $srcdir/simple_ds_modified.xml >$stdout 2>$stderr || ret=$?
65 [scip-shell system . . `[`. $ret = 1 ]
66 [scip-shell system . . `[`. -s $stderr ]
67 ! [scip-shell system . . `[`. -s $result ]
68 ! grepscip-shell system . . grep. -q "XML signature is valid." $stdout
69 grepscip-shell system . . grep. -q "OpenSCAP Error: Invalid signature in SCAP Source Datastream (1.3) content in $srcdir/simple_ds_modified.xml" $stderr
70 grepscip-shell system . . grep. -q "Validating XML signature" $verbose
71 grepscip-shell system . . grep. -q "Signature is OK" $verbose
72 grepscip-shell system . . grep. -q "SignedInfo references (ok/all): 3/3" $verbose
73 grepscip-shell system . . grep. -q "Manifests references (ok/all): 1/2" $verbose
74 rmscip-shell system . . rm. -f $stdout
75 rmscip-shell system . . rm. -f $stderr
76 rmscip-shell system . . rm. -f $verbose
77 rmscip-shell system . . rm. -f $result
78
79 echoscip-shell system . . echo. "Test an unsigned SCAP source data stream (with signature enforced)"
80 stdout=$(mktempscip-shell system . . mktemp.)
81 stderr=$(mktempscip-shell system . . mktemp.)
82 verbose=$(mktempscip-shell system . . mktemp.)
83 result=$(mktempscip-shell system . . mktemp.)
84 $OSCAP xccdf eval --verbose INFO --verbose-log-file $verbose --enforce-signature --results-arf $result $srcdir/simple_ds_no_sign.xml >$stdout 2>$stderr || ret=$?
85 [scip-shell system . . `[`. $ret = 1 ]
86 [scip-shell system . . `[`. -s $stderr ]
87 ! grepscip-shell system . . grep. -q "XML signature is valid." $stdout
88 grepscip-shell system . . grep. -q "OpenSCAP Error: Signature not found" $stderr
89 grepscip-shell system . . grep. -q "Validating XML signature" $verbose
90 rmscip-shell system . . rm. -f $stdout
91 rmscip-shell system . . rm. -f $stderr
92 rmscip-shell system . . rm. -f $verbose
93 rmscip-shell system . . rm. -f $result
94
95 echoscip-shell system . . echo. "Test a security guide generation from a signed SCAP source data stream with a valid signature"
96 stdout=$(mktempscip-shell system . . mktemp.)
97 stderr=$(mktempscip-shell system . . mktemp.)
98 verbose=$(mktempscip-shell system . . mktemp.)
99 html_guide=$(mktempscip-shell system . . mktemp.)
100 $OSCAP xccdf generate guide --verbose INFO --verbose-log-file $verbose --output $html_guide $srcdir/simple_ds_valid_sign.xml >$stdout 2>$stderr
101 ! [scip-shell system . . `[`. -s $stderr ]
102 grepscip-shell system . . grep. -q "XML signature is valid." $stdout
103 grepscip-shell system . . grep. -q "Validating XML signature" $verbose
104 grepscip-shell system . . grep. -q "Signature is OK" $verbose
105 grepscip-shell system . . grep. -q "SignedInfo references (ok/all): 3/3" $verbose
106 grepscip-shell system . . grep. -q "Manifests references (ok/all): 2/2" $verbose
107 grepscip-shell system . . grep. -q "<!DOCTYPE[^>]*html[^>]*>" $html_guide
108 rmscip-shell system . . rm. -f $stdout
109 rmscip-shell system . . rm. -f $stderr
110 rmscip-shell system . . rm. -f $verbose
111 rmscip-shell system . . rm. -f $html_guide
112
113 echoscip-shell system . . echo. "Test a security guide generation from a signed SCAP source data stream with an invalid signature"
114 stdout=$(mktempscip-shell system . . mktemp.)
115 stderr=$(mktempscip-shell system . . mktemp.)
116 verbose=$(mktempscip-shell system . . mktemp.)
117 html_guide=$(mktempscip-shell system . . mktemp.)
118 $OSCAP xccdf generate guide --verbose INFO --verbose-log-file $verbose --output $html_guide $srcdir/simple_ds_invalid_sign.xml >$stdout 2>$stderr || ret=$?
119 [scip-shell system . . `[`. $ret = 1 ]
120 [scip-shell system . . `[`. -s $stderr ]
121 ! [scip-shell system . . `[`. -s $html_guide ]
122 ! grepscip-shell system . . grep. -q "XML signature is valid." $stdout
123 grepscip-shell system . . grep. -q "OpenSCAP Error: Invalid signature in SCAP Source Datastream (1.3) content in $srcdir/simple_ds_invalid_sign.xml" $stderr
124 grepscip-shell system . . grep. -q "Validating XML signature" $verbose
125 grepscip-shell system . . grep. -q "Signature is invalid" $verbose
126 grepscip-shell system . . grep. -q "SignedInfo references (ok/all): 3/3" $verbose
127 grepscip-shell system . . grep. -q "Manifests references (ok/all): 2/2" $verbose
128 rmscip-shell system . . rm. -f $stdout
129 rmscip-shell system . . rm. -f $stderr
130 rmscip-shell system . . rm. -f $verbose
131 rmscip-shell system . . rm. -f $html_guide
132
133 echoscip-shell system . . echo. "Test skipping signature validation on a security guide generation from a signed SCAP source data stream with an invalid signature"
134 stdout=$(mktempscip-shell system . . mktemp.)
135 stderr=$(mktempscip-shell system . . mktemp.)
136 verbose=$(mktempscip-shell system . . mktemp.)
137 html_guide=$(mktempscip-shell system . . mktemp.)
138 $OSCAP xccdf generate guide --verbose INFO --verbose-log-file $verbose --skip-signature-validation --output $html_guide $srcdir/simple_ds_invalid_sign.xml >$stdout 2>$stderr
139 ! [scip-shell system . . `[`. -s $stderr ]
140 ! grepscip-shell system . . grep. -q "XML signature is valid." $stdout
141 ! grepscip-shell system . . grep. -q "Validating XML signature" $verbose
142 grepscip-shell system . . grep. -q "<!DOCTYPE[^>]*html[^>]*>" $html_guide
143 rmscip-shell system . . rm. -f $stdout
144 rmscip-shell system . . rm. -f $stderr
145 rmscip-shell system . . rm. -f $verbose
146 rmscip-shell system . . rm. -f $html_guide
147
148 echoscip-shell system . . echo. "Test a security guide generation from an unsigned SCAP source data stream (with signature enforced)"
149 stdout=$(mktempscip-shell system . . mktemp.)
150 stderr=$(mktempscip-shell system . . mktemp.)
151 verbose=$(mktempscip-shell system . . mktemp.)
152 html_guide=$(mktempscip-shell system . . mktemp.)
153 $OSCAP xccdf generate guide --verbose INFO --verbose-log-file $verbose --enforce-signature --output $html_guide $srcdir/simple_ds_no_sign.xml >$stdout 2>$stderr || ret=$?
154 [scip-shell system . . `[`. $ret = 1 ]
155 [scip-shell system . . `[`. -s $stderr ]
156 ! [scip-shell system . . `[`. -s $html_guide ]
157 ! grepscip-shell system . . grep. -q "XML signature is valid." $stdout
158 grepscip-shell system . . grep. -q "OpenSCAP Error: Signature not found" $stderr
159 grepscip-shell system . . grep. -q "Validating XML signature" $verbose
160 rmscip-shell system . . rm. -f $stdout
161 rmscip-shell system . . rm. -f $stderr
162 rmscip-shell system . . rm. -f $verbose
163 rmscip-shell system . . rm. -f $html_guide
164
165 echoscip-shell system . . echo. "Test a fix generation from a signed SCAP source data stream with a valid signature"
166 stdout=$(mktempscip-shell system . . mktemp.)
167 stderr=$(mktempscip-shell system . . mktemp.)
168 verbose=$(mktempscip-shell system . . mktemp.)
169 fix_script=$(mktempscip-shell system . . mktemp.)
170 $OSCAP xccdf generate fix --verbose INFO --verbose-log-file $verbose --fix-type bash --output $fix_script $srcdir/simple_ds_valid_sign.xml >$stdout 2>$stderr
171 ! [scip-shell system . . `[`. -s $stderr ]
172 grepscip-shell system . . grep. -q "XML signature is valid." $stdout
173 grepscip-shell system . . grep. -q "Validating XML signature" $verbose
174 grepscip-shell system . . grep. -q "Signature is OK" $verbose
175 grepscip-shell system . . grep. -q "SignedInfo references (ok/all): 3/3" $verbose
176 grepscip-shell system . . grep. -q "Manifests references (ok/all): 2/2" $verbose
177 grepscip-shell system . . grep. -q "#!\(/usr\)\?/bin/\(env \)\?bash" $fix_script
178 rmscip-shell system . . rm. -f $stdout
179 rmscip-shell system . . rm. -f $stderr
180 rmscip-shell system . . rm. -f $verbose
181 rmscip-shell system . . rm. -f $fix_script
182
183 echoscip-shell system . . echo. "Test a fix generation from a signed SCAP source data stream with an invalid signature"
184 stdout=$(mktempscip-shell system . . mktemp.)
185 stderr=$(mktempscip-shell system . . mktemp.)
186 verbose=$(mktempscip-shell system . . mktemp.)
187 fix_script=$(mktempscip-shell system . . mktemp.)
188 $OSCAP xccdf generate fix --verbose INFO --verbose-log-file $verbose --fix-type bash --output $fix_script $srcdir/simple_ds_invalid_sign.xml >$stdout 2>$stderr || ret=$?
189 [scip-shell system . . `[`. $ret = 1 ]
190 [scip-shell system . . `[`. -s $stderr ]
191 ! [scip-shell system . . `[`. -s $fix_script ]
192 ! grepscip-shell system . . grep. -q "XML signature is valid." $stdout
193 grepscip-shell system . . grep. -q "OpenSCAP Error: Invalid signature in SCAP Source Datastream (1.3) content in $srcdir/simple_ds_invalid_sign.xml" $stderr
194 grepscip-shell system . . grep. -q "Validating XML signature" $verbose
195 grepscip-shell system . . grep. -q "Signature is invalid" $verbose
196 grepscip-shell system . . grep. -q "SignedInfo references (ok/all): 3/3" $verbose
197 grepscip-shell system . . grep. -q "Manifests references (ok/all): 2/2" $verbose
198 rmscip-shell system . . rm. -f $stdout
199 rmscip-shell system . . rm. -f $stderr
200 rmscip-shell system . . rm. -f $verbose
201 rmscip-shell system . . rm. -f $fix_script
202
203 echoscip-shell system . . echo. "Test skipping signature validation on a fix generation from a signed SCAP source data stream with an invalid signature"
204 stdout=$(mktempscip-shell system . . mktemp.)
205 stderr=$(mktempscip-shell system . . mktemp.)
206 verbose=$(mktempscip-shell system . . mktemp.)
207 fix_script=$(mktempscip-shell system . . mktemp.)
208 $OSCAP xccdf generate fix --verbose INFO --verbose-log-file $verbose --skip-signature-validation --fix-type bash --output $fix_script $srcdir/simple_ds_invalid_sign.xml >$stdout 2>$stderr
209 ! [scip-shell system . . `[`. -s $stderr ]
210 ! grepscip-shell system . . grep. -q "XML signature is valid." $stdout
211 ! grepscip-shell system . . grep. -q "Validating XML signature" $verbose
212 grepscip-shell system . . grep. -q "#!\(/usr\)\?/bin/\(env \)\?bash" $fix_script
213 rmscip-shell system . . rm. -f $stdout
214 rmscip-shell system . . rm. -f $stderr
215 rmscip-shell system . . rm. -f $verbose
216 rmscip-shell system . . rm. -f $fix_script
217
218 echoscip-shell system . . echo. "Test a fix generation from an unsigned SCAP source data stream (with signature enforced)"
219 stdout=$(mktempscip-shell system . . mktemp.)
220 stderr=$(mktempscip-shell system . . mktemp.)
221 verbose=$(mktempscip-shell system . . mktemp.)
222 fix_script=$(mktempscip-shell system . . mktemp.)
223 $OSCAP xccdf generate fix --verbose INFO --verbose-log-file $verbose --enforce-signature --fix-type bash --output $fix_script $srcdir/simple_ds_no_sign.xml >$stdout 2>$stderr || ret=$?
224 [scip-shell system . . `[`. $ret = 1 ]
225 [scip-shell system . . `[`. -s $stderr ]
226 ! [scip-shell system . . `[`. -s $fix_script ]
227 ! grepscip-shell system . . grep. -q "XML signature is valid." $stdout
228 grepscip-shell system . . grep. -q "OpenSCAP Error: Signature not found" $stderr
229 grepscip-shell system . . grep. -q "Validating XML signature" $verbose
230 rmscip-shell system . . rm. -f $stdout
231 rmscip-shell system . . rm. -f $stderr
232 rmscip-shell system . . rm. -f $verbose
233 rmscip-shell system . . rm. -f $fix_script