-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a simple test that covers a situation when the probe collects more items than the limit for a single OVAL object.
- Loading branch information
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_oscap_test("collect_limit.sh") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0"?> | ||
<oval_definitions xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5" xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5" xmlns:ind="http://oval.mitre.org/XMLSchema/oval-definitions-5#independent" 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"> | ||
<generator> | ||
<oval:schema_version>5.10.1</oval:schema_version> | ||
<oval:timestamp>0001-01-01T00:00:00+00:00</oval:timestamp> | ||
</generator> | ||
|
||
<definitions> | ||
<definition class="compliance" version="1" id="oval:x:def:1"> | ||
<metadata> | ||
<title>x</title> | ||
<description>x</description> | ||
<affected family="unix"> | ||
<platform>x</platform> | ||
</affected> | ||
</metadata> | ||
<criteria> | ||
<criterion test_ref="oval:x:tst:1" comment="always pass"/> | ||
</criteria> | ||
</definition> | ||
</definitions> | ||
|
||
<tests> | ||
<ind:textfilecontent54_test id="oval:x:tst:1" version="1" comment="Test" check="all"> | ||
<ind:object object_ref="oval:x:obj:1"/> | ||
</ind:textfilecontent54_test> | ||
</tests> | ||
|
||
<objects> | ||
<ind:textfilecontent54_object id="oval:x:obj:1" version="1" comment="The object matches each line in /tmp/longfile."> | ||
<ind:filepath>/tmp/longfile</ind:filepath> | ||
<ind:pattern operation="pattern match">^.*$</ind:pattern> | ||
<ind:instance datatype="int" operation="greater than or equal">1</ind:instance> | ||
</ind:textfilecontent54_object> | ||
</objects> | ||
|
||
</oval_definitions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
set -e -o pipefail | ||
|
||
. $builddir/tests/test_common.sh | ||
|
||
# PROBE_ITEM_COLLECT_MAX limit is 1000 | ||
seq 1010 > /tmp/longfile | ||
result=$(mktemp) | ||
$OSCAP oval eval --results "$result" $srcdir/collect_limit.oval.xml | ||
assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object' | ||
assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object[@flag="incomplete"]' | ||
assert_exists 1 '/oval_results/results/system/oval_system_characteristics/collected_objects/object/message[@level="warning"]' | ||
text="Object is incomplete because the object matches more than 1000 items." | ||
assert_exists 1 "/oval_results/results/system/oval_system_characteristics/collected_objects/object/message[text()=\"$text\"]" | ||
assert_exists 1000 '/oval_results/results/system/oval_system_characteristics/system_data/ind-sys:textfilecontent_item' | ||
rm -f /tmp/longfile | ||
rm -f "$result" |