Debian Codegraph @

tests/API/XCCDF/unittests/test_xccdf_results_arf_asset.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 . $builddir/tests/test_common.sh
4
5 set -e
6 set -o pipefail
7
8 function test_xccdf_results_arf_assetscip-shell shell shell-project 0.0.0 test_xccdf_results_arf_asset(). {
9 local DS="${srcdir}/test_xccdf_results_arf_no_oval.xccdf.xml"
10 local result="results.xml"
11 local stderr="error.log"
12
13 [scip-shell system . . `[`. -f $result ] && rmscip-shell system . . rm. -f $result
14
15 $OSCAP xccdf eval --results-arf $result $DS 2> $stderr
16
17 [scip-shell system . . `[`. -f $stderr ]; [scip-shell system . . `[`. ! -s $stderr ]; rmscip-shell system . . rm. $stderr
18
19 [scip-shell system . . `[`. -f $result ]
20
21 local asset='/arf:asset-report-collection/arf:assets/arf:asset[@id="asset0"]/ai:computing-devicescip-shell filesystem . . `/arf:asset-report-collection/arf:assets/arf:asset[@id="asset0"]/ai:computing-device`.'
22
23 case $(unamescip-shell system . . uname.) in
24 FreeBSD)
25 local name=`hostnamescip-shell system . . hostname.`
26 local domain=`grepscip-shell system . . grep. search /etc/resolv.confscip-shell filesystem . . `/etc/resolv.conf`. | cutscip-shell system . . cut. -d " " -f 2`
27 local fqdn=$name.$domain
28 ;;
29 *)
30 local fqdn=`hostnamescip-shell system . . hostname. --fqdn`
31 ;;
32 esac
33
34 echoscip-shell system . . echo. $asset'/ai:fqdn[text()="'$fqdn'"]'
35 assert_exists 1 $asset'/ai:fqdn[text()="'$fqdn'"]'
36
37 local hostname=`hostnamescip-shell system . . hostname.`
38 echoscip-shell system . . echo. $asset'/ai:hostname[text()="'$hostname'"]'
39 assert_exists 1 $asset'/ai:hostname[text()="'$hostname'"]'
40
41 local macs=`ifconfig -a | grepscip-shell system . . grep. ether | uniqscip-shell system . . uniq. | awkscip-shell system . . awk. -F ' ' '{print toupper($2);}'`
42 for mac in $macs; do
43 echoscip-shell system . . echo. $asset'/ai:connections/ai:connection/ai:mac-address[text()="'${mac}'"]'
44 assert_exists 1 $asset'/ai:connections/ai:connection/ai:mac-address[text()="'$mac'"]'
45 done
46
47 local ip4s=`ifconfig -a | grepscip-shell system . . grep. 'inet ' | uniqscip-shell system . . uniq. | awkscip-shell system . . awk. -F ' ' '{print $2;}'`
48 for ip in $ip4s; do
49 echoscip-shell system . . echo. $asset'/ai:connections/ai:connection/ai:ip-address/ai:ip-v4[text()="'$ip'"]'
50 assert_exists 1 $asset'/ai:connections/ai:connection/ai:ip-address/ai:ip-v4[text()="'$ip'"]'
51 done
52
53 if require ipcalc; then
54 local ip6s=`ifconfig -a | grepscip-shell system . . grep. 'inet6' | uniqscip-shell system . . uniq. | awkscip-shell system . . awk. -F ' ' '{print $2;}'`
55 for ip in $ip6s; do
56 local ipf=`ipcalc $ip | grepscip-shell system . . grep. Full | awkscip-shell system . . awk. -F ' ' '{print gensub(/(^|:)0+([0-9a-f])/,"\\\1\\\2","g",$3);}'`
57 echoscip-shell system . . echo. $asset'/ai:connections/ai:connection/ai:ip-address/ai:ip-v6[text()="'$ipf'"]'
58 assert_exists 1 $asset'/ai:connections/ai:connection/ai:ip-address/ai:ip-v6[text()="'$ipf'"]'
59 done
60 fi
61
62 rmscip-shell system . . rm. $result
63 }
64
65 test_xccdf_results_arf_assetscip-shell shell shell-project 0.0.0 test_xccdf_results_arf_asset().