Skip to content

Commit

Permalink
Merge pull request #1689 from evgenyz/skip-validation
Browse files Browse the repository at this point in the history
Add --skip-validation option synonym for --skip-valid
  • Loading branch information
jan-cerny authored Feb 17, 2021
2 parents b8c3f2e + eee3778 commit c9bd416
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 21 deletions.
16 changes: 8 additions & 8 deletions dist/bash_completion.d/oscap
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ function _oscap {
local -A opts=()
opts[oscap]="--version --quiet --help -V -q -h"
opts[oscap:oval:validate]="--version --definitions --variables --syschar --results --directives --schematron"
opts[oscap:oval:eval]="--datastream-id --oval-id --id --variables --directives --without-syschar --results --report --skip-valid --fetch-remote-resources --verbose --verbose-log-file"
opts[oscap:oval:eval]="--datastream-id --oval-id --id --variables --directives --without-syschar --results --report --skip-valid --skip-validation --fetch-remote-resources --verbose --verbose-log-file"
opts[oscap:oval:analyse]="--variables --directives --verbose --verbose-log-file"
opts[oscap:oval:collect]="--variables --verbose --verbose-log-file"
opts[oscap:oval:generate:report]="-o --output"
opts[oscap:xccdf:eval]="--benchmark-id --check-engine-results --cpe --datastream-id --export-variables --fetch-remote-resources --oval-results --profile --progress --remediate --report --results --results-arf --rule --skip-valid --stig-viewer --tailoring-file --tailoring-id --thin-results --verbose --verbose-log-file --without-syschar --xccdf-id"
opts[oscap:xccdf:validate]="--schematron"
opts[oscap:xccdf:export-oval-variables]="--datastream-id --xccdf-id --profile --skip-valid --fetch-remote-resources --cpe"
opts[oscap:xccdf:remediate]="--result-id --skip-valid --fetch-remote-resources --results --results-arf --report --oval-results --export-variables --cpe"
opts[oscap:xccdf:export-oval-variables]="--datastream-id --xccdf-id --profile --skip-valid --skip-validation --fetch-remote-resources --cpe"
opts[oscap:xccdf:remediate]="--result-id --skip-valid --skip-validation --fetch-remote-resources --results --results-arf --report --oval-results --export-variables --cpe"
opts[oscap:xccdf:resolve]="-o --output -f --force"
opts[oscap:xccdf:generate]="--profile"
opts[oscap:xccdf:generate:report]="-o --output -i --result-id --profile --oval-template"
opts[oscap:xccdf:generate:guide]="-o --output --hide-profile-info --profile"
opts[oscap:xccdf:generate:fix]="-o --output --template --profile --result-id --profile"
opts[oscap:xccdf:generate:custom]="-o --output --stylesheet"
opts[oscap:ds:sds-add]="--datastream-id --skip-valid"
opts[oscap:ds:sds-compose]="--skip-valid"
opts[oscap:ds:sds-split]="--datastream-id --xccdf-id --skip-valid --fetch-remote-resources"
opts[oscap:ds:rds-create]="--skip-valid"
opts[oscap:ds:rds-split]="--report-id --skip-valid"
opts[oscap:ds:sds-add]="--datastream-id --skip-valid --skip-validation"
opts[oscap:ds:sds-compose]="--skip-valid --skip-validation"
opts[oscap:ds:sds-split]="--datastream-id --xccdf-id --skip-valid --skip-validation --fetch-remote-resources"
opts[oscap:ds:rds-create]="--skip-valid --skip-validation"
opts[oscap:ds:rds-split]="--report-id --skip-valid --skip-validation"
opts[oscap:cvss:score]=""
opts[oscap:cvss:describe]=""
opts[oscap:info]="--fetch-remote-resources --profile --profiles"
Expand Down
2 changes: 1 addition & 1 deletion docs/manual/manual.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ $ oscap oval validate --schematron oval-file.xml
The results of validation are printed to standard error stream (stderr).

NOTE: Please note that for the rest of `oscap` functionality, unless you specify
--skip-valid, validation will automatically occur before files are used.
--skip-validation (--skip-valid), validation will automatically occur before files are used.
Therefore, you do not need to explicitly validate a datastream before
use.

Expand Down
2 changes: 1 addition & 1 deletion tests/API/OVAL/unittests/test_skip_valid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ stderr=`mktemp`
set -e
set -o pipefail

$OSCAP oval eval --results $result --skip-valid $srcdir/test_skip_valid.oval.xml 2> $stderr
$OSCAP oval eval --results $result --skip-validation $srcdir/test_skip_valid.oval.xml 2> $stderr

grep -q "Unable to export unknown state" $stderr

Expand Down
2 changes: 1 addition & 1 deletion tests/API/XCCDF/unittests/test_remediate_python_subs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ echo "Stderr file = $stderr"
echo "Result file = $stderr"
rm -f test_file

$OSCAP xccdf remediate --skip-valid --results $result $srcdir/${name}.xccdf.xml 2> $stderr
$OSCAP xccdf remediate --skip-validation --results $result $srcdir/${name}.xccdf.xml 2> $stderr
[ -f $stderr ]; [ ! -s $stderr ]; rm $stderr
[ -f test_file ]; rm test_file

Expand Down
2 changes: 1 addition & 1 deletion tests/API/XCCDF/unittests/test_remediate_unresolved.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ echo "Stderr file = $stderr"
echo "Result file = $stderr"
rm -f test_file

$OSCAP xccdf remediate --skip-valid --results $result $srcdir/${name}.xccdf.xml 2> $stderr || ret=$?
$OSCAP xccdf remediate --skip-validation --results $result $srcdir/${name}.xccdf.xml 2> $stderr || ret=$?
[ $ret -eq 2 ]
[ -f $stderr ]; [ ! -s $stderr ]; rm $stderr

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ for args in "" "--profile xccdf_moc.elpmaxe.www_profile_1"; do
stderr=$(mktemp -t ${name}.out.XXXXXX)
# If an <xccdf:Rule> contains an <xccdf:complex-check>, then the benchmark consumer MUST process it
# and MUST ignore any <xccdf:check> elements that are also contained by the <xccdf:Rule>.
$OSCAP xccdf eval --skip-valid --results $result $srcdir/${name}.xccdf.xml 2> $stderr
$OSCAP xccdf eval --skip-validation --results $result $srcdir/${name}.xccdf.xml 2> $stderr

echo "Stderr file = $stderr"
echo "Result file = $result"
Expand Down
3 changes: 3 additions & 0 deletions utils/oscap-chroot
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function usage()
echo " --results-arf"
echo " --report"
echo " --skip-valid"
echo " --skip-validation"
echo " --fetch-remote-resources"
echo " --progress"
echo " --datastream-id"
Expand All @@ -66,6 +67,7 @@ function usage()
echo " --results"
echo " --report"
echo " --skip-valid"
echo " --skip-validation"
echo " --datastream-id"
echo " --oval-id"
echo
Expand All @@ -76,6 +78,7 @@ function usage()
echo " --syschar"
echo " --variables"
echo " --skip-valid"
echo " --skip-validation"
echo
echo "See \`man oscap\` to learn more about semantics of these options."
}
Expand Down
3 changes: 3 additions & 0 deletions utils/oscap-chroot.8
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ supported oscap xccdf eval options are:
--results-arf
--report
--skip-valid
--skip-validation
--fetch-remote-resources
--progress
--datastream-id
Expand All @@ -37,6 +38,7 @@ supported oscap oval eval options are:
--results
--report
--skip-valid
--skip-validation
--datastream-id
--oval-id

Expand All @@ -48,6 +50,7 @@ supported oscap oval collect options are:
--syschar
--variables
--skip-valid
--skip-validation


.SH REPORTING BUGS
Expand Down
14 changes: 10 additions & 4 deletions utils/oscap-ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ static struct oscap_module DS_SDS_SPLIT_MODULE = {
" --datastream-id <id> - ID of the datastream in the collection to use.\n"
" --xccdf-id <id> - ID of XCCDF in the datastream that should be evaluated.\n"
" --skip-valid - Skips validating of given XCCDF.\n"
" --skip-validation\n"
" --fetch-remote-resources - Download remote content referenced by DataStream.\n",
.opt_parser = getopt_ds,
.func = app_ds_sds_split
Expand All @@ -92,7 +93,8 @@ static struct oscap_module DS_SDS_COMPOSE_MODULE = {
.summary = "Compose SourceDataStream from given XCCDF",
.usage = "[options] xccdf-file.xml target_datastream.xml",
.help = "Options:\n"
" --skip-valid - Skips validating of given XCCDF.\n",
" --skip-valid - Skips validating of given XCCDF.\n"
" --skip-validation\n",
.opt_parser = getopt_ds,
.func = app_ds_sds_compose
};
Expand All @@ -104,7 +106,8 @@ static struct oscap_module DS_SDS_ADD_MODULE = {
.usage = "[options] new-component.xml existing_datastream.xml",
.help = "Options:\n"
" --datastream-id <id> - ID of the datastream in the collection for adding to.\n"
" --skip-valid - Skips validating of given XCCDF.\n",
" --skip-valid - Skips validating of given XCCDF.\n"
" --skip-validation\n",
.opt_parser = getopt_ds,
.func = app_ds_sds_add
};
Expand All @@ -126,7 +129,8 @@ static struct oscap_module DS_RDS_SPLIT_MODULE = {
.usage = "[OPTIONS] rds.xml TARGET_DIRECTORY",
.help = "Options:\n"
" --report-id <id> - ID of report inside ARF that should be split.\n"
" --skip-valid - Skips validating of given XCCDF.\n",
" --skip-valid - Skips validating of given XCCDF.\n"
" --skip-validation\n",
.opt_parser = getopt_ds,
.func = app_ds_rds_split
};
Expand All @@ -137,7 +141,8 @@ static struct oscap_module DS_RDS_CREATE_MODULE = {
.summary = "Create a ResultDataStream from given SourceDataStream, XCCDF results and one or more OVAL results",
.usage = "[options] sds.xml target-arf.xml results-xccdf.xml [results-oval1.xml [results-oval2.xml]]",
.help = "Options:\n"
" --skip-valid - Skips validating of given XCCDF.\n",
" --skip-valid - Skips validating of given XCCDF.\n"
" --skip-validation\n",
.opt_parser = getopt_ds,
.func = app_ds_rds_create
};
Expand Down Expand Up @@ -176,6 +181,7 @@ bool getopt_ds(int argc, char **argv, struct oscap_action *action) {
const struct option long_options[] = {
// options
{"skip-valid", no_argument, &action->validate, 0},
{"skip-validation", no_argument, &action->validate, 0},
{"datastream-id", required_argument, NULL, DS_OPT_DATASTREAM_ID},
{"xccdf-id", required_argument, NULL, DS_OPT_XCCDF_ID},
{"report-id", required_argument, NULL, DS_OPT_REPORT_ID},
Expand Down
10 changes: 8 additions & 2 deletions utils/oscap-oval.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ static struct oscap_module OVAL_EVAL = {
" --results <file> - Write OVAL Results into file.\n"
" --report <file> - Create human readable (HTML) report from OVAL Results.\n"
" --skip-valid - Skip validation.\n"
" --skip-validation\n"
" --datastream-id <id> - ID of the datastream in the collection to use.\n"
" (only applicable for source datastreams)\n"
" --oval-id <id> - ID of the OVAL component ref in the datastream to use.\n"
Expand All @@ -129,7 +130,8 @@ static struct oscap_module OVAL_COLLECT = {
" --id <object> - Collect system characteristics ONLY for specified OVAL Object.\n"
" --syschar <file> - Write OVAL System Characteristic into file.\n"
" --variables <file> - Provide external variables expected by OVAL Definitions.\n"
" --skip-valid - Skip validation.\n",
" --skip-valid - Skip validation.\n"
" --skip-validation\n",
.opt_parser = getopt_oval_collect,
.func = app_collect_oval
};
Expand All @@ -144,7 +146,8 @@ static struct oscap_module OVAL_ANALYSE = {
"Options:\n"
" --variables <file> - Provide external variables expected by OVAL Definitions.\n"
" --directives <file> - Use OVAL Directives content to specify desired results content.\n"
" --skip-valid - Skip validation.\n",
" --skip-valid - Skip validation.\n"
" --skip-validation\n",
.opt_parser = getopt_oval_analyse,
.func = app_analyse_oval
};
Expand Down Expand Up @@ -515,6 +518,7 @@ bool getopt_oval_eval(int argc, char **argv, struct oscap_action *action)
{ "datastream-id",required_argument, NULL, OVAL_OPT_DATASTREAM_ID},
{ "oval-id", required_argument, NULL, OVAL_OPT_OVAL_ID},
{ "skip-valid", no_argument, &action->validate, 0 },
{ "skip-validation", no_argument, &action->validate, 0 },
{ "fetch-remote-resources", no_argument, &action->remote_resources, 1},
{ 0, 0, 0, 0 }
};
Expand Down Expand Up @@ -554,6 +558,7 @@ bool getopt_oval_collect(int argc, char **argv, struct oscap_action *action)
{ "variables", required_argument, NULL, OVAL_OPT_VARIABLES },
{ "syschar", required_argument, NULL, OVAL_OPT_SYSCHAR },
{ "skip-valid", no_argument, &action->validate, 0 },
{ "skip-validation", no_argument, &action->validate, 0 },
{ 0, 0, 0, 0 }
};

Expand Down Expand Up @@ -587,6 +592,7 @@ bool getopt_oval_analyse(int argc, char **argv, struct oscap_action *action)
{ "variables", required_argument, NULL, OVAL_OPT_VARIABLES },
{ "directives", required_argument, NULL, OVAL_OPT_DIRECTIVES },
{ "skip-valid", no_argument, &action->validate, 0 },
{ "skip-validation", no_argument, &action->validate, 0 },
{ 0, 0, 0, 0 }
};

Expand Down
3 changes: 3 additions & 0 deletions utils/oscap-ssh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function usage()
echo " --results-arf"
echo " --report"
echo " --skip-valid"
echo " --skip-validation"
echo " --fetch-remote-resources"
echo " --progress"
echo " --datastream-id"
Expand All @@ -68,6 +69,7 @@ function usage()
echo " --results"
echo " --report"
echo " --skip-valid"
echo " --skip-validation"
echo " --datastream-id"
echo " --oval-id"
echo
Expand All @@ -78,6 +80,7 @@ function usage()
echo " --syschar"
echo " --variables"
echo " --skip-valid"
echo " --skip-validation"
echo
echo "specific option for oscap-ssh (must be first argument):"
echo " --sudo"
Expand Down
3 changes: 3 additions & 0 deletions utils/oscap-ssh.8
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Supported options are:
--results-arf
--report
--skip-valid
--skip-validation
--fetch-remote-resources
--progress
--datastream-id
Expand All @@ -44,6 +45,7 @@ Supported options are:
--results
--report
--skip-valid
--skip-validation
--datastream-id
--oval-id

Expand All @@ -55,6 +57,7 @@ Supported options are:
--syschar
--variables
--skip-valid
--skip-validation

Specific option for oscap-ssh (must be first argument):
--sudo
Expand Down
3 changes: 3 additions & 0 deletions utils/oscap-vm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function usage()
echo " --results-arf"
echo " --report"
echo " --skip-valid"
echo " --skip-validation"
echo " --fetch-remote-resources"
echo " --progress"
echo " --datastream-id"
Expand All @@ -65,6 +66,7 @@ function usage()
echo " --results"
echo " --report"
echo " --skip-valid"
echo " --skip-validation"
echo " --datastream-id"
echo " --oval-id"
echo
Expand All @@ -76,6 +78,7 @@ function usage()
echo " --syschar"
echo " --variables"
echo " --skip-valid"
echo " --skip-validation"
echo
echo "See \`man oscap\` to learn more about semantics of these options."
}
Expand Down
3 changes: 3 additions & 0 deletions utils/oscap-vm.8
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Supported oscap xccdf eval options are:
\-\-without-syschar
\-\-report <file>
\-\-skip-valid
\-\-skip-validation
\-\-fetch-remote-resources
\-\-progress
\-\-datastream-id <id>
Expand Down Expand Up @@ -92,6 +93,7 @@ Supported oscap oval eval options are:
\-\-results <file>
\-\-report <file>
\-\-skip-valid
\-\-skip-validation
\-\-datastream-id <id>
\-\-oval-id <id>

Expand All @@ -113,6 +115,7 @@ Supported oscap oval collect options are:
\-\-syschar <file>
\-\-variables <file>
\-\-skip-valid
\-\-skip-validation

.SH EXAMPLES

Expand Down
4 changes: 4 additions & 0 deletions utils/oscap-xccdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ static struct oscap_module XCCDF_EXPORT_OVAL_VARIABLES = {
.help = "Options:\n"
" --profile <name> - The name of Profile to be evaluated.\n"
" --skip-valid - Skip validation.\n"
" --skip-validation\n"
" --fetch-remote-resources - Download remote content referenced by XCCDF.\n"
" --datastream-id <id> - ID of the datastream in the collection to use.\n"
" (only applicable for source datastreams)\n"
Expand Down Expand Up @@ -165,6 +166,7 @@ static struct oscap_module XCCDF_EVAL = {
" --without-syschar - Don't provide system characteristic in OVAL/ARF result files.\n"
" --report <file> - Write HTML report into file.\n"
" --skip-valid - Skip validation.\n"
" --skip-validation\n"
" --fetch-remote-resources - Download remote content referenced by XCCDF.\n"
" --progress - Switch to sparse output suitable for progress reporting.\n"
" Format is \"$rule_id:$result\\n\".\n"
Expand All @@ -190,6 +192,7 @@ static struct oscap_module XCCDF_REMEDIATE = {
"Options:\n"
" --result-id - TestResult ID to be processed. Default is the most recent one.\n"
" --skip-valid - Skip validation.\n"
" --skip-validation\n"
" --cpe <name> - Use given CPE dictionary or language (autodetected)\n"
" for applicability checks.\n"
" --fetch-remote-resources - Download remote content referenced by XCCDF.\n"
Expand Down Expand Up @@ -1141,6 +1144,7 @@ bool getopt_xccdf(int argc, char **argv, struct oscap_action *action)
{"oval-results", no_argument, &action->oval_results, 1},
{"check-engine-results", no_argument, &action->check_engine_results, 1},
{"skip-valid", no_argument, &action->validate, 0},
{"skip-validation", no_argument, &action->validate, 0},
{"fetch-remote-resources", no_argument, &action->remote_resources, 1},
{"progress", no_argument, &action->progress, 1},
{"remediate", no_argument, &action->remediate, 1},
Expand Down
Loading

0 comments on commit c9bd416

Please sign in to comment.