File: all.sh

package info (click to toggle)
openscap 1.2.9-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 122,116 kB
  • ctags: 9,729
  • sloc: xml: 646,128; ansic: 96,881; sh: 18,040; makefile: 2,986; python: 1,150; perl: 443; cpp: 123
file content (150 lines) | stat: -rwxr-xr-x 10,649 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash

# Check that variables have their values recorded in the OVAL results.
# This test verifies that different flavours of variable which are
# referenced from various OVAL elements are recorded in the
# 'tested_variable' and 'variable_value' elements.

. ../../../test_common.sh

set -e -o pipefail

function report_variable_values() {
	name="report_variable_values"
	defxml=${name}.def.xml
	varxml=${name}.var.xml
	resxml=$(mktemp ${name}.res.XXXXXX.xml)
	stderr=$(mktemp ${name}.stderr.XXXXXX)

	echo "Results file: $resxml"
	echo "Stderr dump from oscap: $stderr"

	echo "Running eval"
	$OSCAP oval eval --variables $srcdir/$varxml --results $resxml $srcdir/$defxml > $stderr 2>&1

	echo "Verifying results"
	result="$resxml"
	assert_exists 1 '/oval_results'
	assert_exists 1 '/oval_results/results'
	assert_exists 1 '/oval_results/results/system'
	assert_exists 1 '/oval_results/results/system/definitions'
	assert_exists 1 '/oval_results/results/system/definitions/definition[@result="true"]'
	assert_exists 1 '/oval_results/results/system/tests'
	assert_exists 8 '/oval_results/results/system/tests/test'

	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1" and @result="true"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_item'
	assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_variable'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_variable[@variable_id="oval:x:var:1" and text()="0"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:1"]/tested_variable[@variable_id="oval:x:var:1" and text()="1"]'

	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2" and @result="true"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_item'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_variable'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:2"]/tested_variable[@variable_id="oval:x:var:2" and text()="2"]'

	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3" and @result="true"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_item'
	assert_exists 4 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable[@variable_id="oval:x:var:1" and text()="0"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable[@variable_id="oval:x:var:1" and text()="1"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable[@variable_id="oval:x:var:2" and text()="2"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:3"]/tested_variable[@variable_id="oval:x:var:3" and text()="3"]'

	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4" and @result="true"]'
	assert_exists 0 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_item'
	assert_exists 4 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable[@variable_id="oval:x:var:1" and text()="0"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable[@variable_id="oval:x:var:1" and text()="1"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable[@variable_id="oval:x:var:3" and text()="3"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:4"]/tested_variable[@variable_id="oval:x:var:4"]'

	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5" and @result="true"]'
	assert_exists 0 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_item'
	assert_exists 5 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable[@variable_id="oval:x:var:1" and text()="0"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable[@variable_id="oval:x:var:1" and text()="1"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable[@variable_id="oval:x:var:2" and text()="2"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable[@variable_id="oval:x:var:3" and text()="3"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:5"]/tested_variable[@variable_id="oval:x:var:4"]'

	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6" and @result="true"]'
	assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_item'
	assert_exists 5 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable[@variable_id="oval:x:var:1" and text()="0"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable[@variable_id="oval:x:var:1" and text()="1"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable[@variable_id="oval:x:var:2" and text()="2"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable[@variable_id="oval:x:var:5" and text()="4"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:6"]/tested_variable[@variable_id="oval:x:var:5" and text()="5"]'

	assert_exists 0 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:7"]'

	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:8" and @result="true"]'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:8"]/tested_item'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:8"]/tested_variable'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:8"]/tested_variable[@variable_id="oval:x:var:2" and text()="2"]'

	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:9" and @result="true"]'
	assert_exists 2 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:9"]/tested_item'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:9"]/tested_variable'
	assert_exists 1 '/oval_results/results/system/tests/test[@test_id="oval:x:tst:9"]/tested_variable[@variable_id="oval:x:var:2" and text()="2"]'

	assert_exists 1 '/oval_results/results/system/oval_system_characteristics'
	assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects'
	assert_exists 7 '/oval_results/results/system/oval_system_characteristics/collected_objects/object'
	CO='/oval_results/results/system/oval_system_characteristics/collected_objects'

	assert_exists 1 "$CO"'/object[@id="oval:x:obj:1" and @flag="complete"]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:1"]/reference[@item_ref]'
	assert_exists 2 "$CO"'/object[@id="oval:x:obj:1"]/variable_value'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:1"]/variable_value[@variable_id="oval:x:var:1" and text()="0"]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:1"]/variable_value[@variable_id="oval:x:var:1" and text()="1"]'

	assert_exists 1 "$CO"'/object[@id="oval:x:obj:2" and @flag="complete"]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:2"]/reference[@item_ref]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:2"]/variable_value'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:2"]/variable_value[@variable_id="oval:x:var:2" and text()="2"]'

	assert_exists 1 "$CO"'/object[@id="oval:x:obj:3" and @flag="complete"]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:3"]/reference[@item_ref]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:3"]/variable_value'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:3"]/variable_value[@variable_id="oval:x:var:3" and text()="3"]'

	assert_exists 1 "$CO"'/object[@id="oval:x:obj:4" and @flag="does not exist"]'
	assert_exists 0 "$CO"'/object[@id="oval:x:obj:4"]/reference[@item_ref]'
	assert_exists 4 "$CO"'/object[@id="oval:x:obj:4"]/variable_value'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:4"]/variable_value[@variable_id="oval:x:var:1" and text()="0"]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:4"]/variable_value[@variable_id="oval:x:var:1" and text()="1"]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:4"]/variable_value[@variable_id="oval:x:var:3" and text()="3"]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:4"]/variable_value[@variable_id="oval:x:var:4"]'

	assert_exists 0 "$CO"'/object[@id="oval:x:obj:5"]'

	assert_exists 1 "$CO"'/object[@id="oval:x:obj:6" and @flag="complete"]'
	assert_exists 2 "$CO"'/object[@id="oval:x:obj:6"]/reference[@item_ref]'
	assert_exists 5 "$CO"'/object[@id="oval:x:obj:6"]/variable_value'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:6"]/variable_value[@variable_id="oval:x:var:1" and text()="0"]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:6"]/variable_value[@variable_id="oval:x:var:1" and text()="1"]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:6"]/variable_value[@variable_id="oval:x:var:2" and text()="2"]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:6"]/variable_value[@variable_id="oval:x:var:5" and text()="4"]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:6"]/variable_value[@variable_id="oval:x:var:5" and text()="5"]'

	assert_exists 0 "$CO"'/object[@id="oval:x:obj:7"]'

	assert_exists 1 "$CO"'/object[@id="oval:x:obj:8" and @flag="complete"]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:8"]/reference[@item_ref]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:8"]/variable_value'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:8"]/variable_value[@variable_id="oval:x:var:2" and text()="2"]'

	assert_exists 1 "$CO"'/object[@id="oval:x:obj:9" and @flag="complete"]'
	assert_exists 2 "$CO"'/object[@id="oval:x:obj:9"]/reference[@item_ref]'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:9"]/variable_value'
	assert_exists 1 "$CO"'/object[@id="oval:x:obj:9"]/variable_value[@variable_id="oval:x:var:2" and text()="2"]'

	rm $resxml
	rm $stderr
}

test_init report_variable_values.log
test_run "Report variable values in OVAL results" report_variable_values
test_exit