Skip to content

Commit 475b387

Browse files
committed
Add simple tests for validating SCAP 1.3 datastreams
Tests if `oscap ds sds-validate` can validate SCAP 1.3 datastreams against XML schema. The test uses a simple valid datastream and a simple invalid datastream.
1 parent 8457c92 commit 475b387

File tree

4 files changed

+109
-6
lines changed

4 files changed

+109
-6
lines changed

tests/DS/validate/Makefile.am

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ TESTS_ENVIRONMENT= \
99
TESTS = all.sh
1010

1111
EXTRA_DIST = all.sh \
12-
sds-valid.xml \
13-
sds-invalid.xml \
14-
sds-invalid-xccdf.xml \
15-
sds-invalid-oval.xml \
16-
rds-valid.xml \
17-
rds-invalid.xml
12+
rds-invalid.xml \
13+
rds-valid.xml \
14+
sds-1.3-invalid.xml \
15+
sds-1.3-valid.xml \
16+
sds-invalid-oval.xml \
17+
sds-invalid-xccdf.xml \
18+
sds-invalid.xml \
19+
sds-valid.xml

tests/DS/validate/all.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ function test_validation {
1818

1919
test_init test_validation.log
2020
test_run "valid-sds" test_validation sds sds-valid.xml 0
21+
test_run "valid-1.3-sds" test_validation sds sds-1.3-valid.xml 0
2122
test_run "invalid-sds" test_validation sds sds-invalid.xml 1
23+
test_run "invalid-1.3-sds" test_validation sds sds-1.3-invalid.xml 1
2224
test_run "invalid-xccdf-sds" test_validation sds sds-invalid-xccdf.xml 1
2325
test_run "invalid-oval-sds" test_validation sds sds-invalid-oval.xml 1
2426

tests/DS/validate/sds-1.3-invalid.xml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0"?>
2+
<ns0:data-stream-collection xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:ns0="http://scap.nist.gov/schema/scap/source/1.2" xmlns:ns1="http://www.w3.org/1999/xlink" xmlns:ns10="http://checklists.nist.gov/xccdf/1.2" xmlns:ns13="http://cpe.mitre.org/dictionary/2.0" xmlns:ns2="urn:oasis:names:tc:entity:xmlns:xml:catalog" xmlns:ns3="http://scap.nist.gov/schema/ocil/2.0" xmlns:ns4="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:ns6="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:ns7="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:ns8="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:ns9="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="scap_org.open-scap_collection_from_xccdf_ssg-rhel8-xccdf-1.2.xml" schematron-version="1.3">
3+
<ns0:data-stream id="scap_org.open-scap_datastream_from_xccdf_ssg-rhel8-xccdf-1.2.xml" scap-version="1.3" use-case="OTHER">
4+
</ns0:data-stream>
5+
<ns0:component id="scap_org.open-scap_comp_ssg-rhel8-oval.xml" timestamp="2019-05-10T08:18:44">
6+
<ns4:oval_definitions xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#independent independent-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#unix unix-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#linux linux-definitions-schema.xsd">
7+
<ns4:generator>
8+
<ns6:product_name>combine_ovals.py from SCAP Security Guide</ns6:product_name>
9+
<ns6:product_version>ssg: [0, 1, 44], python: 3.7.3</ns6:product_version>
10+
<ns6:schema_version>5.11</ns6:schema_version>
11+
<ns6:timestamp>2019-05-10T06:18:18</ns6:timestamp>
12+
</ns4:generator>
13+
<ns4:definitions>
14+
<ns4:definition class="inventory" id="oval:ssg-installed_OS_is_rhel8:def:1" version="1">
15+
<ns4:metadata>
16+
<ns4:title>Red Hat Enterprise Linux 8</ns4:title>
17+
<ns4:affected family="unix">
18+
<ns4:platform>Red Hat Enterprise Linux 8</ns4:platform>
19+
</ns4:affected>
20+
<ns4:reference ref_id="cpe:/o:redhat:enterprise_linux:8" source="CPE"/>
21+
<ns4:description>The operating system installed on the system is
22+
Red Hat Enterprise Linux 8</ns4:description>
23+
<ns4:reference ref_id="installed_OS_is_rhel8" source="ssg"/>
24+
</ns4:metadata>
25+
<ns4:criteria>
26+
<ns4:criterion comment="RHEL 8 is installed" test_ref="oval:ssg-test_rhel8:tst:1"/>
27+
</ns4:criteria>
28+
</ns4:definition>
29+
</ns4:definitions>
30+
<ns4:tests>
31+
<ns9:rpminfo_test check="all" check_existence="at_least_one_exists" comment="redhat-release is version 8" id="oval:ssg-test_rhel8:tst:1" version="1">
32+
<ns9:object object_ref="oval:ssg-obj_rhel8:obj:1"/>
33+
<ns9:state state_ref="oval:ssg-state_rhel8:ste:1"/>
34+
</ns9:rpminfo_test>
35+
</ns4:tests>
36+
<ns4:objects>
37+
<ns9:rpminfo_object id="oval:ssg-obj_rhel8:obj:1" version="1">
38+
<ns9:name>redhat-release</ns9:name>
39+
</ns9:rpminfo_object>
40+
</ns4:objects>
41+
<ns4:states>
42+
<ns9:rpminfo_state id="oval:ssg-state_rhel8:ste:1" version="1">
43+
<ns9:version operation="pattern match">^8.*$</ns9:version>
44+
</ns9:rpminfo_state>
45+
</ns4:states>
46+
</ns4:oval_definitions>
47+
</ns0:component>
48+
</ns0:data-stream-collection>

tests/DS/validate/sds-1.3-valid.xml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?xml version="1.0"?>
2+
<ns0:data-stream-collection xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:ns0="http://scap.nist.gov/schema/scap/source/1.2" xmlns:ns1="http://www.w3.org/1999/xlink" xmlns:ns10="http://checklists.nist.gov/xccdf/1.2" xmlns:ns13="http://cpe.mitre.org/dictionary/2.0" xmlns:ns2="urn:oasis:names:tc:entity:xmlns:xml:catalog" xmlns:ns3="http://scap.nist.gov/schema/ocil/2.0" xmlns:ns4="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:ns6="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:ns7="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:ns8="http://oval.mitre.org/XMLSchema/oval-definitions-5#unix" xmlns:ns9="http://oval.mitre.org/XMLSchema/oval-definitions-5#linux" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="scap_org.open-scap_collection_from_xccdf_ssg-rhel8-xccdf-1.2.xml" schematron-version="1.3">
3+
<ns0:data-stream id="scap_org.open-scap_datastream_from_xccdf_ssg-rhel8-xccdf-1.2.xml" scap-version="1.3" use-case="OTHER">
4+
<ns0:checks>
5+
<ns0:component-ref id="scap_org.open-scap_cref_ssg-rhel8-oval.xml" ns1:href="#scap_org.open-scap_comp_ssg-rhel8-oval.xml"/>
6+
</ns0:checks>
7+
</ns0:data-stream>
8+
<ns0:component id="scap_org.open-scap_comp_ssg-rhel8-oval.xml" timestamp="2019-05-10T08:18:44">
9+
<ns4:oval_definitions xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#independent independent-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#unix unix-definitions-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5#linux linux-definitions-schema.xsd">
10+
<ns4:generator>
11+
<ns6:product_name>combine_ovals.py from SCAP Security Guide</ns6:product_name>
12+
<ns6:product_version>ssg: [0, 1, 44], python: 3.7.3</ns6:product_version>
13+
<ns6:schema_version>5.11</ns6:schema_version>
14+
<ns6:timestamp>2019-05-10T06:18:18</ns6:timestamp>
15+
</ns4:generator>
16+
<ns4:definitions>
17+
<ns4:definition class="inventory" id="oval:ssg-installed_OS_is_rhel8:def:1" version="1">
18+
<ns4:metadata>
19+
<ns4:title>Red Hat Enterprise Linux 8</ns4:title>
20+
<ns4:affected family="unix">
21+
<ns4:platform>Red Hat Enterprise Linux 8</ns4:platform>
22+
</ns4:affected>
23+
<ns4:reference ref_id="cpe:/o:redhat:enterprise_linux:8" source="CPE"/>
24+
<ns4:description>The operating system installed on the system is
25+
Red Hat Enterprise Linux 8</ns4:description>
26+
<ns4:reference ref_id="installed_OS_is_rhel8" source="ssg"/>
27+
</ns4:metadata>
28+
<ns4:criteria>
29+
<ns4:criterion comment="RHEL 8 is installed" test_ref="oval:ssg-test_rhel8:tst:1"/>
30+
</ns4:criteria>
31+
</ns4:definition>
32+
</ns4:definitions>
33+
<ns4:tests>
34+
<ns9:rpminfo_test check="all" check_existence="at_least_one_exists" comment="redhat-release is version 8" id="oval:ssg-test_rhel8:tst:1" version="1">
35+
<ns9:object object_ref="oval:ssg-obj_rhel8:obj:1"/>
36+
<ns9:state state_ref="oval:ssg-state_rhel8:ste:1"/>
37+
</ns9:rpminfo_test>
38+
</ns4:tests>
39+
<ns4:objects>
40+
<ns9:rpminfo_object id="oval:ssg-obj_rhel8:obj:1" version="1">
41+
<ns9:name>redhat-release</ns9:name>
42+
</ns9:rpminfo_object>
43+
</ns4:objects>
44+
<ns4:states>
45+
<ns9:rpminfo_state id="oval:ssg-state_rhel8:ste:1" version="1">
46+
<ns9:version operation="pattern match">^8.*$</ns9:version>
47+
</ns9:rpminfo_state>
48+
</ns4:states>
49+
</ns4:oval_definitions>
50+
</ns0:component>
51+
</ns0:data-stream-collection>

0 commit comments

Comments
 (0)