Skip to content

Commit 8645604

Browse files
committed
Add test for DS session and SCAP 1.3 remote resources
* Test for PR#1324 which verifies that DS session does not quit when SCAP 1.3 content contains remote component but `--fetch-remote-resources` option is not provided. The test is also extended to verify that scans utilizing SCAP 1.2 and 1.3 datastreams produce the same results.
1 parent 9d85d55 commit 8645604

File tree

4 files changed

+195
-0
lines changed

4 files changed

+195
-0
lines changed

tests/DS/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ TESTS_ENVIRONMENT= \
1111
TESTS = test_ds.sh
1212

1313
EXTRA_DIST = test_ds.sh \
14+
ds_continue_without_remote_resources/remote_content_1.2.ds.xml \
15+
ds_continue_without_remote_resources/remote_content_1.3.ds.xml \
1416
eval_invalid/sds.xml \
1517
eval_invalid/sds-oval.xml \
1618
eval_simple/sds.xml \
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ds:data-stream-collection xmlns:ds="http://scap.nist.gov/schema/scap/source/1.2" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:cat="urn:oasis:names:tc:entity:xmlns:xml:catalog" id="scap_org.open-scap_collection_from_xccdf_test_single_rule.xccdf.xml" schematron-version="1.2">
3+
<ds:data-stream id="scap_org.open-scap_datastream_from_xccdf_test_single_rule.xccdf.xml" scap-version="1.2" use-case="OTHER">
4+
<ds:checklists>
5+
<ds:component-ref id="scap_org.open-scap_cref_test_single_rule.xccdf.xml" xlink:href="#scap_org.open-scap_comp_test_single_rule.xccdf.xml">
6+
<cat:catalog>
7+
<cat:uri name="test_single_rule.oval.xml" uri="#scap_org.open-scap_cref_test_single_rule.oval.xml"/>
8+
</cat:catalog>
9+
</ds:component-ref>
10+
</ds:checklists>
11+
<ds:checks>
12+
<ds:component-ref id="scap_org.open-scap_cref_test_single_rule.oval.xml" xlink:href="#scap_org.open-scap_comp_test_single_rule.oval.xml"/>
13+
</ds:checks>
14+
</ds:data-stream>
15+
16+
<ds:component id="scap_org.open-scap_comp_test_single_rule.oval.xml" timestamp="2017-06-09T07:07:38">
17+
<oval_definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:ind-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:win-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#windows" xsi:schemaLocation="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#windows windows-definitions-schema.xsd">
18+
<generator>
19+
<oval:schema_version>5.10</oval:schema_version>
20+
<oval:timestamp>2009-01-12T10:41:00-05:00</oval:timestamp>
21+
</generator>
22+
23+
<definitions>
24+
<definition class="compliance" id="oval:test-pass:def:1" version="1">
25+
<metadata>
26+
<title>PASS</title>
27+
<description>pass</description>
28+
</metadata>
29+
<criteria>
30+
<criterion comment="PASS test" test_ref="oval:x:tst:1"/>
31+
</criteria>
32+
</definition>
33+
</definitions>
34+
35+
<tests>
36+
<variable_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" id="oval:x:tst:1" check="all" comment="always pass" version="1">
37+
<object object_ref="oval:x:obj:1"/>
38+
</variable_test>
39+
</tests>
40+
41+
<objects>
42+
<variable_object xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" id="oval:x:obj:1" version="1" comment="x">
43+
<var_ref>oval:x:var:1</var_ref>
44+
</variable_object>
45+
</objects>
46+
</oval_definitions>
47+
</ds:component>
48+
49+
<ds:component id="scap_org.open-scap_comp_test_single_rule.xccdf.xml" timestamp="2017-06-09T09:15:45">
50+
<Benchmark xmlns="http://checklists.nist.gov/xccdf/1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="xccdf_com.example.www_benchmark_dummy" xml:lang="en-US">
51+
<status>accepted</status>
52+
<version>1.0</version>
53+
54+
<Profile id="xccdf_com.example.www_profile_test_remote_res">
55+
<title>xccdf_test_profile</title>
56+
<description>This profile is for testing.</description>
57+
<select idref="xccdf_com.example.www_rule_test-pass" selected="true"/>
58+
<select idref="xccdf_com.example.www_rule_test-remote_res" selected="true"/>
59+
</Profile>
60+
61+
<Value id="xccdf_com.example.www_value_val1" type="number" operator="equals" interactive="0">
62+
<title>test value</title>
63+
<description>foo</description>
64+
<value selector="bar_1">50</value>
65+
<value selector="bar_2">100</value>
66+
</Value>
67+
<Rule selected="true" id="xccdf_com.example.www_rule_test-pass">
68+
<title>This rule always pass</title>
69+
<check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
70+
<check-content-ref href="test_single_rule.oval.xml" name="oval:test-pass:def:1"/>
71+
</check>
72+
</Rule>
73+
<Rule selected="true" id="xccdf_com.example.www_rule_test-remote_res">
74+
<title>This rule checks remote resource</title>
75+
<check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
76+
<check-content-ref href="https://www.example.com/security/data/oval/oval.xml.bz2"/>
77+
</check>
78+
</Rule>
79+
<Rule selected="true" id="xccdf_com.example.www_rule_test-pass2">
80+
<title>This rule always pass</title>
81+
<check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
82+
<check-content-ref href="test_single_rule.oval.xml" name="oval:test-pass:def:1"/>
83+
</check>
84+
</Rule>
85+
</Benchmark>
86+
</ds:component>
87+
</ds:data-stream-collection>
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ds:data-stream-collection xmlns:ds="http://scap.nist.gov/schema/scap/source/1.2" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:cat="urn:oasis:names:tc:entity:xmlns:xml:catalog" id="scap_org.open-scap_collection_from_xccdf_test_single_rule.xccdf.xml" schematron-version="1.3">
3+
<ds:data-stream id="scap_org.open-scap_datastream_from_xccdf_test_single_rule.xccdf.xml" scap-version="1.3" use-case="OTHER">
4+
<ds:checklists>
5+
<ds:component-ref id="scap_org.open-scap_cref_test_single_rule.xccdf.xml" xlink:href="#scap_org.open-scap_comp_test_single_rule.xccdf.xml">
6+
<cat:catalog>
7+
<cat:uri name="test_single_rule.oval.xml" uri="#scap_org.open-scap_cref_test_single_rule.oval.xml"/>
8+
<cat:uri name="security-data-oval.xml.bz2" uri="#scap_org.open-scap_cref_security-data-oval.xml.bz2"/>
9+
</cat:catalog>
10+
</ds:component-ref>
11+
</ds:checklists>
12+
<ds:checks>
13+
<ds:component-ref id="scap_org.open-scap_cref_test_single_rule.oval.xml" xlink:href="#scap_org.open-scap_comp_test_single_rule.oval.xml"/>
14+
<ds:component-ref id="scap_org.open-scap_cref_security-data-oval.xml.bz2" xlink:href="https://www.example.com/security/data/oval/oval.xml.bz2"/>
15+
</ds:checks>
16+
</ds:data-stream>
17+
18+
<ds:component id="scap_org.open-scap_comp_test_single_rule.oval.xml" timestamp="2017-06-09T07:07:38">
19+
<oval_definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:ind-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:win-def="http://oval.mitre.org/XMLSchema/oval-definitions-5#windows" xsi:schemaLocation="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#windows windows-definitions-schema.xsd">
20+
<generator>
21+
<oval:schema_version>5.11</oval:schema_version>
22+
<oval:timestamp>2009-01-12T10:41:00-05:00</oval:timestamp>
23+
</generator>
24+
25+
<definitions>
26+
<definition class="compliance" id="oval:test-pass:def:1" version="1">
27+
<metadata>
28+
<title>PASS</title>
29+
<description>pass</description>
30+
</metadata>
31+
<criteria>
32+
<criterion comment="PASS test" test_ref="oval:x:tst:1"/>
33+
</criteria>
34+
</definition>
35+
</definitions>
36+
37+
<tests>
38+
<variable_test xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" id="oval:x:tst:1" check="all" comment="always pass" version="1">
39+
<object object_ref="oval:x:obj:1"/>
40+
</variable_test>
41+
</tests>
42+
43+
<objects>
44+
<variable_object xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" id="oval:x:obj:1" version="1" comment="x">
45+
<var_ref>oval:x:var:1</var_ref>
46+
</variable_object>
47+
</objects>
48+
</oval_definitions>
49+
</ds:component>
50+
51+
<ds:component id="scap_org.open-scap_comp_test_single_rule.xccdf.xml" timestamp="2017-06-09T09:15:45">
52+
<Benchmark xmlns="http://checklists.nist.gov/xccdf/1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="xccdf_com.example.www_benchmark_dummy" xml:lang="en-US">
53+
<status>accepted</status>
54+
<version>1.0</version>
55+
56+
<Profile id="xccdf_com.example.www_profile_test_remote_res">
57+
<title>xccdf_test_profile</title>
58+
<description>This profile is for testing.</description>
59+
<select idref="xccdf_com.example.www_rule_test-pass" selected="true"/>
60+
<select idref="xccdf_com.example.www_rule_test-remote_res" selected="true"/>
61+
</Profile>
62+
63+
<Value id="xccdf_com.example.www_value_val1" type="number" operator="equals" interactive="0">
64+
<title>test value</title>
65+
<description>foo</description>
66+
<value selector="bar_1">50</value>
67+
<value selector="bar_2">100</value>
68+
</Value>
69+
<Rule selected="true" id="xccdf_com.example.www_rule_test-pass">
70+
<title>This rule always pass</title>
71+
<check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
72+
<check-content-ref href="test_single_rule.oval.xml" name="oval:test-pass:def:1"/>
73+
</check>
74+
</Rule>
75+
<Rule selected="true" id="xccdf_com.example.www_rule_test-remote_res">
76+
<title>This rule checks remote resource</title>
77+
<check system="http://oval.mitre.org/XMLSchema/oval-definitions-5" multi-check="true">
78+
<check-content-ref href="security-data-oval.xml.bz2"/>
79+
</check>
80+
</Rule>
81+
<Rule selected="true" id="xccdf_com.example.www_rule_test-pass2">
82+
<title>This rule always pass</title>
83+
<check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
84+
<check-content-ref href="test_single_rule.oval.xml" name="oval:test-pass:def:1"/>
85+
</check>
86+
</Rule>
87+
</Benchmark>
88+
</ds:component>
89+
</ds:data-stream-collection>

tests/DS/test_ds.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,21 @@ function test_sds_tailoring {
414414
rm -f "$result"
415415
}
416416

417+
function test_ds_continue_without_remote_resources() {
418+
local DS="${srcdir}/$1"
419+
local PROFILE="$2"
420+
local result=$(mktemp)
421+
422+
$OSCAP xccdf eval --profile "$PROFILE" --results "$result" "$DS"
423+
424+
assert_exists 1 '//rule-result[@idref="xccdf_com.example.www_rule_test-pass"]/result[text()="pass"]'
425+
assert_exists 1 '//rule-result[@idref="xccdf_com.example.www_rule_test-remote_res"]/result[text()="notchecked"]'
426+
assert_exists 1 '//rule-result[@idref="xccdf_com.example.www_rule_test-pass2"]/result[text()="pass"]'
427+
428+
rm -f "$result"
429+
}
430+
431+
417432
# Testing.
418433
test_init "test_ds.log"
419434

@@ -454,6 +469,8 @@ test_run "rds_split_simple" test_rds_split rds_split_simple report-request.xml r
454469

455470
test_run "test_eval_complex" test_eval_complex
456471
test_run "sds_add_multiple_oval_twice_in_row" sds_add_multiple_twice
472+
test_run "test_ds_1_2_continue_without_remote_resources" test_ds_continue_without_remote_resources ds_continue_without_remote_resources/remote_content_1.2.ds.xml xccdf_com.example.www_profile_test_remote_res
473+
test_run "test_ds_1_3_continue_without_remote_resources" test_ds_continue_without_remote_resources ds_continue_without_remote_resources/remote_content_1.3.ds.xml xccdf_com.example.www_profile_test_remote_res
457474

458475
test_exit
459476

0 commit comments

Comments
 (0)