Debian Codegraph @

utils/oscap-xccdf.c

raw symbols SCIP
1 /*
2 * Copyright 2010--2014 Red Hat Inc., Durham, North Carolina.
3 * All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 * Authors:
20 * Peter Vrabec <[email protected]>
21 */
22
23 #include "oscap_string.h"cxx . . $ `<file>/src/common/oscap_string.h`/
24 #include "oscap_text.h"cxx . . $ `<file>/src/common/public/oscap_text.h`/
25 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`!
26 #include <config.h>cxx . . $ `<file>/build/config.h`/
27 #endif
28
29 #if defined(OVAL_PROBES_ENABLEDcxx . . $ `build/config.h:67:9`!)
30 # include <oval_probe.h>cxx . . $ `<file>/src/OVAL/public/oval_probe.h`/
31 #endif
32 #include <oval_agent_api.h>cxx . . $ `<file>/src/OVAL/public/oval_agent_api.h`/
33 #include <oval_agent_xccdf_api.h>cxx . . $ `<file>/src/OVAL/public/oval_agent_xccdf_api.h`/
34 #include <oval_results.h>cxx . . $ `<file>/src/OVAL/public/oval_results.h`/
35 #include <oval_variables.h>cxx . . $ `<file>/src/OVAL/public/oval_variables.h`/
36
37 #include <scap_ds.h>cxx . . $ `<file>/src/DS/public/scap_ds.h`/
38 #include <xccdf_benchmark.h>cxx . . $ `<file>/src/XCCDF/public/xccdf_benchmark.h`/
39 #include <xccdf_policy.h>cxx . . $ `<file>/src/XCCDF_POLICY/public/xccdf_policy.h`/
40 #include <xccdf_session.h>cxx . . $ `<file>/src/XCCDF/public/xccdf_session.h`/
41 #include <ds_rds_session.h>cxx . . $ `<file>/src/DS/public/ds_rds_session.h`/
42
43 #include <sys/types.h>
44 #include <sys/stat.h>
45 #include <fcntl.h>
46 #include <errno.h>
47 #include <assert.h>
48 #include <limits.h>
49 #ifdef HAVE_GETOPT_Hcxx . . $ `build/config.h:79:9`!
50 #include <getopt.h>
51 #endif
52
53 #ifdef OS_WINDOWS
54 #include <io.h>
55 #include <windows.h>
56 #else
57 #include <unistd.h>
58 #endif
59 #if defined(HAVE_SYSLOG_Hcxx . . $ `build/config.h:70:9`!)
60 #include <syslog.h>
61 #endif
62
63 #include "oscap-tool.h"cxx . . $ `<file>/utils/oscap-tool.h`/
64 #include "oscap.h"cxx . . $ `<file>/src/common/public/oscap.h`/
65 #include "oscap_source.h"cxx . . $ `<file>/src/source/public/oscap_source.h`/
66 #include <oscap_debug.h>cxx . . $ `<file>/src/common/public/oscap_debug.h`/
67 #include "oscap_helpers.h"cxx . . $ `<file>/src/common/public/oscap_helpers.h`/
68
69 #ifndef O_NOFOLLOWcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:141:10`!
70 #define O_NOFOLLOW 0
71 #endif
72
73 static int app_evaluate_xccdfcxx . . $ app_evaluate_xccdf(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action);
74 static int app_xccdf_validatecxx . . $ app_xccdf_validate(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action);
75 static int app_xccdf_resolvecxx . . $ app_xccdf_resolve(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action);
76 static int app_xccdf_export_oval_variablescxx . . $ app_xccdf_export_oval_variables(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action);
77 static int app_xccdf_remediatecxx . . $ app_xccdf_remediate(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action);
78 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! getopt_xccdfcxx . . $ getopt_xccdf(93e8ba72609212ff).(int argc, char **argv, struct oscap_actioncxx . . $ oscap_action# *action);
79 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! getopt_generatecxx . . $ getopt_generate(93e8ba72609212ff).(int argc, char **argv, struct oscap_actioncxx . . $ oscap_action# *action);
80 static int app_xccdf_xsltcxx . . $ app_xccdf_xslt(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action);
81 static int app_generate_fixcxx . . $ app_generate_fix(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action);
82 static int app_generate_guidecxx . . $ app_generate_guide(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action);
83
84 #define XCCDF_SUBMODULES_NUMcxx . . $ `utils/oscap-xccdf.c:84:9`! 7
85 #define XCCDF_GEN_SUBMODULES_NUMcxx . . $ `utils/oscap-xccdf.c:85:9`! 5 /* See actual arrays
86 initialization below. */
87 static struct oscap_modulecxx . . $ oscap_module#* XCCDF_SUBMODULEScxx . . $ XCCDF_SUBMODULES.[XCCDF_SUBMODULES_NUMcxx . . $ `utils/oscap-xccdf.c:84:9`!];
88 static struct oscap_modulecxx . . $ oscap_module#* XCCDF_GEN_SUBMODULEScxx . . $ XCCDF_GEN_SUBMODULES.[XCCDF_GEN_SUBMODULES_NUMcxx . . $ `utils/oscap-xccdf.c:85:9`!];
89
90 struct oscap_modulecxx . . $ oscap_module# OSCAP_XCCDF_MODULEcxx . . $ OSCAP_XCCDF_MODULE. = {
91 .name = "xccdf",
92 .parent = &OSCAP_ROOT_MODULEcxx . . $ OSCAP_ROOT_MODULE.,
93 .summary = "eXtensible Configuration Checklist Description Format",
94 .usage_extra = "command [command-specific-options]",
95 .opt_parser = getopt_xccdfcxx . . $ getopt_xccdf(93e8ba72609212ff).,
96 .submodules = XCCDF_SUBMODULEScxx . . $ XCCDF_SUBMODULES.
97 };
98
99 static struct oscap_modulecxx . . $ oscap_module# XCCDF_RESOLVEcxx . . $ XCCDF_RESOLVE. = {
100 .name = "resolve",
101 .parent = &OSCAP_XCCDF_MODULEcxx . . $ OSCAP_XCCDF_MODULE.,
102 .summary = "Resolve an XCCDF document",
103 .usage = "[options] -o output-xccdf.xml input-xccdf.xml",
104 .help =
105 "Options:\n"
106 " --force - Force resolving XCCDF document even if it is aleready marked as resolved.\n"
107 " --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
108 " Verbosity level must be one of: DEVEL, INFO, WARNING, ERROR.\n"
109 " --verbose-log-file <file> - Write verbose information into file.\n",
110 .opt_parser = getopt_xccdfcxx . . $ getopt_xccdf(93e8ba72609212ff).,
111 .func = app_xccdf_resolvecxx . . $ app_xccdf_resolve(d99c68634f61e371).
112 };
113
114 static struct oscap_modulecxx . . $ oscap_module# XCCDF_VALIDATEcxx . . $ XCCDF_VALIDATE. = {
115 .name = "validate",
116 .parent = &OSCAP_XCCDF_MODULEcxx . . $ OSCAP_XCCDF_MODULE.,
117 .summary = "Validate XCCDF XML content",
118 .usage = "xccdf-file.xml",
119 .opt_parser = getopt_xccdfcxx . . $ getopt_xccdf(93e8ba72609212ff).,
120 .func = app_xccdf_validatecxx . . $ app_xccdf_validate(d99c68634f61e371).,
121 .help = "Options:\n"
122 " --skip-schematron - Do not use schematron-based validation in addition to XML Schema\n"
123 " --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
124 " Verbosity level must be one of: DEVEL, INFO, WARNING, ERROR.\n"
125 " --verbose-log-file <file> - Write verbose information into file.\n",
126 };
127
128 static struct oscap_modulecxx . . $ oscap_module# XCCDF_EXPORT_OVAL_VARIABLEScxx . . $ XCCDF_EXPORT_OVAL_VARIABLES. = {
129 .name = "export-oval-variables",
130 .parent = &OSCAP_XCCDF_MODULEcxx . . $ OSCAP_XCCDF_MODULE.,
131 .summary = "Export XCCDF values as OVAL external-variables document(s)",
132 .usage = "[options] <xccdf benchmark file> [oval definitions files]",
133 .opt_parser = getopt_xccdfcxx . . $ getopt_xccdf(93e8ba72609212ff).,
134 .func = app_xccdf_export_oval_variablescxx . . $ app_xccdf_export_oval_variables(d99c68634f61e371).,
135 .help = "Options:\n"
136 " --profile <name> - The name of Profile to be evaluated.\n"
137 " --skip-validation - Skip validation.\n"
138 " --fetch-remote-resources - Download remote content referenced by XCCDF.\n"
139 " --local-files <dir> - Use locally downloaded copies of remote resources stored in the given directory.\n"
140 " --datastream-id <id> - ID of the data stream in the collection to use.\n"
141 " (only applicable for source data streams)\n"
142 " --xccdf-id <id> - ID of component-ref with XCCDF in the data stream that should be evaluated.\n"
143 " (only applicable for source data streams)\n"
144 " --benchmark-id <id> - ID of XCCDF Benchmark in some component in the data stream that should be evaluated.\n"
145 " (only applicable for source data streams)\n"
146 " (only applicable when datastream-id AND xccdf-id are not specified)\n"
147 " --cpe <name> - Use given CPE dictionary or language (autodetected)\n"
148 " for applicability checks.\n"
149 " --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
150 " Verbosity level must be one of: DEVEL, INFO, WARNING, ERROR.\n"
151 " --verbose-log-file <file> - Write verbose information into file.\n",
152 };
153
154 static struct oscap_modulecxx . . $ oscap_module# XCCDF_EVALcxx . . $ XCCDF_EVAL. = {
155 .name = "eval",
156 .parent = &OSCAP_XCCDF_MODULEcxx . . $ OSCAP_XCCDF_MODULE.,
157 .summary = "Perform evaluation driven by XCCDF file and use OVAL as checking engine",
158 .usage = "[options] INPUT_FILE [oval-definitions-files]",
159 .help =
160 "INPUT_FILE - XCCDF file or a source data stream file\n\n"
161 "Options:\n"
162 " --profile <name> - The name of Profile to be evaluated.\n"
163 " --rule <name> - The name of a single rule to be evaluated.\n"
164 " --skip-rule <name> - The name of the rule to be skipped.\n"
165 " --reference <NAME:ID> - Evaluate only rules that have the given reference.\n"
166 " --tailoring-file <file> - Use given XCCDF Tailoring file.\n"
167 " --tailoring-id <component-id> - Use given DS component as XCCDF Tailoring file.\n"
168 " --cpe <name> - Use given CPE dictionary or language (autodetected)\n"
169 " for applicability checks.\n"
170 " --oval-results - Save OVAL results as well.\n"
171 " --check-engine-results - Save results from check engines loaded from plugins as well.\n"
172 " --export-variables - Export OVAL external variables provided by XCCDF.\n"
173 " --results <file> - Write XCCDF Results into file.\n"
174 " --results-arf <file> - Write ARF (result data stream) into file.\n"
175 " --stig-viewer <file> - Writes XCCDF results into FILE in a format readable by DISA STIG Viewer\n"
176 " --thin-results - Thin Results provides only minimal amount of information in OVAL/ARF results.\n"
177 " The option --without-syschar is automatically enabled when you use Thin Results.\n"
178 " --without-syschar - Don't provide system characteristic in OVAL/ARF result files.\n"
179 " --report <file> - Write HTML report into file.\n"
180 " --skip-validation - Skip validation.\n"
181 " --skip-signature-validation - Skip data stream signature validation.\n"
182 " (only applicable for source data streams)\n"
183 " --enforce-signature - Process only signed data streams.\n"
184 " --fetch-remote-resources - Download remote content referenced by XCCDF.\n"
185 " --local-files <dir> - Use locally downloaded copies of remote resources stored in the given directory.\n"
186 " --progress - Switch to sparse output suitable for progress reporting.\n"
187 " Format is \"$rule_id:$result\\n\".\n"
188 " --progress-full - Switch to sparse but a bit more saturated output also suitable for progress reporting.\n"
189 " Format is \"$rule_id|$rule_title|$result\\n\".\n"
190 " --datastream-id <id> - ID of the data stream in the collection to use.\n"
191 " (only applicable for source data streams)\n"
192 " --xccdf-id <id> - ID of component-ref with XCCDF in the data stream that should be evaluated.\n"
193 " (only applicable for source data streams)\n"
194 " --benchmark-id <id> - ID of XCCDF Benchmark in some component in the data stream that should be evaluated.\n"
195 " (only applicable for source data streams)\n"
196 " (only applicable when datastream-id AND xccdf-id are not specified)\n"
197 " --remediate - Automatically execute XCCDF fix elements for failed rules.\n"
198 " Use of this option is always at your own risk.\n"
199 " --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
200 " Verbosity level must be one of: DEVEL, INFO, WARNING, ERROR.\n"
201 " --verbose-log-file <file> - Write verbose information into file.\n"
202 " --show-rule-details - Show rule description and rationale when reporting results.\n",
203 .opt_parser = getopt_xccdfcxx . . $ getopt_xccdf(93e8ba72609212ff).,
204 .func = app_evaluate_xccdfcxx . . $ app_evaluate_xccdf(d99c68634f61e371).
205 };
206
207 static struct oscap_modulecxx . . $ oscap_module# XCCDF_REMEDIATEcxx . . $ XCCDF_REMEDIATE. = {
208 .name = "remediate",
209 .parent = &OSCAP_XCCDF_MODULEcxx . . $ OSCAP_XCCDF_MODULE.,
210 .summary = "Perform remediation driven by XCCDF TestResult file or ARF.",
211 .usage = "[options] INPUT_FILE [oval-definitions-files]",
212 .help = "INPUT_FILE - XCCDF TestResult file or ARF\n\n"
213 "Options:\n"
214 " --result-id - TestResult ID to be processed. Default is the most recent one.\n"
215 " --skip-validation - Skip validation.\n"
216 " --cpe <name> - Use given CPE dictionary or language (autodetected)\n"
217 " for applicability checks.\n"
218 " --fetch-remote-resources - Download remote content referenced by XCCDF.\n"
219 " --local-files <dir> - Use locally downloaded copies of remote resources stored in the given directory.\n"
220 " --results <file> - Write XCCDF Results into file.\n"
221 " --results-arf <file> - Write ARF (result data stream) into file.\n"
222 " --stig-viewer <file> - Writes XCCDF results into FILE in a format readable by DISA STIG Viewer\n"
223 " --report <file> - Write HTML report into file.\n"
224 " --oval-results - Save OVAL results.\n"
225 " --export-variables - Export OVAL external variables provided by XCCDF.\n"
226 " --check-engine-results - Save results from check engines loaded from plugins as well.\n"
227 " --progress - Switch to sparse output suitable for progress reporting.\n"
228 " Format is \"$rule_id:$result\\n\".\n"
229 " --progress-full - Switch to sparse but a bit more saturated output also suitable for progress reporting.\n"
230 " Format is \"$rule_id|$rule_title|$result\\n\".\n"
231 " --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
232 " Verbosity level must be one of: DEVEL, INFO, WARNING, ERROR.\n"
233 " --verbose-log-file <file> - Write verbose information into file.\n",
234 .opt_parser = getopt_xccdfcxx . . $ getopt_xccdf(93e8ba72609212ff).,
235 .func = app_xccdf_remediatecxx . . $ app_xccdf_remediate(d99c68634f61e371).
236 };
237
238 #define GEN_OPTScxx . . $ `utils/oscap-xccdf.c:238:9`! \
239 "Generate options:\n" \
240 " --profile <profile-id> - Apply profile with given ID to the Benchmark before further processing takes place.\n"
241
242 static struct oscap_modulecxx . . $ oscap_module# XCCDF_GENERATEcxx . . $ XCCDF_GENERATE. = {
243 .name = "generate",
244 .parent = &OSCAP_XCCDF_MODULEcxx . . $ OSCAP_XCCDF_MODULE.,
245 .summary = "Convert XCCDF Benchmark to other formats",
246 .usage = "[options]",
247 .usage_extra = "<subcommand> [sub-options] benchmark-file.xml",
248 .help = GEN_OPTScxx . . $ `utils/oscap-xccdf.c:238:9`!,
249 .opt_parser = getopt_generatecxx . . $ getopt_generate(93e8ba72609212ff).,
250 .submodules = XCCDF_GEN_SUBMODULEScxx . . $ XCCDF_GEN_SUBMODULES.
251 };
252
253 static struct oscap_modulecxx . . $ oscap_module# XCCDF_GEN_REPORTcxx . . $ XCCDF_GEN_REPORT. = {
254 .name = "report",
255 .parent = &XCCDF_GENERATEcxx . . $ XCCDF_GENERATE.,
256 .summary = "Generate results report",
257 .usage = "[options] xccdf-file.xml",
258 .help = GEN_OPTScxx . . $ `utils/oscap-xccdf.c:238:9`!
259 "\nReport Options:\n"
260 " --result-id <id> - TestResult ID to be processed. Default is the most recent one.\n"
261 " --output <file> - Write the document into file.\n"
262 " --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
263 " Verbosity level must be one of: DEVEL, INFO, WARNING, ERROR.\n"
264 " --verbose-log-file <file> - Write verbose information into file.\n",
265 .opt_parser = getopt_xccdfcxx . . $ getopt_xccdf(93e8ba72609212ff).,
266 .user = "xccdf-report.xsl",
267 .func = app_xccdf_xsltcxx . . $ app_xccdf_xslt(d99c68634f61e371).
268 };
269
270 static struct oscap_modulecxx . . $ oscap_module# XCCDF_GEN_GUIDEcxx . . $ XCCDF_GEN_GUIDE. = {
271 .name = "guide",
272 .parent = &XCCDF_GENERATEcxx . . $ XCCDF_GENERATE.,
273 .summary = "Generate security guide",
274 .usage = "[options] xccdf-file.xml",
275 .help = GEN_OPTScxx . . $ `utils/oscap-xccdf.c:238:9`!
276 "\nGuide Options:\n"
277 " --output <file> - Write the document into file.\n"
278 " --hide-profile-info - This option has no effect.\n"
279 " --benchmark-id <id> - ID of XCCDF Benchmark in some component in the data stream that should be used.\n"
280 " (only applicable for source data streams)\n"
281 " --xccdf-id <id> - ID of component-ref with XCCDF in the data stream that should be evaluated.\n"
282 " (only applicable for source data streams)\n"
283 " --tailoring-file <file> - Use given XCCDF Tailoring file.\n"
284 " (only applicable for source data streams)\n"
285 " --tailoring-id <component-id> - Use given DS component as XCCDF Tailoring file.\n"
286 " (only applicable for source data streams)\n"
287 " --skip-signature-validation - Skip data stream signature validation.\n"
288 " (only applicable for source data streams)\n"
289 " --enforce-signature - Process only signed data streams.\n"
290 " --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
291 " Verbosity level must be one of: DEVEL, INFO, WARNING, ERROR.\n"
292 " --verbose-log-file <file> - Write verbose information into file.\n",
293 .opt_parser = getopt_xccdfcxx . . $ getopt_xccdf(93e8ba72609212ff).,
294 .user = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!,
295 .func = app_generate_guidecxx . . $ app_generate_guide(d99c68634f61e371).
296 };
297
298 static struct oscap_modulecxx . . $ oscap_module# XCCDF_GEN_FIXcxx . . $ XCCDF_GEN_FIX. = {
299 .name = "fix",
300 .parent = &XCCDF_GENERATEcxx . . $ XCCDF_GENERATE.,
301 .summary = "Generate a fix script from an XCCDF file",
302 .usage = "[options] xccdf-file.xml",
303 .help = GEN_OPTScxx . . $ `utils/oscap-xccdf.c:238:9`!
304 "\nFix Options:\n"
305 " --fix-type <type> - Fix type. Should be one of: bash, ansible, puppet, anaconda, ignition, kubernetes,\n"
306 " blueprint, kickstart, bootc (default: bash).\n"
307 " --output <file> - Write the script into file.\n"
308 " --raw - Don't write extra headers or boilerplate instructions, only compose the content snippets.\n"
309 " --result-id <id> - Fixes will be generated for failed rule-results of the specified TestResult.\n"
310 " --benchmark-id <id> - ID of XCCDF Benchmark in some component in the data stream that should be used.\n"
311 " (only applicable for source data streams)\n"
312 " --xccdf-id <id> - ID of component-ref with XCCDF in the data stream that should be evaluated.\n"
313 " (only applicable for source data streams)\n"
314 " --tailoring-file <file> - Use given XCCDF Tailoring file.\n"
315 " (only applicable for source data streams)\n"
316 " --tailoring-id <component-id> - Use given DS component as XCCDF Tailoring file.\n"
317 " (only applicable for source data streams)\n"
318 " --skip-signature-validation - Skip data stream signature validation.\n"
319 " (only applicable for source data streams)\n"
320 " --enforce-signature - Process only signed data streams.\n"
321 " --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
322 " Verbosity level must be one of: DEVEL, INFO, WARNING, ERROR.\n"
323 " --verbose-log-file <file> - Write verbose information into file.\n",
324 .opt_parser = getopt_xccdfcxx . . $ getopt_xccdf(93e8ba72609212ff).,
325 .user = "legacy-fix.xsl",
326 .func = app_generate_fixcxx . . $ app_generate_fix(d99c68634f61e371).
327 };
328
329 static struct oscap_modulecxx . . $ oscap_module# XCCDF_GEN_CUSTOMcxx . . $ XCCDF_GEN_CUSTOM. = {
330 .name = "custom",
331 .parent = &XCCDF_GENERATEcxx . . $ XCCDF_GENERATE.,
332 .summary = "Generate a custom output (depending on given XSLT file) from an XCCDF file",
333 .usage = "--stylesheet <file> [--output <file>] xccdf-file.xml",
334 .help = GEN_OPTScxx . . $ `utils/oscap-xccdf.c:238:9`!
335 "\nCustom Options:\n"
336 " --stylesheet <file> - Specify an absolute path to a custom stylesheet to format the output.\n"
337 " --output <file> - Write the document into file.\n"
338 " --verbose <verbosity_level> - Turn on verbose mode at specified verbosity level.\n"
339 " Verbosity level must be one of: DEVEL, INFO, WARNING, ERROR.\n"
340 " --verbose-log-file <file> - Write verbose information into file.\n",
341 .opt_parser = getopt_xccdfcxx . . $ getopt_xccdf(93e8ba72609212ff).,
342 .user = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!,
343 .func = app_xccdf_xsltcxx . . $ app_xccdf_xslt(d99c68634f61e371).
344 };
345
346 static struct oscap_modulecxx . . $ oscap_module#* XCCDF_GEN_SUBMODULEScxx . . $ XCCDF_GEN_SUBMODULES.[XCCDF_GEN_SUBMODULES_NUMcxx . . $ `utils/oscap-xccdf.c:85:9`!] = {
347 &XCCDF_GEN_REPORTcxx . . $ XCCDF_GEN_REPORT.,
348 &XCCDF_GEN_GUIDEcxx . . $ XCCDF_GEN_GUIDE.,
349 &XCCDF_GEN_FIXcxx . . $ XCCDF_GEN_FIX.,
350 &XCCDF_GEN_CUSTOMcxx . . $ XCCDF_GEN_CUSTOM.,
351 NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!
352 };
353
354 static struct oscap_modulecxx . . $ oscap_module#* XCCDF_SUBMODULEScxx . . $ XCCDF_SUBMODULES.[XCCDF_SUBMODULES_NUMcxx . . $ `utils/oscap-xccdf.c:84:9`!] = {
355 &XCCDF_EVALcxx . . $ XCCDF_EVAL.,
356 &XCCDF_RESOLVEcxx . . $ XCCDF_RESOLVE.,
357 &XCCDF_VALIDATEcxx . . $ XCCDF_VALIDATE.,
358 &XCCDF_EXPORT_OVAL_VARIABLEScxx . . $ XCCDF_EXPORT_OVAL_VARIABLES.,
359 &XCCDF_GENERATEcxx . . $ XCCDF_GENERATE.,
360 &XCCDF_REMEDIATEcxx . . $ XCCDF_REMEDIATE.,
361 NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!
362 };
363
364 enum progress_output_optcxx . . $ progress_output_opt# {
365 PROGRESS_OPT_NONEcxx . . $ PROGRESS_OPT_NONE. = 0,
366 PROGRESS_OPT_SPARSEcxx . . $ PROGRESS_OPT_SPARSE.,
367 PROGRESS_OPT_FULLcxx . . $ PROGRESS_OPT_FULL.,
368 };
369
370 /**
371 * XCCDF Result Colors:
372 * PASS:green(32), FAIL:red(31), ERROR:lred(1;31), UNKNOWN:grey(1;30), NOT_APPLICABLE:default bold(1), NOT_CHECKED:default bold(1),
373 * NOT_SELECTED:default dim(2), INFORMATIONAL:blue(34), FIXED:yellow(1;33)
374 */
375 #if defined(OS_WINDOWS)
376 int RESULT_COLORS[] = {0, 10, 12, 12, 8, 15, 15, 15, 9, 14};
377 #else
378 static const char * RESULT_COLORScxx . . $ RESULT_COLORS.[] = {"", "32", "31", "1;31", "1;30", "1", "1", "2", "34", "1;33" };
379 #endif
380
381 static char custom_stylesheet_pathcxx . . $ custom_stylesheet_path.[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!];
382
383 static void _print_rule_detailscxx . . $ _print_rule_details(8944ef7fe5c7215c).(struct xccdf_policycxx . . $ xccdf_policy# *policy, struct xccdf_itemcxx . . $ xccdf_item# *item)
384 {
385 if (!xccdf_policy_get_show_rule_detailscxx . . $ xccdf_policy_get_show_rule_details(11f15227c042e923).(policy)) {
386 return;
387 }
388 char *description = xccdf_policy_get_readable_item_descriptioncxx . . $ xccdf_policy_get_readable_item_description(5539ec35e28150ee).(policy, item, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
389 if (strlencxx . . $ strlen(751346f8406fd082).(description) > 0) {
390 char *indented_description = oscap_indentcxx . . $ oscap_indent(2050848944e00d54).(description, 8);
391 printfcxx . . $ printf(581fddd72a8db8fc).("Description\n%s\n", indented_description);
392 freecxx . . $ free(5d22bdacc48458e8).(indented_description);
393 }
394 freecxx . . $ free(5d22bdacc48458e8).(description);
395 char *rationale = xccdf_policy_get_readable_item_rationalecxx . . $ xccdf_policy_get_readable_item_rationale(5539ec35e28150ee).(policy, item, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
396 if (strlencxx . . $ strlen(751346f8406fd082).(rationale) > 0) {
397 char *indented_rationale = oscap_indentcxx . . $ oscap_indent(2050848944e00d54).(rationale, 8);
398 printfcxx . . $ printf(581fddd72a8db8fc).("Rationale\n%s\n", indented_rationale);
399 freecxx . . $ free(5d22bdacc48458e8).(indented_rationale);
400 }
401 freecxx . . $ free(5d22bdacc48458e8).(rationale);
402 struct oscap_stringlistcxx . . $ oscap_stringlist# *warnings = xccdf_rule_get_warnings_stringscxx . . $ xccdf_rule_get_warnings_strings(b9f9b705ef6a9d70).((struct xccdf_rulecxx . . $ xccdf_rule# *) item);
403 struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *warnings_it = oscap_stringlist_get_stringscxx . . $ oscap_stringlist_get_strings(13be827fcd32d2b9).(warnings);
404 while (oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(warnings_it)) {
405 const char *warning = oscap_string_iterator_nextcxx . . $ oscap_string_iterator_next(1f2a9ae2534eef34).(warnings_it);
406 char *indented_warning = oscap_indentcxx . . $ oscap_indent(2050848944e00d54).(warning, 8);
407 printfcxx . . $ printf(581fddd72a8db8fc).("Warning\n%s\n", indented_warning);
408 freecxx . . $ free(5d22bdacc48458e8).(indented_warning);
409 }
410 oscap_string_iterator_freecxx . . $ oscap_string_iterator_free(41a77e9ce361f406).(warnings_it);
411 oscap_stringlist_freecxx . . $ oscap_stringlist_free(7df8e35292df4dfb).(warnings);
412 }
413
414 static int callback_scr_rulecxx . . $ callback_scr_rule(f3ce4e62e35c57f3).(struct xccdf_rulecxx . . $ xccdf_rule# *rule, void *arg)
415 {
416 struct xccdf_policycxx . . $ xccdf_policy# *policy = (struct xccdf_policycxx . . $ xccdf_policy# *) arg;
417 const char * rule_id = xccdf_rule_get_idcxx . . $ xccdf_rule_get_id(f04cd2d7bd5fa08a).(rule);
418
419 /* is rule selected? we print only selected rules */
420 const boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! selected = xccdf_policy_is_item_selectedcxx . . $ xccdf_policy_is_item_selected(556e49a57ec3a724).(policy, rule_id);
421 if (!selected)
422 return 0;
423
424 const char *title = xccdf_policy_get_readable_item_titlecxx . . $ xccdf_policy_get_readable_item_title(5539ec35e28150ee).(policy, (struct xccdf_itemcxx . . $ xccdf_item# *) rule, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
425
426 /* print */
427 if (isattycxx . . $ isatty(7864480464b09eea).(1)) {
428 #if defined(OS_WINDOWS)
429 HANDLE console;
430 console = GetStdHandle(STD_OUTPUT_HANDLE);
431 printf("Title");
432 SetConsoleTextAttribute(console, 15);
433 printf("\t%s\n", title);
434 SetConsoleTextAttribute(console, 7);
435 #else
436 printfcxx . . $ printf(581fddd72a8db8fc).("Title\r\t\033[1m%s\033[0;0m\n", title);
437 #endif
438 } else
439 printfcxx . . $ printf(581fddd72a8db8fc).("Title\r\t%s\n", title);
440 freecxx . . $ free(5d22bdacc48458e8).((char *)title);
441 #if defined(OS_WINDOWS)
442 printf("Rule\t%s\n", rule_id);
443 #else
444 printfcxx . . $ printf(581fddd72a8db8fc).("Rule\r\t%s\n", rule_id);
445 #endif
446 _print_rule_detailscxx . . $ _print_rule_details(8944ef7fe5c7215c).(policy, (struct xccdf_itemcxx . . $ xccdf_item# *) rule);
447
448 struct xccdf_ident_iteratorcxx . . $ xccdf_ident_iterator# *idents = xccdf_rule_get_identscxx . . $ xccdf_rule_get_idents(a0e3f5394b5a0b4c).(rule);
449 while (xccdf_ident_iterator_has_morecxx . . $ xccdf_ident_iterator_has_more(9cd00765e4887e1a).(idents)) {
450 const struct xccdf_identcxx . . $ xccdf_ident# *ident = xccdf_ident_iterator_nextcxx . . $ xccdf_ident_iterator_next(980350b3dadb3f34).(idents);
451 const char *ident_id = xccdf_ident_get_idcxx . . $ xccdf_ident_get_id(ab38347313183908).(ident);
452 #if defined(OS_WINDOWS)
453 printf("Ident\t%s\n", ident_id);
454 #else
455 printfcxx . . $ printf(581fddd72a8db8fc).("Ident\r\t%s\n", ident_id);
456 #endif
457 }
458 xccdf_ident_iterator_freecxx . . $ xccdf_ident_iterator_free(24490d322c8816ab).(idents);
459
460 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
461
462 return 0;
463 }
464
465 static int callback_scr_resultcxx . . $ callback_scr_result(be8d7529ae353905).(struct xccdf_rule_resultcxx . . $ xccdf_rule_result# *rule_result, void *arg)
466 {
467 xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# result = xccdf_rule_result_get_resultcxx . . $ xccdf_rule_result_get_result(3f94a129bdb3771c).(rule_result);
468
469 /* is result from selected rule? we print only selected rules */
470 if (result == XCCDF_RESULT_NOT_SELECTEDcxx . . $ XCCDF_RESULT_NOT_SELECTED.)
471 return 0;
472
473 /* print result */
474 #if defined(OS_WINDOWS)
475 printf("Result\t");
476 #else
477 printfcxx . . $ printf(581fddd72a8db8fc).("Result\r\t");
478 #endif
479 const char * result_str = xccdf_test_result_type_get_textcxx . . $ xccdf_test_result_type_get_text(b7e1b929574c5650).(result);
480 if (isattycxx . . $ isatty(7864480464b09eea).(1)) {
481 #if defined(OS_WINDOWS)
482 HANDLE console;
483 console = GetStdHandle(STD_OUTPUT_HANDLE);
484 SetConsoleTextAttribute(console, RESULT_COLORS[result]);
485 printf("%s", result_str);
486 SetConsoleTextAttribute(console, 7);
487 printf("\n\n");
488 #else
489 printfcxx . . $ printf(581fddd72a8db8fc).("\033[%sm%s\033[0m\n\n", RESULT_COLORScxx . . $ RESULT_COLORS.[result], result_str);
490 #endif
491 } else
492 printfcxx . . $ printf(581fddd72a8db8fc).("%s\n\n", result_str);
493
494 return 0;
495 }
496
497 static int callback_scr_result_progresscxx . . $ callback_scr_result_progress(be8d7529ae353905).(struct xccdf_rule_resultcxx . . $ xccdf_rule_result# *rule_result, void *arg)
498 {
499 xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# result = xccdf_rule_result_get_resultcxx . . $ xccdf_rule_result_get_result(3f94a129bdb3771c).(rule_result);
500
501 /* is result from selected rule? we print only selected rules */
502 if (result == XCCDF_RESULT_NOT_SELECTEDcxx . . $ XCCDF_RESULT_NOT_SELECTED.)
503 return 0;
504
505 /* print result */
506 const char *rule_id = xccdf_rule_result_get_idrefcxx . . $ xccdf_rule_result_get_idref(d7da8a9a9f9bf6c8).(rule_result);
507 const char *result_str = xccdf_test_result_type_get_textcxx . . $ xccdf_test_result_type_get_text(b7e1b929574c5650).(result);
508
509 printfcxx . . $ printf(581fddd72a8db8fc).("%s:%s\n", rule_id, result_str);
510 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
511
512 return 0;
513 }
514
515 static int callback_scr_rule_progress_fullcxx . . $ callback_scr_rule_progress_full(f3ce4e62e35c57f3).(struct xccdf_rulecxx . . $ xccdf_rule# *rule, void *arg)
516 {
517 const char *rule_id = xccdf_rule_get_idcxx . . $ xccdf_rule_get_id(f04cd2d7bd5fa08a).(rule);
518
519 if (!xccdf_policy_is_item_selectedcxx . . $ xccdf_policy_is_item_selected(556e49a57ec3a724).((struct xccdf_policycxx . . $ xccdf_policy# *)arg, rule_id))
520 return 0;
521
522 char *title = xccdf_policy_get_readable_item_titlecxx . . $ xccdf_policy_get_readable_item_title(5539ec35e28150ee).((struct xccdf_policycxx . . $ xccdf_policy# *)arg, (struct xccdf_itemcxx . . $ xccdf_item# *)rule, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
523 printfcxx . . $ printf(581fddd72a8db8fc).("%s|%s|", rule_id, title);
524 freecxx . . $ free(5d22bdacc48458e8).(title);
525 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
526
527 return 0;
528 }
529
530 static int callback_scr_result_progress_fullcxx . . $ callback_scr_result_progress_full(be8d7529ae353905).(struct xccdf_rule_resultcxx . . $ xccdf_rule_result# *rule_result, void *arg)
531 {
532 xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# result = xccdf_rule_result_get_resultcxx . . $ xccdf_rule_result_get_result(3f94a129bdb3771c).(rule_result);
533
534 /* is result from selected rule? we print only selected rules */
535 if (result == XCCDF_RESULT_NOT_SELECTEDcxx . . $ XCCDF_RESULT_NOT_SELECTED.)
536 return 0;
537
538 /* print result */
539 const char *result_str = xccdf_test_result_type_get_textcxx . . $ xccdf_test_result_type_get_text(b7e1b929574c5650).(result);
540
541 printfcxx . . $ printf(581fddd72a8db8fc).("%s\n", result_str);
542 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
543
544 return 0;
545 }
546
547 static int callback_scr_multicheckcxx . . $ callback_scr_multicheck(28d98af414dca10b).(struct oval_definitioncxx . . $ oval_definition# *definition, void *arg)
548 {
549 printfcxx . . $ printf(581fddd72a8db8fc).("OVAL Definition ID\t%s\n", oval_definition_get_idcxx . . $ oval_definition_get_id(293cc7080a5789e2).(definition));
550 printfcxx . . $ printf(581fddd72a8db8fc).("OVAL Definition Title\t%s\n", oval_definition_get_titlecxx . . $ oval_definition_get_title(293cc7080a5789e2).(definition));
551 return 0;
552 }
553
554 /*
555 * Send XCCDF Rule Results info message to syslog
556 *
557 static int callback_syslog_result(struct xccdf_rule_result *rule_result, void *arg)
558 {
559 xccdf_test_result_type_t result = xccdf_rule_result_get_result(rule_result);
560
561 // do we log it?
562 if ((result != XCCDF_RESULT_FAIL) && (result != XCCDF_RESULT_UNKNOWN))
563 return 0;
564
565 // yes we do
566 const char * result_str = xccdf_test_result_type_get_text(result);
567 const char * ident_id = NULL;
568 int priority = LOG_NOTICE;
569
570 // get ident
571 struct xccdf_ident_iterator *idents = xccdf_rule_result_get_idents(rule_result);
572 if (xccdf_ident_iterator_has_more(idents)) {
573 const struct xccdf_ident *ident = xccdf_ident_iterator_next(idents);
574 ident_id = xccdf_ident_get_id(ident);
575 }
576 xccdf_ident_iterator_free(idents);
577
578 // emit the message
579 syslog(priority, "Rule: %s, Ident: %s, Result: %s.", xccdf_rule_result_get_idref(rule_result), ident_id, result_str);
580
581 return 0;
582 }
583 */
584
585
586 static void _register_progress_callbackcxx . . $ _register_progress_callback(bfefcecb44e5db9c).(struct xccdf_sessioncxx . . $ xccdf_session# *session, int progress)
587 {
588 struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *policy_model = xccdf_session_get_policy_modelcxx . . $ xccdf_session_get_policy_model(737c70f3050f79dc).(session);
589 if (progress == PROGRESS_OPT_SPARSEcxx . . $ PROGRESS_OPT_SPARSE.) {
590 xccdf_policy_model_register_output_callbackcxx . . $ xccdf_policy_model_register_output_callback(98f486fd53d366e9).(policy_model, callback_scr_result_progresscxx . . $ callback_scr_result_progress(be8d7529ae353905)., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
591 } else if (progress == PROGRESS_OPT_FULLcxx . . $ PROGRESS_OPT_FULL.) {
592 xccdf_policy_model_register_start_callbackcxx . . $ xccdf_policy_model_register_start_callback(d5afe8b86bd96298).(policy_model, callback_scr_rule_progress_fullcxx . . $ callback_scr_rule_progress_full(f3ce4e62e35c57f3).,
593 (void *) xccdf_session_get_xccdf_policycxx . . $ xccdf_session_get_xccdf_policy(7e1ccd92df822b71).(session));
594 xccdf_policy_model_register_output_callbackcxx . . $ xccdf_policy_model_register_output_callback(98f486fd53d366e9).(policy_model, callback_scr_result_progress_fullcxx . . $ callback_scr_result_progress_full(be8d7529ae353905)., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
595 } else {
596 xccdf_policy_model_register_start_callbackcxx . . $ xccdf_policy_model_register_start_callback(d5afe8b86bd96298).(policy_model, callback_scr_rulecxx . . $ callback_scr_rule(f3ce4e62e35c57f3).,
597 (void *) xccdf_session_get_xccdf_policycxx . . $ xccdf_session_get_xccdf_policy(7e1ccd92df822b71).(session));
598 xccdf_policy_model_register_output_callbackcxx . . $ xccdf_policy_model_register_output_callback(98f486fd53d366e9).(policy_model, callback_scr_resultcxx . . $ callback_scr_result(be8d7529ae353905)., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
599 xccdf_policy_model_register_multicheck_callbackcxx . . $ xccdf_policy_model_register_multicheck_callback(89b80f19bc5bc578).(policy_model, callback_scr_multicheckcxx . . $ callback_scr_multicheck(28d98af414dca10b)., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
600 }
601 /* xccdf_policy_model_register_output_callback(policy_model, callback_syslog_result, NULL); */
602 }
603
604 void report_missing_profilecxx . . $ report_missing_profile(2fa786934fe80e24).(const char *profile_suffix, const char *source_file)
605 {
606 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
607 "No profile matching suffix \"%s\" was found. Get available profiles using:\n"
608 "$ oscap info \"%s\"\n", profile_suffix, source_file);
609 }
610
611 void report_multiple_profile_matchescxx . . $ report_multiple_profile_matches(2fa786934fe80e24).(const char *profile_suffix, const char *source_file)
612 {
613 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
614 "At least two profiles matched suffix \"%s\". Use a more specific suffix "
615 "to get an exact match. Get list of profiles using:\n"
616 "$ oscap info \"%s\"\n", profile_suffix, source_file);
617 }
618
619 int evaluate_suffix_match_result_with_custom_reportscxx . . $ evaluate_suffix_match_result_with_custom_reports(900988ad5affe787).(int suffix_match_result, const char *profile_suffix, const char *source_file,
620 void (* report_missing)(const char *, const char *), void (* report_multiple)(const char *, const char *))
621 {
622 if (suffix_match_result == OSCAP_PROFILE_NO_MATCHcxx . . $ OSCAP_PROFILE_NO_MATCH.) {
623 if (report_missing)
624 report_missing(profile_suffix, source_file);
625 return OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
626 } else if (suffix_match_result == OSCAP_PROFILE_MULTIPLE_MATCHEScxx . . $ OSCAP_PROFILE_MULTIPLE_MATCHES.) {
627 if (report_multiple)
628 report_multiple(profile_suffix, source_file);
629 return OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
630 }
631 return OSCAP_OKcxx . . $ OSCAP_OK.;
632 }
633
634 int evaluate_suffix_match_resultcxx . . $ evaluate_suffix_match_result(9ee5302023219b2d).(int suffix_match_result, const char *profile_suffix, const char *source_file)
635 {
636 return evaluate_suffix_match_result_with_custom_reportscxx . . $ evaluate_suffix_match_result_with_custom_reports(900988ad5affe787).(suffix_match_result, profile_suffix, source_file, &report_missing_profilecxx . . $ report_missing_profile(2fa786934fe80e24)., &report_multiple_profile_matchescxx . . $ report_multiple_profile_matches(2fa786934fe80e24).);
637 }
638
639 int xccdf_set_profile_or_report_bad_idcxx . . $ xccdf_set_profile_or_report_bad_id(958fe49146dd32a6).(struct xccdf_sessioncxx . . $ xccdf_session# *session, const char *profile_id, const char *source_file)
640 {
641 const int suffix_match_result = xccdf_session_set_profile_id_by_suffixcxx . . $ xccdf_session_set_profile_id_by_suffix(c44cfbc8af8f9f18).(session, profile_id);
642 int return_code = evaluate_suffix_match_resultcxx . . $ evaluate_suffix_match_result(9ee5302023219b2d).(suffix_match_result, profile_id, source_file);
643 return return_code;
644 }
645
646
647 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _system_is_in_bootc_modecxx . . $ _system_is_in_bootc_mode(c9857a73d68e59ba).(void)
648 {
649 #ifdef OS_WINDOWS
650 return false;
651 #else
652 #define BOOTC_PATHcxx . . $ `utils/oscap-xccdf.c:652:10`! "/usr/bin/bootc"
653 #define CHUNK_SIZEcxx . . $ `utils/oscap-xccdf.c:653:10`! 1024
654 struct statcxx . . $ stat# statbuf;
655 if (statcxx . . $ stat(a9cd1e23e96f423c).(BOOTC_PATHcxx . . $ `utils/oscap-xccdf.c:652:10`!, &statbuf) == -1) {
656 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
657 }
658 FILEcxx . . $ FILE# *output = popencxx . . $ popen(82ec0787cd37e0a3).(BOOTC_PATHcxx . . $ `utils/oscap-xccdf.c:652:10`! " status --format json 2>/dev/null", "r");
659 if (output == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
660 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
661 }
662 size_t buf_size = CHUNK_SIZEcxx . . $ `utils/oscap-xccdf.c:653:10`!;
663 char *buf = calloccxx . . $ calloc(63a7bf2941bfcd7a).(buf_size, sizeof(char));
664 if (buf == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
665 pclosecxx . . $ pclose(89bc1efcdac0ca22).(output);
666 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
667 }
668 int c;
669 size_t i = 0;
670 while ((c = fgetccxx . . $ fgetc(89bc1efcdac0ca22).(output)) != EOFcxx . . $ `<external>/232824719582829767/stdio.h:105:9`!) {
671 if (i >= buf_size) {
672 buf_size += CHUNK_SIZEcxx . . $ `utils/oscap-xccdf.c:653:10`!;
673 char *new_buf = realloccxx . . $ realloc(417ab160f6baadc6).(buf, buf_size);
674 if (new_buf == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
675 pclosecxx . . $ pclose(89bc1efcdac0ca22).(output);
676 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
677 }
678 buf = new_buf;
679 }
680 buf[i++] = c;
681 }
682 pclosecxx . . $ pclose(89bc1efcdac0ca22).(output);
683 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! result = (*buf != '\0' && strstrcxx . . $ strstr(a713fe7b9a57cf96).(buf, "\"booted\":null") == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
684 freecxx . . $ free(5d22bdacc48458e8).(buf);
685 return result;
686 #endif
687 }
688
689 /**
690 * XCCDF Processing fucntion
691 * @param action OSCAP Action structure
692 * @param sess OVAL Agent Session
693 */
694 int app_evaluate_xccdfcxx . . $ app_evaluate_xccdf(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action)
695 {
696 struct xccdf_sessioncxx . . $ xccdf_session# *session = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
697
698 int result = OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
699
700 if (action->remediatecxx . . $ oscap_action#remediate. && _system_is_in_bootc_modecxx . . $ _system_is_in_bootc_mode(c9857a73d68e59ba).()) {
701 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
702 "Detected running Image Mode operating system. OpenSCAP can't "
703 "perform remediation of this system because majority of the "
704 "system is read-only. Please apply remediation during bootable "
705 "container image build using 'oscap-im' instead.\n");
706 return result;
707 }
708
709 #if defined(HAVE_SYSLOG_Hcxx . . $ `build/config.h:70:9`!)
710 int priority = LOG_NOTICEcxx . . $ `<external>/6168640806541382331/syslog.h:56:9`!;
711
712 /* syslog message */
713 syslogcxx . . $ syslog(afcfcee7634adf7d).(priority, "Evaluation started. Content: %s, Profile: %s.", action->f_xccdfcxx . . $ oscap_action#f_xccdf., action->profilecxx . . $ oscap_action#profile.);
714 #endif
715 session = xccdf_session_newcxx . . $ xccdf_session_new(bbbce4de0bbc49c9).(action->f_xccdfcxx . . $ oscap_action#f_xccdf.);
716 if (session == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
717 goto cleanup;
718 xccdf_session_set_validationcxx . . $ xccdf_session_set_validation(6c18952ef2e78e15).(session, action->validatecxx . . $ oscap_action#validate., getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_FULL_VALIDATION") != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
719 xccdf_session_set_signature_validationcxx . . $ xccdf_session_set_signature_validation(5724eff0bd74b67a).(session, action->validate_signaturecxx . . $ oscap_action#validate_signature.);
720 xccdf_session_set_signature_enforcementcxx . . $ xccdf_session_set_signature_enforcement(5724eff0bd74b67a).(session, action->enforce_signaturecxx . . $ oscap_action#enforce_signature.);
721 if (action->thin_resultscxx . . $ oscap_action#thin_results.) {
722 xccdf_session_set_thin_resultscxx . . $ xccdf_session_set_thin_results(5724eff0bd74b67a).(session, truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
723 xccdf_session_set_without_sys_chars_exportcxx . . $ xccdf_session_set_without_sys_chars_export(5724eff0bd74b67a).(session, truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
724 }
725 if (xccdf_session_is_sdscxx . . $ xccdf_session_is_sds(7ca1cfb6ae7817c7).(session)) {
726 xccdf_session_set_datastream_idcxx . . $ xccdf_session_set_datastream_id(e1b914460d223154).(session, action->f_datastream_idcxx . . $ oscap_action#f_datastream_id.);
727 xccdf_session_set_component_idcxx . . $ xccdf_session_set_component_id(e1b914460d223154).(session, action->f_xccdf_idcxx . . $ oscap_action#f_xccdf_id.);
728 xccdf_session_set_benchmark_idcxx . . $ xccdf_session_set_benchmark_id(e1b914460d223154).(session, action->f_benchmark_idcxx . . $ oscap_action#f_benchmark_id.);
729 }
730 xccdf_session_set_user_cpecxx . . $ xccdf_session_set_user_cpe(e1b914460d223154).(session, action->cpecxx . . $ oscap_action#cpe.);
731 // The tailoring_file may be NULL but the tailoring file may have been
732 // autonegotiated from the input file, we don't want to lose that.
733 if (action->tailoring_filecxx . . $ oscap_action#tailoring_file. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
734 xccdf_session_set_user_tailoring_filecxx . . $ xccdf_session_set_user_tailoring_file(e1b914460d223154).(session, action->tailoring_filecxx . . $ oscap_action#tailoring_file.);
735 xccdf_session_set_user_tailoring_cidcxx . . $ xccdf_session_set_user_tailoring_cid(e1b914460d223154).(session, action->tailoring_idcxx . . $ oscap_action#tailoring_id.);
736 xccdf_session_configure_remote_resourcescxx . . $ xccdf_session_configure_remote_resources(39d1d6c85e4007df).(session, action->remote_resourcescxx . . $ oscap_action#remote_resources., action->local_filescxx . . $ oscap_action#local_files., download_reporting_callbackcxx . . $ download_reporting_callback(3ca54e6407cd3d15).);
737 xccdf_session_set_custom_oval_filescxx . . $ xccdf_session_set_custom_oval_files(277245166264b402).(session, action->f_ovalscxx . . $ oscap_action#f_ovals.);
738 xccdf_session_set_product_cpecxx . . $ xccdf_session_set_product_cpe(5281e12fff4127ed).(session, OSCAP_PRODUCTNAMEcxx . . $ `utils/oscap-tool.h:49:9`!);
739 struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *it = oscap_stringlist_get_stringscxx . . $ oscap_stringlist_get_strings(13be827fcd32d2b9).(action->rulescxx . . $ oscap_action#rules.);
740 while (oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(it)) {
741 const char *rid = oscap_string_iterator_nextcxx . . $ oscap_string_iterator_next(1f2a9ae2534eef34).(it);
742 xccdf_session_add_rulecxx . . $ xccdf_session_add_rule(e1b914460d223154).(session, rid);
743 }
744 oscap_string_iterator_freecxx . . $ oscap_string_iterator_free(41a77e9ce361f406).(it);
745 struct oscap_string_iteratorcxx . . $ oscap_string_iterator# *sit = oscap_stringlist_get_stringscxx . . $ oscap_stringlist_get_strings(13be827fcd32d2b9).(action->skip_rulescxx . . $ oscap_action#skip_rules.);
746 while (oscap_string_iterator_has_morecxx . . $ oscap_string_iterator_has_more(3724f2faf2515a82).(sit)) {
747 const char *rid = oscap_string_iterator_nextcxx . . $ oscap_string_iterator_next(1f2a9ae2534eef34).(sit);
748 xccdf_session_skip_rulecxx . . $ xccdf_session_skip_rule(e1b914460d223154).(session, rid);
749 }
750 oscap_string_iterator_freecxx . . $ oscap_string_iterator_free(41a77e9ce361f406).(sit);
751 if (action->referencecxx . . $ oscap_action#reference.) {
752 if (strchrcxx . . $ strchr(2050848944e00d54).(action->referencecxx . . $ oscap_action#reference., ':') == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
753 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "The --reference argument needs to be in form NAME:IDENTIFIER, using a colon as a separator.\n");
754 goto cleanup;
755 }
756 xccdf_session_set_reference_filtercxx . . $ xccdf_session_set_reference_filter(e1b914460d223154).(session, action->referencecxx . . $ oscap_action#reference.);
757 }
758 if (action->show_rule_detailscxx . . $ oscap_action#show_rule_details.)
759 xccdf_session_set_show_rule_detailscxx . . $ xccdf_session_set_show_rule_details(5724eff0bd74b67a).(session, truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
760
761 if (xccdf_session_loadcxx . . $ xccdf_session_load(dd871bf8776e7fa2).(session) != 0)
762 goto cleanup;
763
764
765 /* Select profile */
766 if (!xccdf_session_set_profile_idcxx . . $ xccdf_session_set_profile_id(5281e12fff4127ed).(session, action->profilecxx . . $ oscap_action#profile.)) {
767 if (action->profilecxx . . $ oscap_action#profile. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
768 if (xccdf_set_profile_or_report_bad_idcxx . . $ xccdf_set_profile_or_report_bad_id(958fe49146dd32a6).(session, action->profilecxx . . $ oscap_action#profile., action->f_xccdfcxx . . $ oscap_action#f_xccdf.) == OSCAP_ERRORcxx . . $ OSCAP_ERROR.)
769 goto cleanup;
770 } else {
771 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "No Policy was found for default profile.\n");
772 goto cleanup;
773 }
774 }
775
776 _register_progress_callbackcxx . . $ _register_progress_callback(bfefcecb44e5db9c).(session, action->progresscxx . . $ oscap_action#progress.);
777
778 if (action->progresscxx . . $ oscap_action#progress. == PROGRESS_OPT_SPARSEcxx . . $ PROGRESS_OPT_SPARSE.) {
779 // Don't pronounce phases in this mode
780 } else if (action->progresscxx . . $ oscap_action#progress. == PROGRESS_OPT_FULLcxx . . $ PROGRESS_OPT_FULL.) {
781 printfcxx . . $ printf(581fddd72a8db8fc).("---evaluation\n");
782 } else {
783 printfcxx . . $ printf(581fddd72a8db8fc).("--- Starting Evaluation ---\n\n");
784 }
785
786 /* Perform evaluation */
787 if (xccdf_session_evaluatecxx . . $ xccdf_session_evaluate(dd871bf8776e7fa2).(session) != 0)
788 goto cleanup;
789
790 xccdf_session_set_without_sys_chars_exportcxx . . $ xccdf_session_set_without_sys_chars_export(5724eff0bd74b67a).(session, action->without_sys_charscxx . . $ oscap_action#without_sys_chars.);
791 xccdf_session_set_oval_results_exportcxx . . $ xccdf_session_set_oval_results_export(5724eff0bd74b67a).(session, action->oval_resultscxx . . $ oscap_action#oval_results.);
792 xccdf_session_set_oval_variables_exportcxx . . $ xccdf_session_set_oval_variables_export(5724eff0bd74b67a).(session, action->export_variablescxx . . $ oscap_action#export_variables.);
793 xccdf_session_set_arf_exportcxx . . $ xccdf_session_set_arf_export(5281e12fff4127ed).(session, action->f_results_arfcxx . . $ oscap_action#f_results_arf.);
794
795 if (xccdf_session_export_ovalcxx . . $ xccdf_session_export_oval(dd871bf8776e7fa2).(session) != 0)
796 goto cleanup;
797 else if (action->validatecxx . . $ oscap_action#validate. && getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_FULL_VALIDATION") != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! &&
798 (action->oval_resultscxx . . $ oscap_action#oval_results. == truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`! || action->f_results_arfcxx . . $ oscap_action#f_results_arf.))
799 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "OVAL Results are exported correctly.\n");
800
801 xccdf_session_set_check_engine_plugins_results_exportcxx . . $ xccdf_session_set_check_engine_plugins_results_export(5724eff0bd74b67a).(session, action->check_engine_resultscxx . . $ oscap_action#check_engine_results.);
802 if (xccdf_session_export_check_engine_pluginscxx . . $ xccdf_session_export_check_engine_plugins(dd871bf8776e7fa2).(session) != 0)
803 goto cleanup;
804
805 if (action->remediatecxx . . $ oscap_action#remediate.) {
806 if (action->progresscxx . . $ oscap_action#progress. == PROGRESS_OPT_SPARSEcxx . . $ PROGRESS_OPT_SPARSE.) {
807 // Don't pronounce phases in this mode
808 } else if (action->progresscxx . . $ oscap_action#progress. == PROGRESS_OPT_FULLcxx . . $ PROGRESS_OPT_FULL.) {
809 printfcxx . . $ printf(581fddd72a8db8fc).("---remediation\n");
810 } else {
811 printfcxx . . $ printf(581fddd72a8db8fc).("\n--- Starting Remediation ---\n\n");
812 }
813 xccdf_session_remediatecxx . . $ xccdf_session_remediate(dd871bf8776e7fa2).(session);
814 }
815
816 /* Get the result from TestResult model and decide if end with error or with correct return code */
817 int evaluation_result = xccdf_session_contains_fail_resultcxx . . $ xccdf_session_contains_fail_result(7ca1cfb6ae7817c7).(session) ? OSCAP_FAILcxx . . $ OSCAP_FAIL. : OSCAP_OKcxx . . $ OSCAP_OK.;
818
819 /* syslog message */
820 #if defined(HAVE_SYSLOG_Hcxx . . $ `build/config.h:70:9`!)
821 syslogcxx . . $ syslog(afcfcee7634adf7d).(priority, "Evaluation finished. Return code: %d, Base score %f.", evaluation_result, xccdf_session_get_base_scorecxx . . $ xccdf_session_get_base_score(f8473a90d025f46e).(session));
822 #endif
823
824 xccdf_session_set_xccdf_exportcxx . . $ xccdf_session_set_xccdf_export(5281e12fff4127ed).(session, action->f_resultscxx . . $ oscap_action#f_results.);
825 xccdf_session_set_xccdf_stig_viewer_exportcxx . . $ xccdf_session_set_xccdf_stig_viewer_export(5281e12fff4127ed).(session, action->f_results_stigcxx . . $ oscap_action#f_results_stig.);
826 xccdf_session_set_report_exportcxx . . $ xccdf_session_set_report_export(5281e12fff4127ed).(session, action->f_reportcxx . . $ oscap_action#f_report.);
827 if (xccdf_session_export_allcxx . . $ xccdf_session_export_all(dd871bf8776e7fa2).(session) != 0)
828 goto cleanup;
829
830 if (action->validatecxx . . $ oscap_action#validate. && getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_FULL_VALIDATION") != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! &&
831 (action->f_resultscxx . . $ oscap_action#f_results. || action->f_reportcxx . . $ oscap_action#f_report. || action->f_results_arfcxx . . $ oscap_action#f_results_arf. || action->f_results_stigcxx . . $ oscap_action#f_results_stig.))
832 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "XCCDF Results are exported correctly.\n");
833
834 if (action->f_results_arfcxx . . $ oscap_action#f_results_arf. && getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_FULL_VALIDATION") != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
835 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Result data stream exported correctly.\n");
836
837 result = evaluation_result;
838
839 cleanup:
840 xccdf_session_freecxx . . $ xccdf_session_free(fc68940e73a0edd6).(session);
841 oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).();
842 return result;
843 }
844
845 static xccdf_test_result_type_tcxx . . $ xccdf_test_result_type_t# resolve_variables_wrappercxx . . $ resolve_variables_wrapper(55d5550656449b7).(struct xccdf_policycxx . . $ xccdf_policy# *policy, const char *rule_id,
846 const char *id, const char *href, struct xccdf_value_binding_iteratorcxx . . $ xccdf_value_binding_iterator# *bnd_itr,
847 struct xccdf_check_import_iteratorcxx . . $ xccdf_check_import_iterator# *check_import_it, void *usr)
848 {
849 if (0 != oval_agent_resolve_variablescxx . . $ oval_agent_resolve_variables(669417eaa800a408).((struct oval_agent_sessioncxx . . $ oval_agent_session# *) usr, bnd_itr))
850 return XCCDF_RESULT_UNKNOWNcxx . . $ XCCDF_RESULT_UNKNOWN.;
851
852 return XCCDF_RESULT_PASScxx . . $ XCCDF_RESULT_PASS.;
853 }
854
855 static int app_xccdf_export_oval_variablescxx . . $ app_xccdf_export_oval_variables(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action)
856 {
857 struct xccdf_policycxx . . $ xccdf_policy# *policy = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
858 struct xccdf_resultcxx . . $ xccdf_result# *xres;
859 int result = OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
860 struct xccdf_sessioncxx . . $ xccdf_session# *session = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
861
862 session = xccdf_session_newcxx . . $ xccdf_session_new(bbbce4de0bbc49c9).(action->f_xccdfcxx . . $ oscap_action#f_xccdf.);
863 if (session == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
864 goto cleanup;
865
866 xccdf_session_set_validationcxx . . $ xccdf_session_set_validation(6c18952ef2e78e15).(session, action->validatecxx . . $ oscap_action#validate., getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_FULL_VALIDATION") != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
867
868 if (xccdf_session_is_sdscxx . . $ xccdf_session_is_sds(7ca1cfb6ae7817c7).(session)) {
869 xccdf_session_set_datastream_idcxx . . $ xccdf_session_set_datastream_id(e1b914460d223154).(session, action->f_datastream_idcxx . . $ oscap_action#f_datastream_id.);
870 xccdf_session_set_component_idcxx . . $ xccdf_session_set_component_id(e1b914460d223154).(session, action->f_xccdf_idcxx . . $ oscap_action#f_xccdf_id.);
871 xccdf_session_set_benchmark_idcxx . . $ xccdf_session_set_benchmark_id(e1b914460d223154).(session, action->f_benchmark_idcxx . . $ oscap_action#f_benchmark_id.);
872 }
873 xccdf_session_set_user_cpecxx . . $ xccdf_session_set_user_cpe(e1b914460d223154).(session, action->cpecxx . . $ oscap_action#cpe.);
874 xccdf_session_configure_remote_resourcescxx . . $ xccdf_session_configure_remote_resources(39d1d6c85e4007df).(session, action->remote_resourcescxx . . $ oscap_action#remote_resources., action->local_filescxx . . $ oscap_action#local_files., download_reporting_callbackcxx . . $ download_reporting_callback(3ca54e6407cd3d15).);
875 xccdf_session_set_custom_oval_filescxx . . $ xccdf_session_set_custom_oval_files(277245166264b402).(session, action->f_ovalscxx . . $ oscap_action#f_ovals.);
876 xccdf_session_set_custom_oval_eval_fncxx . . $ xccdf_session_set_custom_oval_eval_fn(11dfec3931da66f3).(session, resolve_variables_wrappercxx . . $ resolve_variables_wrapper(55d5550656449b7).);
877
878 if (xccdf_session_loadcxx . . $ xccdf_session_load(dd871bf8776e7fa2).(session) != 0)
879 goto cleanup;
880
881 /* select a profile */
882 policy = xccdf_policy_model_get_policy_by_idcxx . . $ xccdf_policy_model_get_policy_by_id(3a48227fe1c1225a).(xccdf_session_get_policy_modelcxx . . $ xccdf_session_get_policy_model(737c70f3050f79dc).(session), action->profilecxx . . $ oscap_action#profile.);
883 if (policy == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
884 if (action->profilecxx . . $ oscap_action#profile. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
885 report_missing_profilecxx . . $ report_missing_profile(2fa786934fe80e24).(action->profilecxx . . $ oscap_action#profile., action->f_xccdfcxx . . $ oscap_action#f_xccdf.);
886 else
887 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "No Policy was found for default profile.\n");
888 goto cleanup;
889 }
890
891 /* perform evaluation */
892 xres = xccdf_policy_evaluatecxx . . $ xccdf_policy_evaluate(93b250fa94f0dc8e).(policy);
893 if (xres == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
894 goto cleanup;
895
896 xccdf_session_set_oval_variables_exportcxx . . $ xccdf_session_set_oval_variables_export(5724eff0bd74b67a).(session, truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!);
897 if (xccdf_session_export_ovalcxx . . $ xccdf_session_export_oval(dd871bf8776e7fa2).(session) == 0)
898 result = OSCAP_OKcxx . . $ OSCAP_OK.;
899
900 cleanup:
901 oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).();
902 if (session != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
903 xccdf_session_freecxx . . $ xccdf_session_free(fc68940e73a0edd6).(session);
904
905 return result;
906 }
907
908 int app_xccdf_remediatecxx . . $ app_xccdf_remediate(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action)
909 {
910 struct xccdf_sessioncxx . . $ xccdf_session# *session = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
911 int result = OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
912 if (_system_is_in_bootc_modecxx . . $ _system_is_in_bootc_mode(c9857a73d68e59ba).()) {
913 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
914 "Detected running Image Mode operating system. OpenSCAP can't "
915 "perform remediation of this system because majority of the "
916 "system is read-only. Please apply remediation during bootable "
917 "container image build using 'oscap-im' instead.\n");
918 return result;
919 }
920 session = xccdf_session_newcxx . . $ xccdf_session_new(bbbce4de0bbc49c9).(action->f_xccdfcxx . . $ oscap_action#f_xccdf.);
921 if (session == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
922 goto cleanup;
923 xccdf_session_set_validationcxx . . $ xccdf_session_set_validation(6c18952ef2e78e15).(session, action->validatecxx . . $ oscap_action#validate., getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_FULL_VALIDATION") != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
924 xccdf_session_set_user_cpecxx . . $ xccdf_session_set_user_cpe(e1b914460d223154).(session, action->cpecxx . . $ oscap_action#cpe.);
925 xccdf_session_configure_remote_resourcescxx . . $ xccdf_session_configure_remote_resources(39d1d6c85e4007df).(session, action->remote_resourcescxx . . $ oscap_action#remote_resources., action->local_filescxx . . $ oscap_action#local_files., download_reporting_callbackcxx . . $ download_reporting_callback(3ca54e6407cd3d15).);
926 xccdf_session_set_custom_oval_filescxx . . $ xccdf_session_set_custom_oval_files(277245166264b402).(session, action->f_ovalscxx . . $ oscap_action#f_ovals.);
927
928 if (xccdf_session_loadcxx . . $ xccdf_session_load(dd871bf8776e7fa2).(session) != 0)
929 goto cleanup;
930
931 if (xccdf_session_build_policy_from_testresultcxx . . $ xccdf_session_build_policy_from_testresult(c44cfbc8af8f9f18).(session, action->idcxx . . $ oscap_action#id.) != 0)
932 goto cleanup;
933
934 _register_progress_callbackcxx . . $ _register_progress_callback(bfefcecb44e5db9c).(session, action->progresscxx . . $ oscap_action#progress.);
935
936 xccdf_session_remediatecxx . . $ xccdf_session_remediate(dd871bf8776e7fa2).(session);
937
938 xccdf_session_set_oval_results_exportcxx . . $ xccdf_session_set_oval_results_export(5724eff0bd74b67a).(session, action->oval_resultscxx . . $ oscap_action#oval_results.);
939 xccdf_session_set_oval_variables_exportcxx . . $ xccdf_session_set_oval_variables_export(5724eff0bd74b67a).(session, action->export_variablescxx . . $ oscap_action#export_variables.);
940 xccdf_session_set_arf_exportcxx . . $ xccdf_session_set_arf_export(5281e12fff4127ed).(session, action->f_results_arfcxx . . $ oscap_action#f_results_arf.);
941 xccdf_session_set_xccdf_exportcxx . . $ xccdf_session_set_xccdf_export(5281e12fff4127ed).(session, action->f_resultscxx . . $ oscap_action#f_results.);
942 xccdf_session_set_xccdf_stig_viewer_exportcxx . . $ xccdf_session_set_xccdf_stig_viewer_export(5281e12fff4127ed).(session, action->f_results_stigcxx . . $ oscap_action#f_results_stig.);
943 xccdf_session_set_report_exportcxx . . $ xccdf_session_set_report_export(5281e12fff4127ed).(session, action->f_reportcxx . . $ oscap_action#f_report.);
944
945 if (xccdf_session_export_ovalcxx . . $ xccdf_session_export_oval(dd871bf8776e7fa2).(session) != 0)
946 goto cleanup;
947
948 xccdf_session_set_check_engine_plugins_results_exportcxx . . $ xccdf_session_set_check_engine_plugins_results_export(5724eff0bd74b67a).(session, action->check_engine_resultscxx . . $ oscap_action#check_engine_results.);
949 if (xccdf_session_export_check_engine_pluginscxx . . $ xccdf_session_export_check_engine_plugins(dd871bf8776e7fa2).(session) != 0)
950 goto cleanup;
951
952 /* Get the result from TestResult model and decide if end with error or with correct return code */
953 int evaluation_result = xccdf_session_contains_fail_resultcxx . . $ xccdf_session_contains_fail_result(7ca1cfb6ae7817c7).(session) ? OSCAP_FAILcxx . . $ OSCAP_FAIL. : OSCAP_OKcxx . . $ OSCAP_OK.;
954
955 if (xccdf_session_export_allcxx . . $ xccdf_session_export_all(dd871bf8776e7fa2).(session) != 0)
956 goto cleanup;
957
958 result = evaluation_result;
959
960 cleanup:
961 xccdf_session_freecxx . . $ xccdf_session_free(fc68940e73a0edd6).(session);
962 oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).();
963 return result;
964 }
965
966 int app_xccdf_resolvecxx . . $ app_xccdf_resolve(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action)
967 {
968 int ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
969 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# *bench = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
970
971 if (!action->f_xccdfcxx . . $ oscap_action#f_xccdf.) {
972 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "No input document specified!\n");
973 return OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
974 }
975 if (!action->f_resultscxx . . $ oscap_action#f_results.) {
976 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "No output document filename specified!\n");
977 return OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
978 }
979
980 struct oscap_sourcecxx . . $ oscap_source# *source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->f_xccdfcxx . . $ oscap_action#f_xccdf.);
981 /* validate input */
982 if (action->validatecxx . . $ oscap_action#validate.) {
983 if (oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(source, reportercxx . . $ reporter(710d628f83af7da6)., (void *) action) != 0) {
984 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source);
985 goto cleanup;
986 }
987 }
988
989 bench = xccdf_benchmark_import_sourcecxx . . $ xccdf_benchmark_import_source(ea77069d65e32f82).(source);
990 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source);
991 if (!bench)
992 goto cleanup;
993
994 if (action->forcecxx . . $ oscap_action#force.)
995 xccdf_benchmark_set_resolvedcxx . . $ xccdf_benchmark_set_resolved(9d7adcbca7f23e0e).(bench, falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!);
996
997 if (xccdf_benchmark_get_resolvedcxx . . $ xccdf_benchmark_get_resolved(8f09e366eefbe28).(bench))
998 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Benchmark is already resolved!\n");
999 else {
1000 if (!xccdf_benchmark_resolvecxx . . $ xccdf_benchmark_resolve(9e5458caf3f9d147).(bench))
1001 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Benchmark resolving failure (probably a dependency loop)!\n");
1002 else
1003 {
1004 if (xccdf_benchmark_exportcxx . . $ xccdf_benchmark_export(163bb5a28ad7f4ea).(bench, action->f_resultscxx . . $ oscap_action#f_results.) == 0) {
1005 ret = OSCAP_OKcxx . . $ OSCAP_OK.;
1006
1007 /* validate exported results */
1008 const char* full_validation = getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_FULL_VALIDATION");
1009 if (action->validatecxx . . $ oscap_action#validate. && full_validation) {
1010 struct oscap_sourcecxx . . $ oscap_source# *result_source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->f_resultscxx . . $ oscap_action#f_results.);
1011 if (oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(result_source, reportercxx . . $ reporter(710d628f83af7da6)., (void *) action) != 0) {
1012 ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
1013 }
1014 else
1015 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Resolved XCCDF has been exported correctly.\n");
1016 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(result_source);
1017 }
1018 }
1019 }
1020 }
1021
1022 cleanup:
1023 oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).();
1024 if (bench)
1025 xccdf_benchmark_freecxx . . $ xccdf_benchmark_free(55d89e1b9b447538).(bench);
1026
1027 return ret;
1028 }
1029
1030 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! _some_result_existscxx . . $ _some_result_exists(c489d6adaa99944).(struct oscap_sourcecxx . . $ oscap_source# *xccdf_source, const char *namespace)
1031 {
1032 struct xccdf_benchmarkcxx . . $ xccdf_benchmark# *benchmark = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1033 struct xccdf_policy_modelcxx . . $ xccdf_policy_model# *policy_model = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1034 struct oscap_file_entry_listcxx . . $ oscap_file_entry_list# *files = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1035 struct oscap_file_entry_iteratorcxx . . $ oscap_file_entry_iterator# *files_it = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1036 char *oval_result = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1037 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! result = falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1038
1039 benchmark = xccdf_benchmark_import_sourcecxx . . $ xccdf_benchmark_import_source(ea77069d65e32f82).(xccdf_source);
1040 if (benchmark == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
1041 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
1042
1043 policy_model = xccdf_policy_model_newcxx . . $ xccdf_policy_model_new(b3d462237ee1830).(benchmark);
1044 files = xccdf_policy_model_get_systems_and_filescxx . . $ xccdf_policy_model_get_systems_and_files(bd306bb648bca7f3).(policy_model);
1045 files_it = oscap_file_entry_list_get_filescxx . . $ oscap_file_entry_list_get_files(f5aaec2ea5fc982f).(files);
1046 oval_result = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`! * sizeof(char));
1047 while (oscap_file_entry_iterator_has_morecxx . . $ oscap_file_entry_iterator_has_more(126961f4f01d6b48).(files_it)) {
1048 struct oscap_file_entrycxx . . $ oscap_file_entry# *file_entry = (struct oscap_file_entrycxx . . $ oscap_file_entry# *) oscap_file_entry_iterator_nextcxx . . $ oscap_file_entry_iterator_next(2dd8621e704b2d0b).(files_it);;
1049 struct statcxx . . $ stat# sb;
1050 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(oscap_file_entry_get_systemcxx . . $ oscap_file_entry_get_system(7827612c21abd21f).(file_entry), namespace))
1051 continue;
1052 snprintfcxx . . $ snprintf(ea502d73e74c754c).(oval_result, PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!, "./%s.result.xml", oscap_file_entry_get_filecxx . . $ oscap_file_entry_get_file(7827612c21abd21f).(file_entry));
1053 if (statcxx . . $ stat(a9cd1e23e96f423c).(oval_result, &sb) == 0) {
1054 result = truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1055 break;
1056 }
1057 }
1058 freecxx . . $ free(5d22bdacc48458e8).(oval_result);
1059 oscap_file_entry_iterator_freecxx . . $ oscap_file_entry_iterator_free(9fa52656bc957f51).(files_it);
1060 oscap_file_entry_list_freecxx . . $ oscap_file_entry_list_free(46f5db83064d09fb).(files);
1061 xccdf_policy_model_freecxx . . $ xccdf_policy_model_free(72c03b3c10433f31).(policy_model);
1062 return result;
1063 }
1064
1065 int app_generate_fixcxx . . $ app_generate_fix(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action)
1066 {
1067 struct xccdf_sessioncxx . . $ xccdf_session# *session = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1068 struct ds_rds_sessioncxx . . $ ds_rds_session# *arf_session = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1069 const char *remediation_system = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1070
1071 if (action->fix_typecxx . . $ oscap_action#fix_type. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1072 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(action->fix_typecxx . . $ oscap_action#fix_type., "bash") == 0) {
1073 remediation_system = "urn:xccdf:fix:script:sh";
1074 } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(action->fix_typecxx . . $ oscap_action#fix_type., "ansible") == 0) {
1075 remediation_system = "urn:xccdf:fix:script:ansible";
1076 } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(action->fix_typecxx . . $ oscap_action#fix_type., "kickstart") == 0) {
1077 remediation_system = "urn:xccdf:fix:script:kickstart";
1078 } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(action->fix_typecxx . . $ oscap_action#fix_type., "puppet") == 0) {
1079 remediation_system = "urn:xccdf:fix:script:puppet";
1080 } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(action->fix_typecxx . . $ oscap_action#fix_type., "anaconda") == 0) {
1081 remediation_system = "urn:redhat:anaconda:pre";
1082 } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(action->fix_typecxx . . $ oscap_action#fix_type., "ignition") == 0) {
1083 remediation_system = "urn:xccdf:fix:script:ignition";
1084 } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(action->fix_typecxx . . $ oscap_action#fix_type., "kubernetes") == 0) {
1085 remediation_system = "urn:xccdf:fix:script:kubernetes";
1086 } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(action->fix_typecxx . . $ oscap_action#fix_type., "blueprint") == 0) {
1087 remediation_system = "urn:redhat:osbuild:blueprint";
1088 } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(action->fix_typecxx . . $ oscap_action#fix_type., "bootc") == 0) {
1089 remediation_system = "urn:xccdf:fix:script:bootc";
1090 } else {
1091 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
1092 "Unknown fix type '%s'.\n"
1093 "Please provide one of: bash, ansible, kickstart, puppet, anaconda, ignition, kubernetes, blueprint, bootc.\n"
1094 "Or provide a custom template using '--template' instead.\n",
1095 action->fix_typecxx . . $ oscap_action#fix_type.);
1096 return OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
1097 }
1098 } else {
1099 remediation_system = "urn:xccdf:fix:script:sh";
1100 }
1101
1102 if (action->idcxx . . $ oscap_action#id. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! && action->fix_typecxx . . $ oscap_action#fix_type. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(action->fix_typecxx . . $ oscap_action#fix_type., "kickstart")) {
1103 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "It isn't possible to generate results-oriented Kickstarts.\n");
1104 return OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
1105 }
1106 if (action->idcxx . . $ oscap_action#id. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! && action->fix_typecxx . . $ oscap_action#fix_type. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`! && !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(action->fix_typecxx . . $ oscap_action#fix_type., "bootc")) {
1107 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "It isn't possible to generate results-oriented bootc remediations.\n");
1108 return OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
1109 }
1110
1111 int ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
1112 struct oscap_sourcecxx . . $ oscap_source# *source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->f_xccdfcxx . . $ oscap_action#f_xccdf.);
1113 oscap_document_type_tcxx . . $ oscap_document_type_t# document_type = oscap_source_get_scap_typecxx . . $ oscap_source_get_scap_type(1b623b3fe9f5b871).(source);
1114 if (document_type == OSCAP_DOCUMENT_ARFcxx . . $ OSCAP_DOCUMENT_ARF.) {
1115 arf_session = ds_rds_session_new_from_sourcecxx . . $ ds_rds_session_new_from_source(592e39614e891652).(source);
1116 if (arf_session == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1117 goto cleanup;
1118 }
1119 struct oscap_sourcecxx . . $ oscap_source# *report_source = ds_rds_session_select_reportcxx . . $ ds_rds_session_select_report(e0b2d513013fe52d).(arf_session, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1120 if (report_source == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1121 goto cleanup;
1122 }
1123 struct oscap_sourcecxx . . $ oscap_source# *report_request_source = ds_rds_session_select_report_requestcxx . . $ ds_rds_session_select_report_request(e0b2d513013fe52d).(arf_session, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1124 if (report_request_source == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1125 goto cleanup;
1126 }
1127 session = xccdf_session_new_from_sourcecxx . . $ xccdf_session_new_from_source(635597adc8233c20).(oscap_source_clonecxx . . $ oscap_source_clone(ab0443cab9f10e49).(report_request_source));
1128 if (action->idcxx . . $ oscap_action#id. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1129 if (xccdf_session_add_report_from_sourcecxx . . $ xccdf_session_add_report_from_source(6b23355d2c1822cf).(session, oscap_source_clonecxx . . $ oscap_source_clone(ab0443cab9f10e49).(report_source))) {
1130 goto cleanup;
1131 }
1132 }
1133 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source);
1134 } else {
1135 session = xccdf_session_new_from_sourcecxx . . $ xccdf_session_new_from_source(635597adc8233c20).(source);
1136 }
1137 if (session == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)
1138 goto cleanup;
1139
1140 xccdf_session_set_validationcxx . . $ xccdf_session_set_validation(6c18952ef2e78e15).(session, action->validatecxx . . $ oscap_action#validate., getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_FULL_VALIDATION") != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1141 xccdf_session_set_signature_validationcxx . . $ xccdf_session_set_signature_validation(5724eff0bd74b67a).(session, action->validate_signaturecxx . . $ oscap_action#validate_signature.);
1142 xccdf_session_set_signature_enforcementcxx . . $ xccdf_session_set_signature_enforcement(5724eff0bd74b67a).(session, action->enforce_signaturecxx . . $ oscap_action#enforce_signature.);
1143 xccdf_session_set_user_cpecxx . . $ xccdf_session_set_user_cpe(e1b914460d223154).(session, action->cpecxx . . $ oscap_action#cpe.);
1144 xccdf_session_configure_remote_resourcescxx . . $ xccdf_session_configure_remote_resources(39d1d6c85e4007df).(session, action->remote_resourcescxx . . $ oscap_action#remote_resources., action->local_filescxx . . $ oscap_action#local_files., download_reporting_callbackcxx . . $ download_reporting_callback(3ca54e6407cd3d15).);
1145 xccdf_session_set_custom_oval_filescxx . . $ xccdf_session_set_custom_oval_files(277245166264b402).(session, action->f_ovalscxx . . $ oscap_action#f_ovals.);
1146 xccdf_session_set_user_tailoring_filecxx . . $ xccdf_session_set_user_tailoring_file(e1b914460d223154).(session, action->tailoring_filecxx . . $ oscap_action#tailoring_file.);
1147 xccdf_session_set_user_tailoring_cidcxx . . $ xccdf_session_set_user_tailoring_cid(e1b914460d223154).(session, action->tailoring_idcxx . . $ oscap_action#tailoring_id.);
1148 if (xccdf_session_is_sdscxx . . $ xccdf_session_is_sds(7ca1cfb6ae7817c7).(session)) {
1149 xccdf_session_set_component_idcxx . . $ xccdf_session_set_component_id(e1b914460d223154).(session, action->f_xccdf_idcxx . . $ oscap_action#f_xccdf_id.);
1150 xccdf_session_set_benchmark_idcxx . . $ xccdf_session_set_benchmark_id(e1b914460d223154).(session, action->f_benchmark_idcxx . . $ oscap_action#f_benchmark_id.);
1151 }
1152 xccdf_session_set_loading_flagscxx . . $ xccdf_session_set_loading_flags(3c1bec58736b4360).(session, XCCDF_SESSION_LOAD_XCCDFcxx . . $ XCCDF_SESSION_LOAD_XCCDF.);
1153 if (xccdf_session_loadcxx . . $ xccdf_session_load(dd871bf8776e7fa2).(session) != 0)
1154 goto cleanup;
1155
1156 #ifdef OS_WINDOWS
1157 int output_fd = _fileno(stdout);
1158 #else
1159 int output_fd = STDOUT_FILENOcxx . . $ `<external>/12628407106812493757/unistd.h:211:9`!;
1160 #endif
1161 if (action->f_resultscxx . . $ oscap_action#f_results. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1162 if ((output_fd = opencxx . . $ open(e156e3aa1e5c4ad1).(action->f_resultscxx . . $ oscap_action#f_results., O_CREATcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:47:10`!|O_TRUNCcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:56:10`!|O_NOFOLLOWcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:141:10`!|O_WRONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:44:9`!, 0700)) < 0) {
1163 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "Could not open %s: %s", action->f_resultscxx . . $ oscap_action#f_results., strerrorcxx . . $ strerror(ff224f080444ee45).(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
1164 goto cleanup;
1165 }
1166 }
1167
1168 struct oscap_sourcecxx . . $ oscap_source# *tailoring = xccdf_session_get_user_tailoring_filecxx . . $ xccdf_session_get_user_tailoring_file(66c05d76889feaa2).(session);
1169 if (action->idcxx . . $ oscap_action#id. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1170 /* Result-oriented fixes */
1171 if (xccdf_session_build_policy_from_testresultcxx . . $ xccdf_session_build_policy_from_testresult(c44cfbc8af8f9f18).(session, action->idcxx . . $ oscap_action#id.) != 0)
1172 goto cleanup2;
1173
1174 struct xccdf_policycxx . . $ xccdf_policy# *policy = xccdf_session_get_xccdf_policycxx . . $ xccdf_session_get_xccdf_policy(7e1ccd92df822b71).(session);
1175 struct xccdf_resultcxx . . $ xccdf_result# *result = xccdf_policy_get_result_by_idcxx . . $ xccdf_policy_get_result_by_id(bb71306f61267cbc).(policy, xccdf_session_get_result_idcxx . . $ xccdf_session_get_result_id(f99217dc5fad66c6).(session));
1176 if (xccdf_policy_generate_fixcxx . . $ xccdf_policy_generate_fix(9f2af4d8d66a7977).(policy, result, remediation_system, action->f_xccdfcxx . . $ oscap_action#f_xccdf., tailoring, output_fd, action->rawcxx . . $ oscap_action#raw.) == 0)
1177 ret = OSCAP_OKcxx . . $ OSCAP_OK.;
1178 } else { // Fallback to profile if result id is missing
1179 /* Profile-oriented fixes */
1180 if (!xccdf_session_set_profile_idcxx . . $ xccdf_session_set_profile_id(5281e12fff4127ed).(session, action->profilecxx . . $ oscap_action#profile.)) {
1181 if (action->profilecxx . . $ oscap_action#profile. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1182 if (xccdf_set_profile_or_report_bad_idcxx . . $ xccdf_set_profile_or_report_bad_id(958fe49146dd32a6).(session, action->profilecxx . . $ oscap_action#profile., action->f_xccdfcxx . . $ oscap_action#f_xccdf.) == OSCAP_ERRORcxx . . $ OSCAP_ERROR.)
1183 goto cleanup2;
1184 } else {
1185 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "No Policy was found for default profile.\n");
1186 goto cleanup2;
1187 }
1188 }
1189 struct xccdf_policycxx . . $ xccdf_policy# *policy = xccdf_session_get_xccdf_policycxx . . $ xccdf_session_get_xccdf_policy(7e1ccd92df822b71).(session);
1190 if (xccdf_policy_generate_fixcxx . . $ xccdf_policy_generate_fix(9f2af4d8d66a7977).(policy, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, remediation_system, action->f_xccdfcxx . . $ oscap_action#f_xccdf., tailoring, output_fd, action->rawcxx . . $ oscap_action#raw.) == 0)
1191 ret = OSCAP_OKcxx . . $ OSCAP_OK.;
1192 }
1193 cleanup2:
1194 #ifdef OS_WINDOWS
1195 if (output_fd != _fileno(stdout))
1196 #else
1197 if (output_fd != STDOUT_FILENOcxx . . $ `<external>/12628407106812493757/unistd.h:211:9`!)
1198 #endif
1199 closecxx . . $ close(7864480464b09eea).(output_fd);
1200 cleanup:
1201 ds_rds_session_freecxx . . $ ds_rds_session_free(f80cb7d7d6605f3a).(arf_session);
1202 xccdf_session_freecxx . . $ xccdf_session_free(fc68940e73a0edd6).(session);
1203 oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).();
1204 return ret;
1205 }
1206
1207 int app_generate_guidecxx . . $ app_generate_guide(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action)
1208 {
1209 int ret = OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
1210
1211 struct oscap_sourcecxx . . $ oscap_source# *source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->f_xccdfcxx . . $ oscap_action#f_xccdf.);
1212 struct xccdf_sessioncxx . . $ xccdf_session# *session = xccdf_session_new_from_sourcecxx . . $ xccdf_session_new_from_source(635597adc8233c20).(source);
1213 if (session == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1214 goto cleanup;
1215 }
1216
1217 xccdf_session_set_validationcxx . . $ xccdf_session_set_validation(6c18952ef2e78e15).(session, action->validatecxx . . $ oscap_action#validate., getenvcxx . . $ getenv(a8b8e32347182212).("OSCAP_FULL_VALIDATION") != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1218 xccdf_session_set_signature_validationcxx . . $ xccdf_session_set_signature_validation(5724eff0bd74b67a).(session, action->validate_signaturecxx . . $ oscap_action#validate_signature.);
1219 xccdf_session_set_signature_enforcementcxx . . $ xccdf_session_set_signature_enforcement(5724eff0bd74b67a).(session, action->enforce_signaturecxx . . $ oscap_action#enforce_signature.);
1220 xccdf_session_configure_remote_resourcescxx . . $ xccdf_session_configure_remote_resources(39d1d6c85e4007df).(session, action->remote_resourcescxx . . $ oscap_action#remote_resources., action->local_filescxx . . $ oscap_action#local_files., download_reporting_callbackcxx . . $ download_reporting_callback(3ca54e6407cd3d15).);
1221 xccdf_session_set_user_tailoring_filecxx . . $ xccdf_session_set_user_tailoring_file(e1b914460d223154).(session, action->tailoring_filecxx . . $ oscap_action#tailoring_file.);
1222 xccdf_session_set_user_tailoring_cidcxx . . $ xccdf_session_set_user_tailoring_cid(e1b914460d223154).(session, action->tailoring_idcxx . . $ oscap_action#tailoring_id.);
1223 if (xccdf_session_is_sdscxx . . $ xccdf_session_is_sds(7ca1cfb6ae7817c7).(session)) {
1224 xccdf_session_set_component_idcxx . . $ xccdf_session_set_component_id(e1b914460d223154).(session, action->f_xccdf_idcxx . . $ oscap_action#f_xccdf_id.);
1225 xccdf_session_set_benchmark_idcxx . . $ xccdf_session_set_benchmark_id(e1b914460d223154).(session, action->f_benchmark_idcxx . . $ oscap_action#f_benchmark_id.);
1226 }
1227 xccdf_session_set_loading_flagscxx . . $ xccdf_session_set_loading_flags(3c1bec58736b4360).(session, XCCDF_SESSION_LOAD_XCCDFcxx . . $ XCCDF_SESSION_LOAD_XCCDF.);
1228
1229 if (xccdf_session_loadcxx . . $ xccdf_session_load(dd871bf8776e7fa2).(session) != 0) {
1230 goto cleanup;
1231 }
1232
1233 if (!xccdf_session_set_profile_idcxx . . $ xccdf_session_set_profile_id(5281e12fff4127ed).(session, action->profilecxx . . $ oscap_action#profile.)) {
1234 if (action->profilecxx . . $ oscap_action#profile. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) {
1235 if (xccdf_set_profile_or_report_bad_idcxx . . $ xccdf_set_profile_or_report_bad_id(958fe49146dd32a6).(session, action->profilecxx . . $ oscap_action#profile., action->f_xccdfcxx . . $ oscap_action#f_xccdf.) == OSCAP_ERRORcxx . . $ OSCAP_ERROR.)
1236 goto cleanup;
1237 } else {
1238 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "No Policy was found for default profile.\n");
1239 goto cleanup;
1240 }
1241 }
1242
1243 if (xccdf_session_generate_guidecxx . . $ xccdf_session_generate_guide(c44cfbc8af8f9f18).(session, action->f_resultscxx . . $ oscap_action#f_results.) == 0) {
1244 ret = OSCAP_OKcxx . . $ OSCAP_OK.;
1245 }
1246
1247 cleanup:
1248 xccdf_session_freecxx . . $ xccdf_session_free(fc68940e73a0edd6).(session);
1249 oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).();
1250 return ret;
1251 }
1252
1253 int app_xccdf_xsltcxx . . $ app_xccdf_xslt(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action)
1254 {
1255 const char *oval_template = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1256 const char *sce_template = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1257
1258 if (action->modulecxx . . $ oscap_action#module. == &XCCDF_GEN_REPORTcxx . . $ XCCDF_GEN_REPORT.) {
1259 /* If generating the report and the option is missing -> use defaults */
1260 struct oscap_sourcecxx . . $ oscap_source# *xccdf_source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->f_xccdfcxx . . $ oscap_action#f_xccdf.);
1261 /* We want to define default template because we strive to serve user the
1262 * best. However, we must not offer a template, if there is a risk it might
1263 * be incorrect. Otherwise, libxml2 will throw a lot of misleading messages
1264 * to stderr. */
1265 if (_some_result_existscxx . . $ _some_result_exists(c489d6adaa99944).(xccdf_source, "http://oval.mitre.org/XMLSchema/oval-definitions-5")) {
1266 oval_template = "%.result.xml";
1267 }
1268 if (_some_result_existscxx . . $ _some_result_exists(c489d6adaa99944).(xccdf_source, "http://open-scap.org/page/SCE")) {
1269 sce_template = "%.result.xml";
1270 }
1271 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(xccdf_source);
1272 }
1273
1274 if (action->modulecxx . . $ oscap_action#module. == &XCCDF_GEN_CUSTOMcxx . . $ XCCDF_GEN_CUSTOM.) {
1275 action->modulecxx . . $ oscap_action#module.->usercxx . . $ oscap_module#user. = (void*)action->stylesheetcxx . . $ oscap_action#stylesheet.;
1276 }
1277
1278 const char *params[] = {
1279 "result-id", action->idcxx . . $ oscap_action#id.,
1280 "benchmark_id", action->f_benchmark_idcxx . . $ oscap_action#f_benchmark_id.,
1281 "profile_id", action->profilecxx . . $ oscap_action#profile.,
1282 "oval-template", oval_template,
1283 "sce-template", sce_template,
1284 "verbosity", "",
1285 "hide-profile-info", action->hide_profile_infocxx . . $ oscap_action#hide_profile_info. ? "yes" : NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!,
1286 NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!
1287 };
1288
1289 int ret = app_xsltcxx . . $ app_xslt(94a5cfe74efaac1c).(action->f_xccdfcxx . . $ oscap_action#f_xccdf., action->modulecxx . . $ oscap_action#module.->usercxx . . $ oscap_module#user., action->f_resultscxx . . $ oscap_action#f_results., params);
1290 return ret;
1291 }
1292
1293 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! getopt_generatecxx . . $ getopt_generate(93e8ba72609212ff).(int argc, char **argv, struct oscap_actioncxx . . $ oscap_action# *action)
1294 {
1295 static const struct optioncxx . . $ option# long_options[] = {
1296 {"profile", 1, 0, 3},
1297 {0, 0, 0, 0}
1298 };
1299
1300 int c;
1301 while ((c = getopt_longcxx . . $ getopt_long(41f665c090816971).(argc, argv, "+", long_options, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)) != -1) {
1302 switch (c) {
1303 case 3: action->profilecxx . . $ oscap_action#profile. = optargcxx . . $ optarg.; break;
1304 default: return oscap_module_usagecxx . . $ oscap_module_usage(8d148a6468c518c9).(action->modulecxx . . $ oscap_action#module., stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1305 }
1306 }
1307 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1308 }
1309
1310 enum oval_optcxx . . $ oval_opt# {
1311 XCCDF_OPT_RESULT_FILEcxx . . $ XCCDF_OPT_RESULT_FILE. = 1,
1312 XCCDF_OPT_RESULT_FILE_STIGcxx . . $ XCCDF_OPT_RESULT_FILE_STIG.,
1313 XCCDF_OPT_RESULT_FILE_ARFcxx . . $ XCCDF_OPT_RESULT_FILE_ARF.,
1314 XCCDF_OPT_DATASTREAM_IDcxx . . $ XCCDF_OPT_DATASTREAM_ID.,
1315 XCCDF_OPT_XCCDF_IDcxx . . $ XCCDF_OPT_XCCDF_ID.,
1316 XCCDF_OPT_BENCHMARK_IDcxx . . $ XCCDF_OPT_BENCHMARK_ID.,
1317 XCCDF_OPT_PROFILEcxx . . $ XCCDF_OPT_PROFILE.,
1318 XCCDF_OPT_RULEcxx . . $ XCCDF_OPT_RULE.,
1319 XCCDF_OPT_SKIP_RULEcxx . . $ XCCDF_OPT_SKIP_RULE.,
1320 XCCDF_OPT_REPORT_FILEcxx . . $ XCCDF_OPT_REPORT_FILE.,
1321 XCCDF_OPT_FORMATcxx . . $ XCCDF_OPT_FORMAT.,
1322 XCCDF_OPT_STYLESHEET_FILEcxx . . $ XCCDF_OPT_STYLESHEET_FILE.,
1323 XCCDF_OPT_FILE_VERSIONcxx . . $ XCCDF_OPT_FILE_VERSION.,
1324 XCCDF_OPT_TAILORING_FILEcxx . . $ XCCDF_OPT_TAILORING_FILE.,
1325 XCCDF_OPT_TAILORING_IDcxx . . $ XCCDF_OPT_TAILORING_ID.,
1326 XCCDF_OPT_CPEcxx . . $ XCCDF_OPT_CPE.,
1327 XCCDF_OPT_CPE_DICTcxx . . $ XCCDF_OPT_CPE_DICT.,
1328 XCCDF_OPT_OUTPUTcxx . . $ XCCDF_OPT_OUTPUT. = 'o',
1329 XCCDF_OPT_RESULT_IDcxx . . $ XCCDF_OPT_RESULT_ID. = 'i',
1330 XCCDF_OPT_FIX_TYPEcxx . . $ XCCDF_OPT_FIX_TYPE.,
1331 XCCDF_OPT_LOCAL_FILEScxx . . $ XCCDF_OPT_LOCAL_FILES.,
1332 XCCDF_OPT_REFERENCEcxx . . $ XCCDF_OPT_REFERENCE.,
1333 XCCDF_OPT_VERBOSEcxx . . $ XCCDF_OPT_VERBOSE.,
1334 XCCDF_OPT_VERBOSE_LOG_FILEcxx . . $ XCCDF_OPT_VERBOSE_LOG_FILE.
1335 };
1336
1337 boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! getopt_xccdfcxx . . $ getopt_xccdf(93e8ba72609212ff).(int argc, char **argv, struct oscap_actioncxx . . $ oscap_action# *action)
1338 {
1339 assertcxx . . $ `/usr/include/assert.h:50:10`!(action != NULL);
1340
1341 action->doctypecxx . . $ oscap_action#doctype. = OSCAP_DOCUMENT_XCCDFcxx . . $ OSCAP_DOCUMENT_XCCDF.;
1342
1343 /* Command-options */
1344 const struct optioncxx . . $ option# long_options[] = {
1345 // options
1346 {"output", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_OUTPUTcxx . . $ XCCDF_OPT_OUTPUT.},
1347 {"results", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_RESULT_FILEcxx . . $ XCCDF_OPT_RESULT_FILE.},
1348 {"results-arf", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_RESULT_FILE_ARFcxx . . $ XCCDF_OPT_RESULT_FILE_ARF.},
1349 {"stig-viewer", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_RESULT_FILE_STIGcxx . . $ XCCDF_OPT_RESULT_FILE_STIG.},
1350 {"datastream-id", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_DATASTREAM_IDcxx . . $ XCCDF_OPT_DATASTREAM_ID.},
1351 {"xccdf-id", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_XCCDF_IDcxx . . $ XCCDF_OPT_XCCDF_ID.},
1352 {"benchmark-id", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_BENCHMARK_IDcxx . . $ XCCDF_OPT_BENCHMARK_ID.},
1353 {"profile", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_PROFILEcxx . . $ XCCDF_OPT_PROFILE.},
1354 {"rule", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_RULEcxx . . $ XCCDF_OPT_RULE.},
1355 {"skip-rule", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_SKIP_RULEcxx . . $ XCCDF_OPT_SKIP_RULE.},
1356 {"result-id", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_RESULT_IDcxx . . $ XCCDF_OPT_RESULT_ID.},
1357 {"report", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_REPORT_FILEcxx . . $ XCCDF_OPT_REPORT_FILE.},
1358 {"stylesheet", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_STYLESHEET_FILEcxx . . $ XCCDF_OPT_STYLESHEET_FILE.},
1359 {"tailoring-file", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_TAILORING_FILEcxx . . $ XCCDF_OPT_TAILORING_FILE.},
1360 {"tailoring-id", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_TAILORING_IDcxx . . $ XCCDF_OPT_TAILORING_ID.},
1361 {"cpe", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_CPEcxx . . $ XCCDF_OPT_CPE.},
1362 {"cpe-dict", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_CPE_DICTcxx . . $ XCCDF_OPT_CPE_DICT.}, // DEPRECATED!
1363 {"fix-type", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_FIX_TYPEcxx . . $ XCCDF_OPT_FIX_TYPE.},
1364 {"local-files", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_LOCAL_FILEScxx . . $ XCCDF_OPT_LOCAL_FILES.},
1365 {"reference", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_REFERENCEcxx . . $ XCCDF_OPT_REFERENCE.},
1366 {"verbose", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_VERBOSEcxx . . $ XCCDF_OPT_VERBOSE.},
1367 {"verbose-log-file", required_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:63:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, XCCDF_OPT_VERBOSE_LOG_FILEcxx . . $ XCCDF_OPT_VERBOSE_LOG_FILE.},
1368 // flags
1369 {"force", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->forcecxx . . $ oscap_action#force., 1},
1370 {"oval-results", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->oval_resultscxx . . $ oscap_action#oval_results., 1},
1371 {"check-engine-results", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->check_engine_resultscxx . . $ oscap_action#check_engine_results., 1},
1372 {"skip-validation", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->validatecxx . . $ oscap_action#validate., 0},
1373 {"skip-signature-validation", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->validate_signaturecxx . . $ oscap_action#validate_signature., 0},
1374 {"enforce-signature", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->enforce_signaturecxx . . $ oscap_action#enforce_signature., 1},
1375 {"fetch-remote-resources", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->remote_resourcescxx . . $ oscap_action#remote_resources., 1},
1376 {"progress", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->progresscxx . . $ oscap_action#progress., PROGRESS_OPT_SPARSEcxx . . $ PROGRESS_OPT_SPARSE.},
1377 {"progress-full", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->progresscxx . . $ oscap_action#progress., PROGRESS_OPT_FULLcxx . . $ PROGRESS_OPT_FULL.},
1378 {"remediate", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->remediatecxx . . $ oscap_action#remediate., 1},
1379 {"hide-profile-info", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->hide_profile_infocxx . . $ oscap_action#hide_profile_info., 1},
1380 {"export-variables", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->export_variablescxx . . $ oscap_action#export_variables., 1},
1381 {"skip-schematron", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->schematroncxx . . $ oscap_action#schematron., 0},
1382 {"without-syschar", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->without_sys_charscxx . . $ oscap_action#without_sys_chars., 1},
1383 {"thin-results", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->thin_resultscxx . . $ oscap_action#thin_results., 1},
1384 {"raw", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->rawcxx . . $ oscap_action#raw., 1},
1385 {"show-rule-details", no_argumentcxx . . $ `<external>/1746263805473775960/getopt_ext.h:62:9`!, &action->show_rule_detailscxx . . $ oscap_action#show_rule_details., 1},
1386 // end
1387 {0, 0, 0, 0}
1388 };
1389
1390 int c;
1391 while ((c = getopt_longcxx . . $ getopt_long(41f665c090816971).(argc, argv, "o:i:", long_options, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!)) != -1) {
1392
1393 switch (c) {
1394 case XCCDF_OPT_OUTPUTcxx . . $ XCCDF_OPT_OUTPUT.:
1395 case XCCDF_OPT_RESULT_FILEcxx . . $ XCCDF_OPT_RESULT_FILE.: action->f_resultscxx . . $ oscap_action#f_results. = optargcxx . . $ optarg.; break;
1396 case XCCDF_OPT_RESULT_FILE_STIGcxx . . $ XCCDF_OPT_RESULT_FILE_STIG.: action->f_results_stigcxx . . $ oscap_action#f_results_stig. = optargcxx . . $ optarg.; break;
1397 case XCCDF_OPT_RESULT_FILE_ARFcxx . . $ XCCDF_OPT_RESULT_FILE_ARF.: action->f_results_arfcxx . . $ oscap_action#f_results_arf. = optargcxx . . $ optarg.; break;
1398 case XCCDF_OPT_DATASTREAM_IDcxx . . $ XCCDF_OPT_DATASTREAM_ID.: action->f_datastream_idcxx . . $ oscap_action#f_datastream_id. = optargcxx . . $ optarg.; break;
1399 case XCCDF_OPT_XCCDF_IDcxx . . $ XCCDF_OPT_XCCDF_ID.: action->f_xccdf_idcxx . . $ oscap_action#f_xccdf_id. = optargcxx . . $ optarg.; break;
1400 case XCCDF_OPT_BENCHMARK_IDcxx . . $ XCCDF_OPT_BENCHMARK_ID.: action->f_benchmark_idcxx . . $ oscap_action#f_benchmark_id. = optargcxx . . $ optarg.; break;
1401 case XCCDF_OPT_PROFILEcxx . . $ XCCDF_OPT_PROFILE.: action->profilecxx . . $ oscap_action#profile. = optargcxx . . $ optarg.; break;
1402 case XCCDF_OPT_RULEcxx . . $ XCCDF_OPT_RULE.:
1403 oscap_stringlist_add_stringcxx . . $ oscap_stringlist_add_string(80c12aaea9c014af).(action->rulescxx . . $ oscap_action#rules., optargcxx . . $ optarg.);
1404 break;
1405 case XCCDF_OPT_SKIP_RULEcxx . . $ XCCDF_OPT_SKIP_RULE.:
1406 oscap_stringlist_add_stringcxx . . $ oscap_stringlist_add_string(80c12aaea9c014af).(action->skip_rulescxx . . $ oscap_action#skip_rules., optargcxx . . $ optarg.);
1407 break;
1408 case XCCDF_OPT_RESULT_IDcxx . . $ XCCDF_OPT_RESULT_ID.: action->idcxx . . $ oscap_action#id. = optargcxx . . $ optarg.; break;
1409 case XCCDF_OPT_REPORT_FILEcxx . . $ XCCDF_OPT_REPORT_FILE.: action->f_reportcxx . . $ oscap_action#f_report. = optargcxx . . $ optarg.; break;
1410 /* we use realpath to get an absolute path to given XSLT to prevent openscap from looking
1411 into /usr/share/openscap/xsl instead of CWD */
1412 case XCCDF_OPT_STYLESHEET_FILEcxx . . $ XCCDF_OPT_STYLESHEET_FILE.: oscap_realpathcxx . . $ oscap_realpath(ed8193f262e4eda).(optargcxx . . $ optarg., custom_stylesheet_pathcxx . . $ custom_stylesheet_path.); action->stylesheetcxx . . $ oscap_action#stylesheet. = custom_stylesheet_pathcxx . . $ custom_stylesheet_path.; break;
1413 case XCCDF_OPT_TAILORING_FILEcxx . . $ XCCDF_OPT_TAILORING_FILE.: action->tailoring_filecxx . . $ oscap_action#tailoring_file. = optargcxx . . $ optarg.; break;
1414 case XCCDF_OPT_TAILORING_IDcxx . . $ XCCDF_OPT_TAILORING_ID.: action->tailoring_idcxx . . $ oscap_action#tailoring_id. = optargcxx . . $ optarg.; break;
1415 case XCCDF_OPT_CPEcxx . . $ XCCDF_OPT_CPE.: action->cpecxx . . $ oscap_action#cpe. = optargcxx . . $ optarg.; break;
1416 case XCCDF_OPT_CPE_DICTcxx . . $ XCCDF_OPT_CPE_DICT.:
1417 {
1418 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, "Warning: --cpe-dict is a deprecated option. Please use --cpe instead!\n\n");
1419 action->cpecxx . . $ oscap_action#cpe. = optargcxx . . $ optarg.; break;
1420 }
1421 case XCCDF_OPT_FIX_TYPEcxx . . $ XCCDF_OPT_FIX_TYPE.:
1422 action->fix_typecxx . . $ oscap_action#fix_type. = optargcxx . . $ optarg.;
1423 break;
1424 case XCCDF_OPT_LOCAL_FILEScxx . . $ XCCDF_OPT_LOCAL_FILES.:
1425 action->local_filescxx . . $ oscap_action#local_files. = optargcxx . . $ optarg.;
1426 break;
1427 case XCCDF_OPT_REFERENCEcxx . . $ XCCDF_OPT_REFERENCE.:
1428 action->referencecxx . . $ oscap_action#reference. = optargcxx . . $ optarg.;
1429 break;
1430 case XCCDF_OPT_VERBOSEcxx . . $ XCCDF_OPT_VERBOSE.:
1431 action->verbosity_levelcxx . . $ oscap_action#verbosity_level. = optargcxx . . $ optarg.;
1432 break;
1433 case XCCDF_OPT_VERBOSE_LOG_FILEcxx . . $ XCCDF_OPT_VERBOSE_LOG_FILE.:
1434 action->f_verbose_logcxx . . $ oscap_action#f_verbose_log. = optargcxx . . $ optarg.;
1435 break;
1436 case 0: break;
1437 default: return oscap_module_usagecxx . . $ oscap_module_usage(8d148a6468c518c9).(action->modulecxx . . $ oscap_action#module., stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!);
1438 }
1439 }
1440
1441 if (action->modulecxx . . $ oscap_action#module. == &XCCDF_EVALcxx . . $ XCCDF_EVAL.) {
1442 /* We should have XCCDF file here */
1443 if (optindcxx . . $ optind. >= argc) {
1444 /* TODO */
1445 return oscap_module_usagecxx . . $ oscap_module_usage(8d148a6468c518c9).(action->modulecxx . . $ oscap_action#module., stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "XCCDF file need to be specified!");
1446 }
1447
1448 action->f_xccdfcxx . . $ oscap_action#f_xccdf. = argv[optindcxx . . $ optind.];
1449 if (argc > (optindcxx . . $ optind.+1)) {
1450 action->f_ovalscxx . . $ oscap_action#f_ovals. = malloccxx . . $ malloc(bfcfa4d6b7f7ef64).((argc-(optindcxx . . $ optind.+1)+1) * sizeof(char *));
1451 int i = 1;
1452 while (argc > (optindcxx . . $ optind.+i)) {
1453 action->f_ovalscxx . . $ oscap_action#f_ovals.[i-1] = argv[optindcxx . . $ optind. + i];
1454 i++;
1455 }
1456 action->f_ovalscxx . . $ oscap_action#f_ovals.[i-1] = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1457 } else {
1458 action->f_ovalscxx . . $ oscap_action#f_ovals. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!;
1459 }
1460 } else if (action->modulecxx . . $ oscap_action#module. == &XCCDF_GEN_CUSTOMcxx . . $ XCCDF_GEN_CUSTOM.) {
1461 if (!action->stylesheetcxx . . $ oscap_action#stylesheet.) {
1462 return oscap_module_usagecxx . . $ oscap_module_usage(8d148a6468c518c9).(action->modulecxx . . $ oscap_action#module., stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "XSLT Stylesheet needs to be specified!");
1463 }
1464
1465 if (optindcxx . . $ optind. >= argc)
1466 return oscap_module_usagecxx . . $ oscap_module_usage(8d148a6468c518c9).(action->modulecxx . . $ oscap_action#module., stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "XCCDF file needs to be specified!");
1467 action->f_xccdfcxx . . $ oscap_action#f_xccdf. = argv[optindcxx . . $ optind.];
1468 } else {
1469 if (optindcxx . . $ optind. >= argc)
1470 return oscap_module_usagecxx . . $ oscap_module_usage(8d148a6468c518c9).(action->modulecxx . . $ oscap_action#module., stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "XCCDF file needs to be specified!");
1471 action->f_xccdfcxx . . $ oscap_action#f_xccdf. = argv[optindcxx . . $ optind.];
1472 }
1473
1474 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
1475 }
1476
1477 int app_xccdf_validatecxx . . $ app_xccdf_validate(d99c68634f61e371).(const struct oscap_actioncxx . . $ oscap_action# *action) {
1478 int ret;
1479 int result = OSCAP_OKcxx . . $ OSCAP_OK.;
1480
1481 struct oscap_sourcecxx . . $ oscap_source# *source = oscap_source_new_from_filecxx . . $ oscap_source_new_from_file(987f8b70a317ffb9).(action->f_xccdfcxx . . $ oscap_action#f_xccdf.);
1482 ret = oscap_source_validatecxx . . $ oscap_source_validate(58e1cfedb30f1c20).(source, reportercxx . . $ reporter(710d628f83af7da6)., (void *) action);
1483
1484 if (ret < 0) {
1485 result = OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
1486 } else if (ret > 0) {
1487 result = OSCAP_FAILcxx . . $ OSCAP_FAIL.;
1488 } else {
1489 if (action->schematroncxx . . $ oscap_action#schematron.) {
1490 ret = oscap_source_validate_schematroncxx . . $ oscap_source_validate_schematron(a38c22d0fd42c683).(source);
1491 if (ret < 0) {
1492 result = OSCAP_ERRORcxx . . $ OSCAP_ERROR.;
1493 } else if (ret > 0) {
1494 result = OSCAP_FAILcxx . . $ OSCAP_FAIL.;
1495 }
1496 }
1497 }
1498
1499 oscap_source_freecxx . . $ oscap_source_free(1a322e80279420f6).(source);
1500 oscap_print_errorcxx . . $ oscap_print_error(49f6e7a06ebc5aa8).();
1501
1502 return result;
1503 }