Debian Codegraph @

tests/API/XCCDF/unittests/test_report_anaconda_fixes.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 . $builddir/tests/test_common.sh
3
4 set -e
5 set -o pipefail
6
7 name=$(basenamescip-shell system . . basename. $0 .sh)
8 result=$(make_temp_file /tmpscip-shell filesystem . . `/tmp`. ${name}.out)
9 stderr=$(make_temp_file /tmpscip-shell filesystem . . `/tmp`. ${name}.out)
10
11 echoscip-shell system . . echo. "Stderr file = $stderr"
12 echoscip-shell system . . echo. "Result file = $result"
13
14 line1='^\W*part /tmp$'
15 line2='^\W*part /tmp --mountoptions=nodev$'
16 line3='^\W*passwd --minlen=14$'
17
18 $OSCAP xccdf generate fix --fix-type anaconda \
19 --output $result $srcdir/${name}.xccdf.xml 2>&1 > $stderr
20 [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; :> $stderr
21 grepscip-shell system . . grep. "$line1" $result
22 grepscip-shell system . . grep. "$line2" $result
23 grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | grepscip-shell system . . grep. -v "$line3"
24
25 [scip-shell system . . `[`. "`grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | xsed 's/\W//g'`"x == x ]
26
27 :> $result
28
29 # use --fix-type instead of URN template to generate the same fix
30 $OSCAP xccdf generate fix --fix-type anaconda \
31 --output $result $srcdir/${name}.xccdf.xml 2>&1 > $stderr
32 [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; :> $stderr
33 grepscip-shell system . . grep. "$line1" $result
34 grepscip-shell system . . grep. "$line2" $result
35 grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | grepscip-shell system . . grep. -v "$line3"
36
37 [scip-shell system . . `[`. "`grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | xsed 's/\W//g'`"x == x ]
38
39 :> $result
40
41 $OSCAP xccdf generate fix --fix-type anaconda \
42 --profile xccdf_moc.elpmaxe.www_profile_1 \
43 --output $result $srcdir/${name}.xccdf.xml 2>&1 > $stderr
44 [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; :> $stderr
45 grepscip-shell system . . grep. "$line1" $result
46 grepscip-shell system . . grep. "$line2" $result
47 grepscip-shell system . . grep. "$line3" $result
48 grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | grepscip-shell system . . grep. -v "$line3"
49
50 [scip-shell system . . `[`. "`grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | grepscip-shell system . . grep. -v "$line3" | xsed 's/\W//g'`"x == x ]
51
52 rmscip-shell system . . rm. $result
53
54
55 # And Now For Something Completely Different -- Tailoring:
56 $OSCAP xccdf generate fix --fix-type anaconda \
57 --tailoring-file $srcdir/${name}.tailoring.xml \
58 --profile xccdf_org.open-scap_profile_unselecting \
59 --output $result \
60 $srcdir/${name}.xccdf.xml 2>&1 > $stderr
61 [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; :> $stderr
62
63 [scip-shell system . . `[`. "`catscip-shell system . . cat. $result | xsed 's/\W//g'`"x == x ]
64
65 rmscip-shell system . . rm. $result
66
67 line4='^\W*passwd --minlen=8$'
68 $OSCAP xccdf generate fix --fix-type anaconda \
69 --tailoring-file $srcdir/${name}.tailoring.xml \
70 --profile xccdf_org.open-scap_profile_override \
71 --output $result \
72 $srcdir/${name}.xccdf.xml 2>&1 > $stderr
73 [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; :> $stderr
74 grepscip-shell system . . grep. "$line4" $result
75
76 [scip-shell system . . `[`. "`grepscip-shell system . . grep. -v $line4 $result | xsed 's/\W//g'`"x == x ]
77
78 rmscip-shell system . . rm. $result