Skip to content

Commit 57ccbea

Browse files
committed
Drop verbose options from some modules
Verbose options are now global options. We don't have to specify them in each module explicitely, that would be a conflict with the global options.
1 parent f0e7239 commit 57ccbea

File tree

3 files changed

+7
-103
lines changed

3 files changed

+7
-103
lines changed

utils/oscap-ds.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ static struct oscap_module DS_RDS_VALIDATE_MODULE = {
147147
.parent = &OSCAP_DS_MODULE,
148148
.summary = "Validate given ResultDataStream",
149149
.usage = "[options] result_datastream.xml",
150-
.help = "Options:\n"
151-
" --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
152-
" --verbose-log-file <file> - Write verbose informations into file.\n",
150+
.help = NULL,
153151
.opt_parser = getopt_ds,
154152
.func = app_ds_rds_validate
155153
};
@@ -168,9 +166,7 @@ static struct oscap_module* DS_SUBMODULES[DS_SUBMODULES_NUM] = {
168166
enum ds_opt {
169167
DS_OPT_DATASTREAM_ID = 1,
170168
DS_OPT_XCCDF_ID,
171-
DS_OPT_REPORT_ID,
172-
DS_OPT_VERBOSE,
173-
DS_OPT_VERBOSE_LOG_FILE,
169+
DS_OPT_REPORT_ID
174170
};
175171

176172
bool getopt_ds(int argc, char **argv, struct oscap_action *action) {
@@ -184,8 +180,6 @@ bool getopt_ds(int argc, char **argv, struct oscap_action *action) {
184180
{"xccdf-id", required_argument, NULL, DS_OPT_XCCDF_ID},
185181
{"report-id", required_argument, NULL, DS_OPT_REPORT_ID},
186182
{"fetch-remote-resources", no_argument, &action->remote_resources, 1},
187-
{"verbose", required_argument, NULL, DS_OPT_VERBOSE },
188-
{"verbose-log-file", required_argument, NULL, DS_OPT_VERBOSE_LOG_FILE },
189183
// end
190184
{0, 0, 0, 0}
191185
};
@@ -197,8 +191,6 @@ bool getopt_ds(int argc, char **argv, struct oscap_action *action) {
197191
case DS_OPT_DATASTREAM_ID: action->f_datastream_id = optarg; break;
198192
case DS_OPT_XCCDF_ID: action->f_xccdf_id = optarg; break;
199193
case DS_OPT_REPORT_ID: action->f_report_id = optarg; break;
200-
case DS_OPT_VERBOSE: action->verbosity_level = optarg; break;
201-
case DS_OPT_VERBOSE_LOG_FILE: action->f_verbose_log = optarg; break;
202194
case 0: break;
203195
default: return oscap_module_usage(action->module, stderr, NULL);
204196
}
@@ -541,10 +533,6 @@ int app_ds_rds_create(const struct oscap_action *action) {
541533
int app_ds_rds_validate(const struct oscap_action *action) {
542534
int ret = OSCAP_ERROR;
543535

544-
if (!oscap_set_verbose(action->verbosity_level, action->f_verbose_log, false)) {
545-
return OSCAP_ERROR;
546-
}
547-
548536
struct oscap_source *rds = oscap_source_new_from_file(action->ds_action->file);
549537
if (oscap_source_validate(rds, reporter, (void *) action) != 0) {
550538
oscap_source_free(rds);

utils/oscap-oval.c

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ static struct oscap_module OVAL_EVAL = {
112112
" --datastream-id <id> - ID of the datastream in the collection to use.\n"
113113
" (only applicable for source datastreams)\n"
114114
" --oval-id <id> - ID of the OVAL component ref in the datastream to use.\n"
115-
" (only applicable for source datastreams)\n"
116-
" --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
117-
" --verbose-log-file <file> - Write verbose information into file.\n",
115+
" (only applicable for source datastreams)\n",
118116
.opt_parser = getopt_oval_eval,
119117
.func = app_evaluate_oval
120118
};
@@ -129,9 +127,7 @@ static struct oscap_module OVAL_COLLECT = {
129127
" --id <object> - Collect system characteristics ONLY for specified OVAL Object.\n"
130128
" --syschar <file> - Write OVAL System Characteristic into file.\n"
131129
" --variables <file> - Provide external variables expected by OVAL Definitions.\n"
132-
" --skip-valid - Skip validation.\n"
133-
" --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
134-
" --verbose-log-file <file> - Write verbose information into file.\n",
130+
" --skip-valid - Skip validation.\n",
135131
.opt_parser = getopt_oval_collect,
136132
.func = app_collect_oval
137133
};
@@ -146,9 +142,7 @@ static struct oscap_module OVAL_ANALYSE = {
146142
"Options:\n"
147143
" --variables <file> - Provide external variables expected by OVAL Definitions.\n"
148144
" --directives <file> - Use OVAL Directives content to specify desired results content.\n"
149-
" --skip-valid - Skip validation.\n"
150-
" --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
151-
" --verbose-log-file <file> - Write verbose information into file.\n",
145+
" --skip-valid - Skip validation.\n",
152146
.opt_parser = getopt_oval_analyse,
153147
.func = app_analyse_oval
154148
};
@@ -210,11 +204,6 @@ int app_collect_oval(const struct oscap_action *action)
210204
struct oval_generator *generator = NULL;
211205
int ret = OSCAP_ERROR;
212206

213-
/* Turn on verbosity */
214-
if (!oscap_set_verbose(action->verbosity_level, action->f_verbose_log, false)) {
215-
goto cleanup;
216-
}
217-
218207
/* validate inputs */
219208
if (action->validate) {
220209
if (!valid_inputs(action)) {
@@ -331,11 +320,6 @@ int app_evaluate_oval(const struct oscap_action *action)
331320
oval_result_t eval_result;
332321
int ret = OSCAP_ERROR;
333322

334-
/* Turn on verbosity */
335-
if (!oscap_set_verbose(action->verbosity_level, action->f_verbose_log, false)) {
336-
goto cleanup;
337-
}
338-
339323
/* create a new OVAL session */
340324
if ((session = oval_session_new(action->f_oval)) == NULL) {
341325
oscap_print_error();
@@ -399,11 +383,6 @@ static int app_analyse_oval(const struct oscap_action *action) {
399383
struct oval_generator *generator = NULL;
400384
int ret = OSCAP_ERROR;
401385

402-
/* Turn on verbosity */
403-
if (!oscap_set_verbose(action->verbosity_level, action->f_verbose_log, false)) {
404-
goto cleanup;
405-
}
406-
407386
/* validate inputs */
408387
if (action->validate) {
409388
if (!valid_inputs(action)) {
@@ -515,9 +494,7 @@ enum oval_opt {
515494
OVAL_OPT_DIRECTIVES,
516495
OVAL_OPT_DATASTREAM_ID,
517496
OVAL_OPT_OVAL_ID,
518-
OVAL_OPT_OUTPUT = 'o',
519-
OVAL_OPT_VERBOSE,
520-
OVAL_OPT_VERBOSE_LOG_FILE
497+
OVAL_OPT_OUTPUT = 'o'
521498
};
522499

523500
#if defined(OVAL_PROBES_ENABLED)
@@ -536,8 +513,6 @@ bool getopt_oval_eval(int argc, char **argv, struct oscap_action *action)
536513
{ "datastream-id",required_argument, NULL, OVAL_OPT_DATASTREAM_ID},
537514
{ "oval-id", required_argument, NULL, OVAL_OPT_OVAL_ID},
538515
{ "skip-valid", no_argument, &action->validate, 0 },
539-
{ "verbose", required_argument, NULL, OVAL_OPT_VERBOSE },
540-
{ "verbose-log-file", required_argument, NULL, OVAL_OPT_VERBOSE_LOG_FILE },
541516
{ "fetch-remote-resources", no_argument, &action->remote_resources, 1},
542517
{ 0, 0, 0, 0 }
543518
};
@@ -552,19 +527,10 @@ bool getopt_oval_eval(int argc, char **argv, struct oscap_action *action)
552527
case OVAL_OPT_DIRECTIVES: action->f_directives = optarg; break;
553528
case OVAL_OPT_DATASTREAM_ID: action->f_datastream_id = optarg; break;
554529
case OVAL_OPT_OVAL_ID: action->f_oval_id = optarg; break;
555-
case OVAL_OPT_VERBOSE:
556-
action->verbosity_level = optarg;
557-
break;
558-
case OVAL_OPT_VERBOSE_LOG_FILE:
559-
action->f_verbose_log = optarg;
560-
break;
561530
case 0: break;
562531
default: return oscap_module_usage(action->module, stderr, NULL);
563532
}
564533
}
565-
if (!check_verbose_options(action)) {
566-
return false;
567-
}
568534

569535
/* We should have Definitions file here */
570536
if (optind >= argc)
@@ -586,8 +552,6 @@ bool getopt_oval_collect(int argc, char **argv, struct oscap_action *action)
586552
{ "variables", required_argument, NULL, OVAL_OPT_VARIABLES },
587553
{ "syschar", required_argument, NULL, OVAL_OPT_SYSCHAR },
588554
{ "skip-valid", no_argument, &action->validate, 0 },
589-
{ "verbose", required_argument, NULL, OVAL_OPT_VERBOSE },
590-
{ "verbose-log-file", required_argument, NULL, OVAL_OPT_VERBOSE_LOG_FILE },
591555
{ 0, 0, 0, 0 }
592556
};
593557

@@ -597,19 +561,10 @@ bool getopt_oval_collect(int argc, char **argv, struct oscap_action *action)
597561
case OVAL_OPT_ID: action->id = optarg; break;
598562
case OVAL_OPT_VARIABLES: action->f_variables = optarg; break;
599563
case OVAL_OPT_SYSCHAR: action->f_syschar = optarg; break;
600-
case OVAL_OPT_VERBOSE:
601-
action->verbosity_level = optarg;
602-
break;
603-
case OVAL_OPT_VERBOSE_LOG_FILE:
604-
action->f_verbose_log = optarg;
605-
break;
606564
case 0: break;
607565
default: return oscap_module_usage(action->module, stderr, NULL);
608566
}
609567
}
610-
if (!check_verbose_options(action)) {
611-
return false;
612-
}
613568

614569
/* We should have Definitions file here */
615570
if (optind >= argc)
@@ -630,8 +585,6 @@ bool getopt_oval_analyse(int argc, char **argv, struct oscap_action *action)
630585
{ "variables", required_argument, NULL, OVAL_OPT_VARIABLES },
631586
{ "directives", required_argument, NULL, OVAL_OPT_DIRECTIVES },
632587
{ "skip-valid", no_argument, &action->validate, 0 },
633-
{ "verbose", required_argument, NULL, OVAL_OPT_VERBOSE },
634-
{ "verbose-log-file", required_argument, NULL, OVAL_OPT_VERBOSE_LOG_FILE },
635588
{ 0, 0, 0, 0 }
636589
};
637590

@@ -641,19 +594,10 @@ bool getopt_oval_analyse(int argc, char **argv, struct oscap_action *action)
641594
case OVAL_OPT_RESULT_FILE: action->f_results = optarg; break;
642595
case OVAL_OPT_VARIABLES: action->f_variables = optarg; break;
643596
case OVAL_OPT_DIRECTIVES: action->f_directives = optarg; break;
644-
case OVAL_OPT_VERBOSE:
645-
action->verbosity_level = optarg;
646-
break;
647-
case OVAL_OPT_VERBOSE_LOG_FILE:
648-
action->f_verbose_log = optarg;
649-
break;
650597
case 0: break;
651598
default: return oscap_module_usage(action->module, stderr, NULL);
652599
}
653600
}
654-
if (!check_verbose_options(action)) {
655-
return false;
656-
}
657601

658602
/* We should have Definitions file here */
659603
if (optind >= argc)

utils/oscap-xccdf.c

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ static struct oscap_module XCCDF_EVAL = {
175175
" (only applicable for source datastreams)\n"
176176
" (only applicable when datastream-id AND xccdf-id are not specified)\n"
177177
" --remediate - Automatically execute XCCDF fix elements for failed rules.\n"
178-
" Use of this option is always at your own risk.\n"
179-
" --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
180-
" --verbose-log-file <file> - Write verbose informations into file.\n",
178+
" Use of this option is always at your own risk.\n",
181179
.opt_parser = getopt_xccdf,
182180
.func = app_evaluate_xccdf
183181
};
@@ -203,8 +201,6 @@ static struct oscap_module XCCDF_REMEDIATE = {
203201
" --check-engine-results - Save results from check engines loaded from plugins as well.\n"
204202
" --progress - Switch to sparse output suitable for progress reporting.\n"
205203
" Format is \"$rule_id:$result\\n\".\n"
206-
" --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
207-
" --verbose-log-file <file> - Write verbose informations into file.\n"
208204
,
209205
.opt_parser = getopt_xccdf,
210206
.func = app_xccdf_remediate
@@ -540,9 +536,6 @@ int app_evaluate_xccdf(const struct oscap_action *action)
540536
int result = OSCAP_ERROR;
541537
#if defined(HAVE_SYSLOG_H)
542538
int priority = LOG_NOTICE;
543-
if (!oscap_set_verbose(action->verbosity_level, action->f_verbose_log, false)) {
544-
goto cleanup;
545-
}
546539

547540
/* syslog message */
548541
syslog(priority, "Evaluation started. Content: %s, Profile: %s.", action->f_xccdf, action->profile);
@@ -710,10 +703,6 @@ static int app_xccdf_export_oval_variables(const struct oscap_action *action)
710703

711704
int app_xccdf_remediate(const struct oscap_action *action)
712705
{
713-
if (!oscap_set_verbose(action->verbosity_level, action->f_verbose_log, false)) {
714-
return OSCAP_ERROR;
715-
}
716-
717706
struct xccdf_session *session = NULL;
718707
int result = OSCAP_ERROR;
719708
session = xccdf_session_new(action->f_xccdf);
@@ -866,10 +855,6 @@ int app_generate_fix(const struct oscap_action *action)
866855
struct ds_rds_session *arf_session = NULL;
867856
const char *template = NULL;
868857

869-
if (!oscap_set_verbose(action->verbosity_level, action->f_verbose_log, false)) {
870-
return OSCAP_ERROR;
871-
}
872-
873858
if (action->fix_type != NULL && action->tmpl != NULL) {
874859
/* Avoid undefined situations, eg.:
875860
* oscap xccdf generate fix --fix-type ansible --template urn:xccdf:fix:scipt:sh
@@ -1074,8 +1059,6 @@ enum oval_opt {
10741059
XCCDF_OPT_CPE_DICT,
10751060
XCCDF_OPT_OUTPUT = 'o',
10761061
XCCDF_OPT_RESULT_ID = 'i',
1077-
XCCDF_OPT_VERBOSE,
1078-
XCCDF_OPT_VERBOSE_LOG_FILE,
10791062
XCCDF_OPT_FIX_TYPE
10801063
};
10811064

@@ -1107,8 +1090,6 @@ bool getopt_xccdf(int argc, char **argv, struct oscap_action *action)
11071090
{"cpe", required_argument, NULL, XCCDF_OPT_CPE},
11081091
{"cpe-dict", required_argument, NULL, XCCDF_OPT_CPE_DICT}, // DEPRECATED!
11091092
{"sce-template", required_argument, NULL, XCCDF_OPT_SCE_TEMPLATE},
1110-
{ "verbose", required_argument, NULL, XCCDF_OPT_VERBOSE },
1111-
{ "verbose-log-file", required_argument, NULL, XCCDF_OPT_VERBOSE_LOG_FILE },
11121093
{"fix-type", required_argument, NULL, XCCDF_OPT_FIX_TYPE},
11131094
// flags
11141095
{"force", no_argument, &action->force, 1},
@@ -1156,22 +1137,13 @@ bool getopt_xccdf(int argc, char **argv, struct oscap_action *action)
11561137
action->cpe = optarg; break;
11571138
}
11581139
case XCCDF_OPT_SCE_TEMPLATE: action->sce_template = optarg; break;
1159-
case XCCDF_OPT_VERBOSE:
1160-
action->verbosity_level = optarg;
1161-
break;
1162-
case XCCDF_OPT_VERBOSE_LOG_FILE:
1163-
action->f_verbose_log = optarg;
1164-
break;
11651140
case XCCDF_OPT_FIX_TYPE:
11661141
action->fix_type = optarg;
11671142
break;
11681143
case 0: break;
11691144
default: return oscap_module_usage(action->module, stderr, NULL);
11701145
}
11711146
}
1172-
if (!check_verbose_options(action)) {
1173-
return false;
1174-
}
11751147

11761148
if (action->module == &XCCDF_EVAL) {
11771149
/* We should have XCCDF file here */

0 commit comments

Comments
 (0)