| 1 | #!/usr/bin/env bash |
| 2 | . $builddir/tests/test_common.sh |
| 3 | |
| 4 | set -e |
| 5 | set -o pipefail |
| 6 | |
| 7 | name=$(basename $0 _ds.sh) |
| 8 | xccdf=${name}.xccdf.xml |
| 9 | sds=$(make_temp_file /tmp ${name}.sds) |
| 10 | stderr=$(make_temp_file /tmp ${name}_ds.err) |
| 11 | result=$(make_temp_file /tmp ${name}_ds.out) |
| 12 | cp $srcdir/test_report_anaconda_fixes.sds.xml $sds |
| 13 | |
| 14 | echo "name: $name" |
| 15 | echo "sds file: $sds" |
| 16 | echo "Stderr file = $stderr" |
| 17 | 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 | grep $datastream_id |
| 29 | $OSCAP info $sds | 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 | [ -f $stderr ]; [ ! -s $stderr ]; :> $stderr |
| 35 | grep "$line1" $result |
| 36 | grep "$line2" $result |
| 37 | grep -v "$line1" $result | grep -v "$line2" | grep -v "$line3" |
| 38 | |
| 39 | [ "`grep -v "$line1" $result | 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 | [ -f $stderr ]; [ ! -s $stderr ]; :> $stderr |
| 47 | grep "$line1" $result |
| 48 | grep "$line2" $result |
| 49 | grep "$line3" $result |
| 50 | grep -v "$line1" $result | grep -v "$line2" | grep -v "$line3" |
| 51 | |
| 52 | [ "`grep -v "$line1" $result | grep -v "$line2" | grep -v "$line3" | xsed 's/\W//g'`"x == x ] |
| 53 | |
| 54 | rm $result $sds |