Library/scap-results: make datastream required argument
This commit is contained in:
parent
a500c86fd1
commit
9cf8ca43f2
1 changed files with 28 additions and 16 deletions
|
|
@ -60,6 +60,11 @@ Usage:
|
|||
=cut
|
||||
|
||||
function scapResPrintResults() {
|
||||
if [ $# -lt 5 ]; then
|
||||
rlLogError "scapResPrintResults: Function requres 5 arguments"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local results_xml="$1"
|
||||
local datastream="$2"
|
||||
local distro="$3"
|
||||
|
|
@ -144,7 +149,7 @@ Prints 'fail', 'error', and 'unknown' results in the following format:
|
|||
...
|
||||
|
||||
Usage:
|
||||
scapResPrintBadResults <RESULTS_XCCDF> <DISTRO> <PROFILE> <SERVER_WITH_GUI> <REMEDIATION_TYPE>
|
||||
scapResPrintBadResults <RESULTS_XCCDF> <DATASTREAM> <DISTRO> <PROFILE> <SERVER_WITH_GUI> <REMEDIATION_TYPE>
|
||||
|
||||
Returns 0 and prints results on the stdout if an XML file with results exists,
|
||||
and distro and profile are defined, non-zero otherwise.
|
||||
|
|
@ -152,19 +157,25 @@ and distro and profile are defined, non-zero otherwise.
|
|||
=cut
|
||||
|
||||
function scapResPrintBadResults() {
|
||||
if [ $# -lt 4 ]; then
|
||||
rlLogError "scapResPrintBadResults: Function requres 4 arguments"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local results_xml="$1"
|
||||
local distro="$2"
|
||||
local profile="${3#"xccdf_org.ssgproject.content_profile_"}"
|
||||
local server_with_gui="$4"
|
||||
local remediation_type="$5"
|
||||
local datastream="$2"
|
||||
local distro="$3"
|
||||
local profile="${4#"xccdf_org.ssgproject.content_profile_"}"
|
||||
local server_with_gui="$5"
|
||||
local remediation_type="$6"
|
||||
|
||||
if [ ! -f "$results_xml" ] || [ -z "$distro" ] || [ -z "$profile" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
scapResPrintResults "$results_xml" "$distro" "$profile" "fail" "$server_with_gui" "$remediation_type"
|
||||
scapResPrintResults "$results_xml" "$distro" "$profile" "error" "$server_with_gui" "$remediation_type"
|
||||
scapResPrintResults "$results_xml" "$distro" "$profile" "unknown" "$server_with_gui" "$remediation_type"
|
||||
scapResPrintResults "$results_xml" "$datastream" "$distro" "$profile" "fail" "$server_with_gui" "$remediation_type"
|
||||
scapResPrintResults "$results_xml" "$datastream" "$distro" "$profile" "error" "$server_with_gui" "$remediation_type"
|
||||
scapResPrintResults "$results_xml" "$datastream" "$distro" "$profile" "unknown" "$server_with_gui" "$remediation_type"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
@ -177,24 +188,25 @@ true <<'=cut'
|
|||
Assert that a document has a specific number of occurrences of a string.
|
||||
The number of the occurrences can be filtered.
|
||||
Usage:
|
||||
scapResAssertExists <STRING> <DOCUMENT> <DISTRO> <PROFILE> <SERVER_WITH_GUI> <KS_SPECIFIC_FILTER>
|
||||
scapResAssertExists <STRING> <DOCUMENT> <DATASTREAM> <DISTRO> <PROFILE> <SERVER_WITH_GUI> <KS_SPECIFIC_FILTER>
|
||||
|
||||
Returns 0 if no unexpected results are printed. Otherwise returns 1.
|
||||
|
||||
=cut
|
||||
|
||||
function scapResAssertExists() {
|
||||
if [ "$#" -lt 3 ]; then
|
||||
rlLogError "scapResAssertExists: Function requires at least 3 arguments!"
|
||||
if [ "$#" -lt 5 ]; then
|
||||
rlLogError "scapResAssertExists: Function requires at least 5 arguments!"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local result_string="$1"
|
||||
local document="$2"
|
||||
local distro="$3"
|
||||
local profile="${4#"xccdf_org.ssgproject.content_profile_"}"
|
||||
local server_with_gui="$5"
|
||||
local kickstart_filter="$(echo "$6" | tr " " "\n")"
|
||||
local datastream="$3"
|
||||
local distro="$4"
|
||||
local profile="${5#"xccdf_org.ssgproject.content_profile_"}"
|
||||
local server_with_gui="$6"
|
||||
local kickstart_filter="$(echo "$7" | tr " " "\n")"
|
||||
|
||||
# Count result occurrences when verifying that results are in the document
|
||||
if [[ "$result_string" == "//"* ]]; then
|
||||
|
|
@ -209,7 +221,7 @@ function scapResAssertExists() {
|
|||
fi
|
||||
fi
|
||||
|
||||
local results="$(scapResPrintResults "$document" "$distro" "$profile" "$result_string" "$server_with_gui")"
|
||||
local results="$(scapResPrintResults "$document" "$datastream" "$distro" "$profile" "$result_string" "$server_with_gui")"
|
||||
|
||||
local kickstart_results=""
|
||||
if [ -n "$results" ]; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue