Skip to content

Commit 800e07e

Browse files
committed
Add test for textfilecontent54
Validate behaviour with negative instance Signed-off-by: Edgar Aguilar <[email protected]>
1 parent 8beeb91 commit 800e07e

File tree

3 files changed

+218
-0
lines changed

3 files changed

+218
-0
lines changed

tests/probes/textfilecontent54/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ if(ENABLE_PROBES_INDEPENDENT)
66
add_oscap_test("test_recursion_limit.sh")
77
add_oscap_test("test_symlinks.sh")
88
add_oscap_test("test_validation_of_various_oval_versions.sh")
9+
add_oscap_test("test_negative_instance.sh")
910
endif()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
. $builddir/tests/test_common.sh
4+
5+
function test_negative_instance {
6+
7+
probecheck "textfilecontent54" || return 255
8+
9+
local ret_val=0;
10+
local DF="${srcdir}/test_negative_instance.xml"
11+
local RF="results.xml"
12+
13+
[ -f $RF ] && rm -f $RF
14+
15+
local FILE_A="/tmp/test_negative_instance.tmp_file"
16+
17+
touch "$FILE_A"
18+
19+
echo "valid_key = valid_value" > "$FILE_A"
20+
echo "valid_key = valid_value" >> "$FILE_A"
21+
echo "valid_key = valid_value" >> "$FILE_A"
22+
23+
$OSCAP oval eval --results $RF $DF
24+
25+
if [ -f $RF ]; then
26+
verify_results "tst" $DF $RF 13 && verify_results "def" $DF $RF 1
27+
ret_val=$?
28+
else
29+
ret_val=1
30+
fi
31+
32+
rm -f $FILE_A $FILE_B $FILE_C
33+
34+
return $ret_val
35+
}
36+
37+
test_negative_instance
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
<?xml version="1.0"?>
2+
<oval_definitions xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ind-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:unix-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:lin-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5" xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix unix-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#independent independent-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#linux linux-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd">
3+
4+
<generator>
5+
<oval:schema_version>5.11.1</oval:schema_version>
6+
<oval:timestamp>2025-03-24T00:00:00-00:00</oval:timestamp>
7+
</generator>
8+
9+
<definitions>
10+
11+
<definition class="compliance" version="1" id="oval:0:def:1"> <!-- comment="true" -->
12+
<metadata>
13+
<title></title>
14+
<description></description>
15+
</metadata>
16+
<criteria operator="AND">
17+
<criterion test_ref="oval:0:tst:1"/>
18+
<criterion test_ref="oval:0:tst:2"/>
19+
<criterion test_ref="oval:0:tst:3"/>
20+
<criterion test_ref="oval:0:tst:4"/>
21+
<criterion test_ref="oval:0:tst:5"/>
22+
<criterion test_ref="oval:0:tst:6"/>
23+
<criterion test_ref="oval:0:tst:7"/>
24+
<criterion test_ref="oval:0:tst:8"/>
25+
<criterion test_ref="oval:0:tst:9"/>
26+
<criterion test_ref="oval:0:tst:10"/>
27+
<criterion test_ref="oval:0:tst:11"/>
28+
<criterion test_ref="oval:0:tst:12"/>
29+
<criterion test_ref="oval:0:tst:13"/>
30+
</criteria>
31+
</definition>
32+
33+
</definitions>
34+
35+
<tests>
36+
37+
<textfilecontent54_test check_existence="all_exist" version="1" id="oval:0:tst:1" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
38+
<object object_ref="oval:0:obj:1"/>
39+
</textfilecontent54_test>
40+
41+
<textfilecontent54_test check_existence="all_exist" version="1" id="oval:0:tst:2" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
42+
<object object_ref="oval:0:obj:2"/>
43+
</textfilecontent54_test>
44+
45+
<textfilecontent54_test check_existence="all_exist" version="1" id="oval:0:tst:3" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
46+
<object object_ref="oval:0:obj:3"/>
47+
</textfilecontent54_test>
48+
49+
<textfilecontent54_test check_existence="all_exist" version="1" id="oval:0:tst:4" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
50+
<object object_ref="oval:0:obj:4"/>
51+
</textfilecontent54_test>
52+
53+
<textfilecontent54_test check_existence="all_exist" version="1" id="oval:0:tst:5" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
54+
<object object_ref="oval:0:obj:5"/>
55+
</textfilecontent54_test>
56+
57+
<textfilecontent54_test check_existence="all_exist" version="1" id="oval:0:tst:6" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
58+
<object object_ref="oval:0:obj:6"/>
59+
</textfilecontent54_test>
60+
61+
<textfilecontent54_test check_existence="all_exist" version="1" id="oval:0:tst:7" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
62+
<object object_ref="oval:0:obj:7"/>
63+
</textfilecontent54_test>
64+
65+
<textfilecontent54_test check_existence="all_exist" version="1" id="oval:0:tst:8" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
66+
<object object_ref="oval:0:obj:8"/>
67+
</textfilecontent54_test>
68+
69+
<textfilecontent54_test check_existence="all_exist" version="1" id="oval:0:tst:9" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
70+
<object object_ref="oval:0:obj:9"/>
71+
</textfilecontent54_test>
72+
73+
<textfilecontent54_test check_existence="none_exist" version="1" id="oval:0:tst:10" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
74+
<object object_ref="oval:0:obj:10"/>
75+
</textfilecontent54_test>
76+
77+
<textfilecontent54_test check_existence="only_one_exists" version="1" id="oval:0:tst:11" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
78+
<object object_ref="oval:0:obj:11"/>
79+
</textfilecontent54_test>
80+
81+
<textfilecontent54_test check_existence="none_exist" version="1" id="oval:0:tst:12" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
82+
<object object_ref="oval:0:obj:12"/>
83+
</textfilecontent54_test>
84+
85+
<textfilecontent54_test check_existence="only_one_exists" version="1" id="oval:0:tst:13" check="all" comment="true" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
86+
<object object_ref="oval:0:obj:4"/>
87+
</textfilecontent54_test>
88+
89+
</tests>
90+
91+
<objects>
92+
93+
<textfilecontent54_object version="1" id="oval:0:obj:1" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
94+
<path>/tmp</path>
95+
<filename>test_negative_instance.tmp_file</filename>
96+
<pattern operation="pattern match">(\s)*valid_key(\s)*=(\s)*valid_value(\s)*</pattern>
97+
<instance operation="greater than or equal" datatype="int">1</instance>
98+
</textfilecontent54_object>
99+
100+
<textfilecontent54_object version="1" id="oval:0:obj:2" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
101+
<path>/tmp</path>
102+
<filename>test_negative_instance.tmp_file</filename>
103+
<pattern operation="pattern match">(\s)*valid_key(\s)*=(\s)*valid_value(\s)*</pattern>
104+
<instance operation="greater than or equal" datatype="int">2</instance>
105+
</textfilecontent54_object>
106+
107+
<textfilecontent54_object version="1" id="oval:0:obj:3" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
108+
<path>/tmp</path>
109+
<filename>test_negative_instance.tmp_file</filename>
110+
<pattern operation="pattern match">(\s)*valid_key(\s)*=(\s)*valid_value(\s)*</pattern>
111+
<instance operation="greater than or equal" datatype="int">3</instance>
112+
</textfilecontent54_object>
113+
114+
<textfilecontent54_object version="1" id="oval:0:obj:4" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
115+
<path>/tmp</path>
116+
<filename>test_negative_instance.tmp_file</filename>
117+
<pattern operation="pattern match">(\s)*valid_key(\s)*=(\s)*valid_value(\s)*</pattern>
118+
<instance operation="greater than or equal" datatype="int">-1</instance>
119+
</textfilecontent54_object>
120+
121+
<textfilecontent54_object version="1" id="oval:0:obj:5" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
122+
<path>/tmp</path>
123+
<filename>test_negative_instance.tmp_file</filename>
124+
<pattern operation="pattern match">(\s)*valid_key(\s)*=(\s)*valid_value(\s)*</pattern>
125+
<instance operation="greater than or equal" datatype="int">-2</instance>
126+
</textfilecontent54_object>
127+
128+
<textfilecontent54_object version="1" id="oval:0:obj:6" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
129+
<path>/tmp</path>
130+
<filename>test_negative_instance.tmp_file</filename>
131+
<pattern operation="pattern match">(\s)*valid_key(\s)*=(\s)*valid_value(\s)*</pattern>
132+
<instance operation="greater than or equal" datatype="int">-3</instance>
133+
</textfilecontent54_object>
134+
135+
<textfilecontent54_object version="1" id="oval:0:obj:7" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
136+
<path>/tmp</path>
137+
<filename>test_negative_instance.tmp_file</filename>
138+
<pattern operation="pattern match">(\s)*valid_key(\s)*=(\s)*valid_value(\s)*</pattern>
139+
<instance operation="equals" datatype="int">-1</instance>
140+
</textfilecontent54_object>
141+
142+
<textfilecontent54_object version="1" id="oval:0:obj:8" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
143+
<path>/tmp</path>
144+
<filename>test_negative_instance.tmp_file</filename>
145+
<pattern operation="pattern match">(\s)*valid_key(\s)*=(\s)*valid_value(\s)*</pattern>
146+
<instance operation="equals" datatype="int">-2</instance>
147+
</textfilecontent54_object>
148+
149+
<textfilecontent54_object version="1" id="oval:0:obj:9" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
150+
<path>/tmp</path>
151+
<filename>test_negative_instance.tmp_file</filename>
152+
<pattern operation="pattern match">(\s)*valid_key(\s)*=(\s)*valid_value(\s)*</pattern>
153+
<instance operation="equals" datatype="int">-3</instance>
154+
</textfilecontent54_object>
155+
156+
<textfilecontent54_object version="1" id="oval:0:obj:10" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
157+
<path>/tmp</path>
158+
<filename>test_negative_instance.tmp_file</filename>
159+
<pattern operation="pattern match">(\s)*valid_key(\s)*=(\s)*valid_value(\s)*</pattern>
160+
<instance operation="greater than" datatype="int">-1</instance>
161+
</textfilecontent54_object>
162+
163+
<textfilecontent54_object version="1" id="oval:0:obj:11" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
164+
<path>/tmp</path>
165+
<filename>test_negative_instance.tmp_file</filename>
166+
<pattern operation="pattern match">(\s)*valid_key(\s)*=(\s)*valid_value(\s)*</pattern>
167+
<instance operation="less than" datatype="int">-2</instance>
168+
</textfilecontent54_object>
169+
170+
<textfilecontent54_object version="1" id="oval:0:obj:12" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent">
171+
<path>/tmp</path>
172+
<filename>test_negative_instance.tmp_file</filename>
173+
<pattern operation="pattern match">(\s)*valid_key(\s)*=(\s)*valid_value(\s)*</pattern>
174+
<instance operation="less than" datatype="int">-3</instance>
175+
</textfilecontent54_object>
176+
177+
178+
</objects>
179+
180+
</oval_definitions>

0 commit comments

Comments
 (0)