exec.setDefinitionXmlFile(getSourceContext().getSourceContent().getLocalFile());
exec.setVerifyDefinitionsFileMD5Hash(false);
exec.setOutputInfoAndErrorsToSTDOUT(config.isLogOutput());
exec.setApplyXSLStylesheetToResults(false);
ResultContext resultContext = config.getResultContextResolver().resolve(getSourceContext(), "oval-results_", ".xml");
File resultFile = resultContext.getResultFile();
exec.setResultsFile(resultFile);
OvalVariablesDocument variablesDocument = getVariablesDocument(getExports(), config);
if (variablesDocument != null) {
File variablesFile = resultContext.getAuxiliaryFile("oval-variables_", ".xml");
variablesDocument.save( variablesFile, new XmlOptions().setSavePrettyPrint() );
exec.setExternalVariableFile( variablesFile );
variablesDocumentContent = new FileResultContent(variablesFile);
}
Set<String> defList = getCheckedDefinitions();
if (!defList.isEmpty()) {
EvalutationDefinitionIdsDocument evaluatedDefinitionsDocument = getEvaluatedDefinitionsDocument(defList);
if (evaluatedDefinitionsDocument != null) {
File evaluatedDefinitionsFile = resultContext.getAuxiliaryFile("oval-evaluation-ids_", ".xml");
evaluatedDefinitionsDocument.save(evaluatedDefinitionsFile, new XmlOptions().setSavePrettyPrint());
exec.setExternalEvaluatedDefinitionsFile(evaluatedDefinitionsFile);
evaluationIdsDocumentContent = new FileResultContent(evaluatedDefinitionsFile);
}
}
OVALDirectives directives = (OVALDirectives)config.getDirective(getCheckSystem().getSystem());
if (directives != null) {
File directivesFile = resultContext.getAuxiliaryFile("oval-directives_", ".xml");
XmlObject content = directives.getContent(config);
content.save(directivesFile, new XmlOptions().setSavePrettyPrint());
exec.setDirectivesFile(directivesFile);
directivesContent = new FileResultContent(directivesFile);
// Handle suppression of systems characteristics
if (directives.isSuppressSystemsCharacteristics()) {
// TODO: P4: implement XSL to remove item data using -t and -x
}
}
int exitCode = exec.exec(getCheckSystem(), config, System.out);
if ( exitCode != 0 || resultFile.canRead() == false ) {
log.error("execution of OVALDI failed for content: " + getSourceContext().getId());
result = new OVALResult(this, "Execution of OVALDI failed with error code: "+exitCode);
} else {
FileResultContent resultContent = new FileResultContent(resultFile);
resultContext.setResultContent(resultContent);
result = new OVALResult(this, resultContext);
}
} catch ( FileNotFoundException ex ) {
log.error("cannot find OVALDI executable", ex);