sce_engine.c File Reference

Script Check Engine. More...

#include "common/alloc.h"
#include "common/_error.h"
#include "common/util.h"
#include "common/list.h"
#include "common/oscap_acquire.h"
#include "common/oscap_string.h"
#include "common/debug_priv.h"
#include "sce_engine_api.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <wait.h>
#include <unistd.h>
#include <sys/stat.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/types.h>
#include <limits.h>
#include <libgen.h>

Data Structures

struct  sce_check_result
struct  sce_session
struct  sce_parameters

Functions

struct sce_check_result * sce_check_result_new (void)
 sce_check_result
void sce_check_result_free (struct sce_check_result *v)
 sce_check_result
void sce_check_result_set_href (struct sce_check_result *v, const char *href)
 Sets the href used to execute the check that yielded given check result.
const char * sce_check_result_get_href (struct sce_check_result *v)
 sce_check_result
void sce_check_result_set_basename (struct sce_check_result *v, const char *base_name)
 Sets basename of the script that was used for check evaluation.
const char * sce_check_result_get_basename (struct sce_check_result *v)
 sce_check_result
void sce_check_result_set_stdout (struct sce_check_result *v, const char *_stdout)
 Sets stdout that was captured while script was evaluating.
const char * sce_check_result_get_stdout (struct sce_check_result *v)
 sce_check_result
void sce_check_result_set_stderr (struct sce_check_result *v, const char *_stderr)
 Sets stderr that was captured while script was evaluating.
const char * sce_check_result_get_stderr (struct sce_check_result *v)
 sce_check_result
void sce_check_result_set_exit_code (struct sce_check_result *v, int exit_code)
 Sets exit code with which the script ended execution after evaluation sce_check_result.
int sce_check_result_get_exit_code (struct sce_check_result *v)
 sce_check_result
void sce_check_result_reset_environment_variables (struct sce_check_result *v)
 Clears the list of passed environment variables.
void sce_check_result_add_environment_variable (struct sce_check_result *v, const char *var)
 Adds an environment variable entry to list of environment variables that were passed to the script.
void sce_check_result_set_xccdf_result (struct sce_check_result *v, xccdf_test_result_type_t result)
 Sets the final xccdf result (after exit code to xccdf mapping takes place).
xccdf_test_result_type_t sce_check_result_get_xccdf_result (struct sce_check_result *v)
 sce_check_result
void sce_check_result_export (struct sce_check_result *v, const char *target_file)
 Exports details (in XML form) of given check result to given file.
struct sce_session * sce_session_new (void)
 sce_session
void sce_session_free (struct sce_session *s)
 sce_session
void sce_session_reset (struct sce_session *s)
 Removes all check results from the session.
void sce_session_add_check_result (struct sce_session *s, struct sce_check_result *result)
 Adds a check result to the session.
struct sce_check_result_iteratorsce_session_get_check_results (struct sce_session *s)
void sce_session_export_to_directory (struct sce_session *s, const char *directory)
 Exports all check results to given directory.
struct sce_parameters * sce_parameters_new (void)
 sce_parameters
void sce_parameters_free (struct sce_parameters *v)
 sce_parameters
void sce_parameters_set_xccdf_directory (struct sce_parameters *v, const char *value)
 Sets the directory that contains XCCDF that will reference SCE checks.
const char * sce_parameters_get_xccdf_directory (struct sce_parameters *v)
 sce_parameters
void sce_parameters_set_session (struct sce_parameters *v, struct sce_session *value)
 Sets SCE session to use for check results storage.
struct sce_session * sce_parameters_get_session (struct sce_parameters *v)
 sce_parameters
void sce_parameters_allocate_session (struct sce_parameters *v)
 Just a convenience shortcut of setting a session to a newly allocated session.
xccdf_test_result_type_t sce_engine_eval_rule (struct xccdf_policy *policy, const char *rule_id, const char *id, const char *href, struct xccdf_value_binding_iterator *value_binding_it, struct xccdf_check_import_iterator *check_import_it, void *usr)
 Internal rule evaluation callback, don't use directly.
bool xccdf_policy_model_register_engine_sce (struct xccdf_policy_model *model, struct sce_parameters *parameters)
 Registers SCE to given policy model.


Detailed Description

Script Check Engine.


Function Documentation

void sce_check_result_add_environment_variable ( struct sce_check_result *  v,
const char *  var 
)

Adds an environment variable entry to list of environment variables that were passed to the script.

These include XCCDF result codes, bound XCCDF variables and possibly more.

sce_check_result contains these mostly for debugging purposes.

Parameters:
var entry that will be added, in "VARIABLE_NAME=VARIABLE_VALUE" form sce_check_result

void sce_check_result_export ( struct sce_check_result *  v,
const char *  target_file 
)

Exports details (in XML form) of given check result to given file.

sce_check_result

void sce_check_result_reset_environment_variables ( struct sce_check_result *  v  ) 

Clears the list of passed environment variables.

sce_check_result

void sce_check_result_set_basename ( struct sce_check_result *  v,
const char *  basename 
)

Sets basename of the script that was used for check evaluation.

sce_check_result

void sce_check_result_set_href ( struct sce_check_result *  v,
const char *  href 
)

Sets the href used to execute the check that yielded given check result.

sce_check_result

void sce_check_result_set_stderr ( struct sce_check_result *  v,
const char *  details 
)

Sets stderr that was captured while script was evaluating.

Parameters:
stderr should contain output only from stderr sce_check_result

void sce_check_result_set_stdout ( struct sce_check_result *  v,
const char *  details 
)

Sets stdout that was captured while script was evaluating.

Parameters:
stdout should contain output only from stdout sce_check_result

void sce_check_result_set_xccdf_result ( struct sce_check_result *  v,
xccdf_test_result_type_t  result 
)

Sets the final xccdf result (after exit code to xccdf mapping takes place).

sce_check_result

xccdf_test_result_type_t sce_engine_eval_rule ( struct xccdf_policy policy,
const char *  rule_id,
const char *  id,
const char *  href,
struct xccdf_value_binding_iterator *  value_binding_it,
struct xccdf_check_import_iterator check_import_it,
void *  usr 
)

Internal rule evaluation callback, don't use directly.

See also:
xccdf_policy_model_register_engine_sce

void sce_parameters_allocate_session ( struct sce_parameters *  v  ) 

Just a convenience shortcut of setting a session to a newly allocated session.

The session gets automatically freed when sce_parameters are freed, don't deallocate it! sce_parameters

void sce_parameters_set_session ( struct sce_parameters *  v,
struct sce_session *  value 
)

Sets SCE session to use for check results storage.

Parameters:
v 
value SCE session to use (sce_parameters take ownership of it, don't deallocate it!) sce_parameters

void sce_session_add_check_result ( struct sce_session *  s,
struct sce_check_result *  result 
)

Adds a check result to the session.

Parameters:
s session to add the check result to
result result to be added (the session takes ownership of it, don't deallocate it!) sce_session

void sce_session_export_to_directory ( struct sce_session *  s,
const char *  directory 
)

Exports all check results to given directory.

sce_session

void sce_session_reset ( struct sce_session *  s  ) 

Removes all check results from the session.

sce_session

bool xccdf_policy_model_register_engine_sce ( struct xccdf_policy_model model,
struct sce_parameters *  sce_parameters 
)

Registers SCE to given policy model.

Parameters:
model model to register SCE to
sce_parameters various parameters to be used with SCE (you are responsible to deallocate them!)


Generated on Tue Nov 14 12:18:56 2017 for Open SCAP Library by  doxygen 1.5.6