| 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 _ds.sh) |
| 8 | xccdf=${name}.xccdf.xml |
| 9 | sds=$(make_temp_file /tmpscip-shell filesystem . . `/tmp`. ${name}.sds) |
| 10 | stderr=$(make_temp_file /tmpscip-shell filesystem . . `/tmp`. ${name}_ds.err) |
| 11 | result=$(make_temp_file /tmpscip-shell filesystem . . `/tmp`. ${name}_ds.out) |
| 12 | cpscip-shell system . . cp. $srcdir/test_report_anaconda_fixes.sds.xml $sds |
| 13 | |
| 14 | echoscip-shell system . . echo. "name: $name" |
| 15 | echoscip-shell system . . echo. "sds file: $sds" |
| 16 | echoscip-shell system . . echo. "Stderr file = $stderr" |
| 17 | echoscip-shell system . . echo. "Results file = $result" |
| 18 | |
| 19 | line1='^\W*part /tmp$' |
| 20 | line2='^\W*part /tmp --mountoptions=nodev$' |
| 21 | line3='^\W*passwd --minlen=14$' |
| 22 | |
| 23 | $OSCAP ds sds-validate $sds |
| 24 | |
| 25 | datastream_id=scap_org.open-scap_datastream_from_xccdf_test_report_anaconda_fixes.xccdf.xml |
| 26 | component_id=scap_org.open-scap_cref_test_report_anaconda_fixes.xccdf.xml |
| 27 | |
| 28 | $OSCAP info $sds | grepscip-shell system . . grep. $datastream_id |
| 29 | $OSCAP info $sds | grepscip-shell system . . grep. $component_id |
| 30 | |
| 31 | $OSCAP xccdf generate fix --fix-type anaconda \ |
| 32 | --datastream-id $datastream_id --xccdf-id $component_id \ |
| 33 | --output $result $sds 2>&1 > $stderr |
| 34 | [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; :> $stderr |
| 35 | grepscip-shell system . . grep. "$line1" $result |
| 36 | grepscip-shell system . . grep. "$line2" $result |
| 37 | grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | grepscip-shell system . . grep. -v "$line3" |
| 38 | |
| 39 | [scip-shell system . . `[`. "`grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | xsed 's/\W//g'`"x == x ] |
| 40 | |
| 41 | :> $result |
| 42 | |
| 43 | $OSCAP xccdf generate fix --fix-type anaconda \ |
| 44 | --profile xccdf_moc.elpmaxe.www_profile_1 \ |
| 45 | --output $result $sds 2>&1 > $stderr |
| 46 | [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; :> $stderr |
| 47 | grepscip-shell system . . grep. "$line1" $result |
| 48 | grepscip-shell system . . grep. "$line2" $result |
| 49 | grepscip-shell system . . grep. "$line3" $result |
| 50 | grepscip-shell system . . grep. -v "$line1" $result | grepscip-shell system . . grep. -v "$line2" | grepscip-shell system . . grep. -v "$line3" |
| 51 | |
| 52 | [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 ] |
| 53 | |
| 54 | rmscip-shell system . . rm. $result $sds |