Open SCAP Library
Loading...
Searching...
No Matches
Topics | Files | Data Structures | Typedefs | Enumerations | Functions
XCCDF_POLICY
Collaboration diagram for XCCDF_POLICY:

Topics

 Engine Plugin
 
 

Files

file  xccdf_policy.h
 Open-scap XCCDF Policy library interface.
 

Data Structures

struct  xccdf_policy_model
 XCCDF policy model structure contains xccdf_benchmark as reference to Benchmark element in XML file and list of policies that are abstract structure of Profile element from benchmark file. More...
 
struct  xccdf_policy
 XCCDF policy structure is abstract (class) structure of Profile element from benchmark. More...
 
struct  xccdf_value_binding
 XCCDF value binding structure is binding between Refine values, Set values, Value element and Check export element of benchmark. More...
 
struct  xccdf_policy_iterator
 Iterate through policies. More...
 
struct  oscap_file_entry_iterator
 
struct  oscap_file_entry_list
 

Typedefs

typedef void *(* xccdf_policy_engine_query_fn) (void *, xccdf_policy_engine_query_t, void *)
 Type of function which implements queries defined within xccdf_policy_engine_query_t.
 
typedef xccdf_test_result_type_t(* xccdf_policy_engine_eval_fn) (struct xccdf_policy *policy, const char *rule_id, const char *definition_id, const char *href_if, struct xccdf_value_binding_iterator *value_binding_it, struct xccdf_check_import_iterator *check_imports_it, void *user_data)
 Type of function which implements OpenSCAP checking engine.
 
typedef int(* policy_reporter_output) (struct xccdf_rule_result *, void *)
 
typedef int(* policy_reporter_start) (struct xccdf_rule *, void *)
 
typedef int(* policy_reporter_multicheck) (struct oval_definition *, void *)
 

Enumerations

enum  xccdf_policy_engine_query_t { POLICY_ENGINE_QUERY_NAMES_FOR_HREF = 1 , POLICY_ENGINE_QUERY_OVAL_DEFS_FOR_HREF = 2 }
 Type of a query over checking-engine data. More...
 

Functions

OSCAP_API bool xccdf_policy_model_set_tailoring (struct xccdf_policy_model *model, struct xccdf_tailoring *tailoring)
 Sets the Tailoring element to use in the policy.
 
OSCAP_API bool xccdf_policy_model_add_cpe_dict_source (struct xccdf_policy_model *model, struct oscap_source *source)
 Registers an additional CPE dictionary for applicability testing The one embedded in the evaluated XCCDF take precedence!
 
OSCAP_API bool xccdf_policy_model_add_cpe_dict (struct xccdf_policy_model *model, const char *cpe_dict)
 Registers an additional CPE dictionary for applicability testing The one embedded in the evaluated XCCDF take precedence!
 
OSCAP_API bool xccdf_policy_model_add_cpe_lang_model_source (struct xccdf_policy_model *model, struct oscap_source *source)
 Registers an additional CPE lang model for applicability testing The one embedded in the evaluated XCCDF take precedence!
 
OSCAP_API bool xccdf_policy_model_add_cpe_autodetect_source (struct xccdf_policy_model *model, struct oscap_source *source)
 Registers an additional CPE resource (either dictionary or language) Autodetects given file and acts accordingly.
 
OSCAP_API struct oscap_htable_iteratorxccdf_policy_model_get_cpe_oval_sessions (struct xccdf_policy_model *model)
 Retrieves an iterator of all OVAL sessions created for CPE applicability evaluation key is the OVAL href, value is the OVAL session itself (type oval_agent_session*)
 
OSCAP_API struct xccdf_policy_modelxccdf_policy_model::xccdf_policy_model_new (struct xccdf_benchmark *benchmark)
 Constructor of Policy Model structure.
 
OSCAP_API struct xccdf_policyxccdf_policy::xccdf_policy_new (struct xccdf_policy_model *model, struct xccdf_profile *profile)
 Constructor of Policy structure.
 
OSCAP_API struct xccdf_value_bindingxccdf_value_binding::xccdf_value_binding_new (void)
 Constructor of structure with profile bindings - refine_rules, refine_values and set_values.
 
OSCAP_API void xccdf_policy_model::xccdf_policy_model_free (struct xccdf_policy_model *)
 Destructor of Policy Model structure.
 
OSCAP_API void xccdf_policy::xccdf_policy_free (struct xccdf_policy *)
 Destructor of Policy structure.
 
OSCAP_API void xccdf_value_binding::xccdf_value_binding_free (struct xccdf_value_binding *)
 Destructor of Value binding structure.
 
OSCAP_API struct xccdf_tailoringxccdf_policy_model::xccdf_policy_model_get_tailoring (struct xccdf_policy_model *model)
 Retrieves the Tailoring element used in this policy.
 
OSCAP_API char * xccdf_policy::xccdf_policy_get_readable_item_title (struct xccdf_policy *policy, struct xccdf_item *item, const char *preferred_lang)
 Get human readable title of given XCCDF Item.
 
OSCAP_API char * xccdf_policy::xccdf_policy_get_readable_item_description (struct xccdf_policy *policy, struct xccdf_item *item, const char *preferred_lang)
 Get human readable description of given XCCDF Item.
 
OSCAP_API bool xccdf_policy_model::xccdf_policy_model_register_engine_and_query_callback (struct xccdf_policy_model *model, char *sys, xccdf_policy_engine_eval_fn eval_fn, void *usr, xccdf_policy_engine_query_fn query_fn)
 Function to register callback for checking system.
 
OSCAP_API bool xccdf_policy_model::xccdf_policy_model_register_output_callback (struct xccdf_policy_model *model, policy_reporter_output func, void *usr)
 Function to register output callback for checking system that will be called AFTER each rule evaluation.
 
OSCAP_API bool xccdf_policy_model::xccdf_policy_model_register_start_callback (struct xccdf_policy_model *model, policy_reporter_start func, void *usr)
 Function to register start callback for checking system that will be called BEFORE each rule evaluation.
 
OSCAP_API bool xccdf_policy_model::xccdf_policy_model_register_multicheck_callback (struct xccdf_policy_model *model, policy_reporter_multicheck func, void *usr)
 Function to register callback for checking system that will be called DURING each rule evaluation if rule sets multi-check="true".
 

Setters

For lists use add functions.

Parameters of set functions are duplicated in memory and need to be freed by caller.

OSCAP_API int xccdf_policy_get_selected_rules_count (struct xccdf_policy *policy)
 Retrieves number of selected items in the policy.
 
OSCAP_API bool xccdf_policy_model::xccdf_policy_model_add_policy (struct xccdf_policy_model *, struct xccdf_policy *)
 Add Policy to Policy Model.
 
OSCAP_API bool xccdf_policy::xccdf_policy_add_select (struct xccdf_policy *, struct xccdf_select *)
 Add rule to Policy.
 
OSCAP_API bool xccdf_policy_model::xccdf_policy_add_result (struct xccdf_policy *policy, struct xccdf_result *item)
 Add result to XCCDF Policy Model.
 
OSCAP_API bool xccdf_policy::xccdf_policy_add_value (struct xccdf_policy *, struct xccdf_value_binding *)
 Add value binding to the Policy structure.
 
OSCAP_API bool xccdf_policy::xccdf_policy_is_item_selected (struct xccdf_policy *policy, const char *id)
 Get the selection settings of the item.
 
OSCAP_API struct xccdf_selectxccdf_policy::xccdf_policy_get_select_by_id (struct xccdf_policy *policy, const char *item_id)
 Get select from policy by specified ID of XCCDF Item.
 

Evaluators

OSCAP_API struct oscap_file_entry_listxccdf_policy_model_get_systems_and_files (struct xccdf_policy_model *policy_model)
 Return names of files that are used in checks of particular rules.
 
OSCAP_API struct oscap_file_entry_listxccdf_item_get_systems_and_files (struct xccdf_item *item)
 Return names of files that are used in checks of particular rules.
 
OSCAP_API struct oscap_stringlistxccdf_policy_model_get_files (struct xccdf_policy_model *policy_model)
 Return names of files that are used in checks of particular rules.
 
OSCAP_API struct oscap_stringlistxccdf_item_get_files (struct xccdf_item *item)
 Return names of files that are used in checks of particular rules.
 
OSCAP_API xccdf_test_result_type_t xccdf_test_result_resolve_and_operation (xccdf_test_result_type_t A, xccdf_test_result_type_t B)
 Return result of the AND operation for two given attributes.
 
OSCAP_API struct xccdf_resultxccdf_policy::xccdf_policy_evaluate (struct xccdf_policy *policy)
 Call the checking engine for each selected rule in given policy structure.
 
OSCAP_API bool xccdf_policy::xccdf_policy_resolve (struct xccdf_policy *policy)
 Resolve benchmark by applying all refine_rules and refine_values to rules / values of benchmark.
 
OSCAP_API int xccdf_policy::xccdf_policy_generate_fix (struct xccdf_policy *policy, struct xccdf_result *result, const char *sys, const char *input_file_name, struct oscap_source *tailoring, int output_fd, int raw)
 Generate remediation prescription (presumably a remediation script).
 
OSCAP_API struct oscap_file_entryoscap_file_entry::oscap_file_entry_new (void)
 
OSCAP_API struct oscap_file_entryoscap_file_entry::oscap_file_entry_dup (struct oscap_file_entry *file_entry)
 
OSCAP_API void oscap_file_entry::oscap_file_entry_free (struct oscap_file_entry *entry)
 
OSCAP_API const char * oscap_file_entry::oscap_file_entry_get_system (struct oscap_file_entry *entry)
 
OSCAP_API const char * oscap_file_entry::oscap_file_entry_get_file (struct oscap_file_entry *entry)
 
OSCAP_API const struct oscap_file_entryoscap_file_entry_iterator::oscap_file_entry_iterator_next (struct oscap_file_entry_iterator *it)
 
OSCAP_API bool oscap_file_entry_iterator::oscap_file_entry_iterator_has_more (struct oscap_file_entry_iterator *it)
 
OSCAP_API void oscap_file_entry_iterator::oscap_file_entry_iterator_free (struct oscap_file_entry_iterator *it)
 
OSCAP_API void oscap_file_entry_iterator::oscap_file_entry_iterator_reset (struct oscap_file_entry_iterator *it)
 
OSCAP_API struct oscap_file_entry_listoscap_file_entry_list::oscap_file_entry_list_new (void)
 
OSCAP_API void oscap_file_entry_list::oscap_file_entry_list_free (struct oscap_file_entry_list *list)
 
OSCAP_API struct oscap_file_entry_iteratoroscap_file_entry_list::oscap_file_entry_list_get_files (struct oscap_file_entry_list *list)
 

Iterators

OSCAP_API struct xccdf_scorexccdf_policy_get_score (struct xccdf_policy *policy, struct xccdf_result *test_result, const char *system)
 Get score of the XCCDF Benchmark.
 
OSCAP_API int xccdf_policy_recalculate_score (struct xccdf_policy *policy, struct xccdf_result *test_result)
 Recalculate score of the XCCDF Benchmark.
 
OSCAP_API char * xccdf_policy_substitute (const char *text, struct xccdf_policy *policy)
 Perform textual substitution of cdf:sub elements with respect to given XCCDF policy.
 
OSCAP_API bool xccdf_policy_iterator::xccdf_policy_iterator_has_more (struct xccdf_policy_iterator *it)
 Return true if the list is not empty, false otherwise.
 
OSCAP_API struct xccdf_policyxccdf_policy_iterator::xccdf_policy_iterator_next (struct xccdf_policy_iterator *it)
 Return the next xccdf_policy structure from the list and increment the iterator.
 
OSCAP_API void xccdf_policy_iterator::xccdf_policy_iterator_free (struct xccdf_policy_iterator *it)
 Free the iterator structure (it makes no changes to the list structure)
 
OSCAP_API void xccdf_policy_iterator::xccdf_policy_iterator_reset (struct xccdf_policy_iterator *it)
 Reset the iterator structure (it will point to the first item in the list)
 
OSCAP_API const char * xccdf_policy::xccdf_policy_get_value_of_item (struct xccdf_policy *policy, struct xccdf_item *item)
 Get value of given value item in context of given policy.
 

Getters

Return value is pointer to structure's member.

Do not free unless you null the pointer in the structure. Use remove function otherwise.

OSCAP_API struct xccdf_policy_modelxccdf_policy::xccdf_policy_get_model (const struct xccdf_policy *policy)
 Get model from Policy (parent structure of Policy to access the benchmark)
 
OSCAP_API struct xccdf_benchmarkxccdf_policy_model::xccdf_policy_model_get_benchmark (const struct xccdf_policy_model *item)
 Get Benchmark from Policy Model.
 
OSCAP_API struct xccdf_value_binding_iterator * xccdf_policy::xccdf_policy_get_values (const struct xccdf_policy *item)
 Get Value Bindings from XCCDF Policy.
 
OSCAP_API struct xccdf_policy_iteratorxccdf_policy_model::xccdf_policy_model_get_policies (const struct xccdf_policy_model *model)
 Get policies from Policy Model.
 
OSCAP_API int xccdf_policy_model::xccdf_policy_model_build_all_useful_policies (struct xccdf_policy_model *policy_model)
 Build all policies that can be useful for user.
 
OSCAP_API struct xccdf_select_iteratorxccdf_policy::xccdf_policy_get_selected_rules (struct xccdf_policy *)
 Get selected rules from policy.
 
OSCAP_API struct xccdf_profilexccdf_policy::xccdf_policy_get_profile (const struct xccdf_policy *)
 Get XCCDF Profile from Policy.
 
OSCAP_API struct xccdf_select_iteratorxccdf_policy::xccdf_policy_get_selects (const struct xccdf_policy *)
 Get rules from Policy.
 
OSCAP_API char * xccdf_value_binding::xccdf_value_binding_get_name (const struct xccdf_value_binding *)
 Get variable name from value bindings.
 
OSCAP_API char * xccdf_value_binding::xccdf_value_binding_get_value (const struct xccdf_value_binding *)
 Get value from value bindings.
 
OSCAP_API xccdf_value_type_t xccdf_value_binding::xccdf_value_binding_get_type (const struct xccdf_value_binding *)
 get variable type from value bindings
 
OSCAP_API xccdf_operator_t xccdf_value_binding::xccdf_value_binding_get_operator (const struct xccdf_value_binding *)
 get Value operator from value bindings
 
OSCAP_API char * xccdf_value_binding::xccdf_value_binding_get_setvalue (const struct xccdf_value_binding *)
 get Set Value from value bindings
 
OSCAP_API struct xccdf_result_iteratorxccdf_policy_model::xccdf_policy_get_results (const struct xccdf_policy *policy)
 Get results of all XCCDF Policy results.
 
OSCAP_API struct xccdf_resultxccdf_policy_model::xccdf_policy_get_result_by_id (struct xccdf_policy *policy, const char *id)
 Get XCCDF Result structure by it's idetificator if there is one.
 
OSCAP_API const char * xccdf_policy::xccdf_policy_get_id (struct xccdf_policy *policy)
 Get ID of XCCDF Profile that is implemented by XCCDF Policy.
 
OSCAP_API struct xccdf_policyxccdf_policy_model::xccdf_policy_model_get_policy_by_id (struct xccdf_policy_model *policy_model, const char *id)
 Get XCCDF Policy from Policy model by speciefied ID of Profile.
 

Detailed Description

Policy interface to Extensible Configuration Checklist Description Format. Purpose of this layer is to separate the transport syntax of the XCCDF XML from the processes of evaluating and scoring the policy content comprised by the XCCDF documents. XCCDF Policy model performs the loading, evaluation and scoring tasks of XCCDF.

Typedef Documentation

◆ xccdf_policy_engine_eval_fn

typedef xccdf_test_result_type_t(* xccdf_policy_engine_eval_fn) (struct xccdf_policy *policy, const char *rule_id, const char *definition_id, const char *href_if, struct xccdf_value_binding_iterator *value_binding_it, struct xccdf_check_import_iterator *check_imports_it, void *user_data)

Type of function which implements OpenSCAP checking engine.

This function defines basic interface between XCCDF module and thee checking engine. For each checking engine required for evaluation there should be at least one such function registerd. The registered function is then used by xccdf_policy module to perform evaluation on the machine.

◆ xccdf_policy_engine_query_fn

typedef void *(* xccdf_policy_engine_query_fn) (void *, xccdf_policy_engine_query_t, void *)

Type of function which implements queries defined within xccdf_policy_engine_query_t.

Each checking engine may register its own function of the xccdf_policy_engine_query_fn type. The registered function is then used by xccdf_policy module to acquire comprehensive info about the checking-engine itself or the data fed in. First argument of the function is always user data as registered. Second argument defines the query. Third argument is dependent on query and defined as follows:

  • (const char *)href – for POLICY_ENGINE_QUERY_NAMES_FOR_HREF
  • (const char *)href – for POLICY_ENGINE_QUERY_OVAL_DEFS_FOR_HREF

Expected return type depends also on query as follows:

  • (struct oscap_stringlist *) – for POLICY_ENGINE_QUERY_NAMES_FOR_HREF
  • (struct oscap_list *) – for POLICY_ENGINE_QUERY_OVAL_DEFS_FOR_HREF
  • NULL shall be returned if the function doesn't understand the query.

Enumeration Type Documentation

◆ xccdf_policy_engine_query_t

Type of a query over checking-engine data.

This allows xccdf_policy module to query checking engine and acquire comprehensive info.

Function Documentation

◆ xccdf_item_get_files()

OSCAP_API struct oscap_stringlist * xccdf_item_get_files ( struct xccdf_item * item)

Return names of files that are used in checks of particular rules.

Every check needs this file to be evaluated properly. If this file will not be imported and bind to the XCCDF Policy system the result of rule after evaluation will be "Not checked"

◆ xccdf_item_get_systems_and_files()

OSCAP_API struct oscap_file_entry_list * xccdf_item_get_systems_and_files ( struct xccdf_item * item)

Return names of files that are used in checks of particular rules.

Every check needs this file to be evaluated properly. If this file will not be imported and bind to the XCCDF Policy system the result of rule after evaluation will be "Not checked"

The resulting list should be freed with oscap_filelist_free.

◆ xccdf_policy_add_select()

OSCAP_API bool xccdf_policy_add_select ( struct xccdf_policy * ,
struct xccdf_select *  )

Add rule to Policy.

Returns
true if rule has been added succesfully

◆ xccdf_policy_add_value()

OSCAP_API bool xccdf_policy_add_value ( struct xccdf_policy * ,
struct xccdf_value_binding *  )

Add value binding to the Policy structure.

Returns
true if rule has been added succesfully

◆ xccdf_policy_evaluate()

OSCAP_API struct xccdf_result * xccdf_policy_evaluate ( struct xccdf_policy * policy)

Call the checking engine for each selected rule in given policy structure.

Parameters
policygiven Policy to evaluate
Returns
true if evaluation pass or false in case of error
Example
Before each policy evaluation user has to register callback that will be called for each check. Every checking engine must have registered callback or the particular check will be skipped. In the code below is used the predefined function oval_agent_eval_rule for evaluation OVAL checks:
xccdf_policy_model_register_engine_oval(policy_mode, agent_session)
If you use this predefined OVAL callback, user data structure (last parameter of register function) MUST be of type oval_agent_session_t:
OSCAP_API * struct oval_agent_session * sess = oval_agent_new_session((struct oval_definition_model *) model, "name-of-file");
oval_agent_session_t * oval_agent_new_session(struct oval_definition_model *model, const char *name)
Create new session for OVAL agent from OVAL definition model.
Definition oval_agent.c:92
Definition oval_agent.c:54
Oval definition model.
Definition oval_defModel.c:53
struct xccdf_policy_model * model
XCCDF Policy model.
Definition xccdf_policy_priv.h:59

◆ xccdf_policy_generate_fix()

OSCAP_API int xccdf_policy_generate_fix ( struct xccdf_policy * policy,
struct xccdf_result * result,
const char * sys,
const char * input_file_name,
struct oscap_source * tailoring,
int output_fd,
int raw )

Generate remediation prescription (presumably a remediation script).

Parameters
policyXCCDF Policy
resultXCCDF TestResult. This may be omitted to generate the prescription based solely on the XCCDF Policy (xccdf:Profile).
sysConsider only those fixes that have @system attribute equal to sys
input_file_namefile name of the input SCAP file
tailoringinput tailoring file (parsed as oscap source)
output_fdwrite prescription to this file descriptor
rawcontrols verbosiness of generated remediation files (if greater than zero, the function won't add commentaries and optional boilerplate instructions)
Returns
zero on success, non-zero indicate partial (incomplete) output.

◆ xccdf_policy_get_id()

OSCAP_API const char * xccdf_policy_get_id ( struct xccdf_policy * policy)

Get ID of XCCDF Profile that is implemented by XCCDF Policy.

Parameters
policyXCCDF Policy
Returns
ID of Policy's Profile

◆ xccdf_policy_get_model()

OSCAP_API struct xccdf_policy_model * xccdf_policy_get_model ( const struct xccdf_policy * policy)

Get model from Policy (parent structure of Policy to access the benchmark)

Parameters
policyXCCDF Policy
Returns
Policy model

◆ xccdf_policy_get_profile()

OSCAP_API struct xccdf_profile * xccdf_policy_get_profile ( const struct xccdf_policy * )

Get XCCDF Profile from Policy.

Returns
XCCDF Profile

◆ xccdf_policy_get_readable_item_description()

OSCAP_API char * xccdf_policy_get_readable_item_description ( struct xccdf_policy * policy,
struct xccdf_item * item,
const char * preferred_lang )

Get human readable description of given XCCDF Item.

This function searches for description with the best matching language and resolves any inner <xccdf:sub> substitution (in accordance with the given XCCDF Policy.

Parameters
policyXCCDF Policy
itemXCCDF Item to query description from
preferred_langLanguage of your choice, Null value for the default.
Returns
plaintext C string which must be freed by caller

◆ xccdf_policy_get_readable_item_title()

OSCAP_API char * xccdf_policy_get_readable_item_title ( struct xccdf_policy * policy,
struct xccdf_item * item,
const char * preferred_lang )

Get human readable title of given XCCDF Item.

This finds title with best matching language and resolves <xccdf:sub> substitution in accordance with the given XCCDF Policy.

Parameters
policyXCCDF Policy
itemXCCDF Item to query title from
preferred_langLanguage of your choice, Null value for the default.
Returns
plaintext C string which must be freed by caller

◆ xccdf_policy_get_result_by_id()

OSCAP_API struct xccdf_result * xccdf_policy_get_result_by_id ( struct xccdf_policy * policy,
const char * id )

Get XCCDF Result structure by it's idetificator if there is one.

Returns
structure xccdf_result if found, NULL otherwise

◆ xccdf_policy_get_score()

OSCAP_API struct xccdf_score * xccdf_policy_get_score ( struct xccdf_policy * policy,
struct xccdf_result * test_result,
const char * system )

Get score of the XCCDF Benchmark.

Parameters
policyXCCDF Policy
test_resultTest Result model
systemScore system
Returns
XCCDF Score

◆ xccdf_policy_get_select_by_id()

OSCAP_API struct xccdf_select * xccdf_policy_get_select_by_id ( struct xccdf_policy * policy,
const char * item_id )

Get select from policy by specified ID of XCCDF Item.

Returns
XCCDF Select

◆ xccdf_policy_get_selected_rules()

OSCAP_API struct xccdf_select_iterator * xccdf_policy_get_selected_rules ( struct xccdf_policy * )

Get selected rules from policy.

Returns
Pointer to select iterator.
Return values
NULLon faliure

◆ xccdf_policy_get_selected_rules_count()

OSCAP_API int xccdf_policy_get_selected_rules_count ( struct xccdf_policy * policy)

Retrieves number of selected items in the policy.

Note
This is meant to be used to estimate scanning progress for example.

◆ xccdf_policy_get_selects()

OSCAP_API struct xccdf_select_iterator * xccdf_policy_get_selects ( const struct xccdf_policy * )

Get rules from Policy.

Returns
xccdf_select_iterator

◆ xccdf_policy_get_value_of_item()

OSCAP_API const char * xccdf_policy_get_value_of_item ( struct xccdf_policy * policy,
struct xccdf_item * item )

Get value of given value item in context of given policy.

Parameters
policyXCCDF policy
itemthe xccdf:Value to resolve
Returns
string representation of resolved value_instance.
Return values
NULLindicates failure

◆ xccdf_policy_is_item_selected()

OSCAP_API bool xccdf_policy_is_item_selected ( struct xccdf_policy * policy,
const char * id )

Get the selection settings of the item.

Returns
true if the item is selected

◆ xccdf_policy_model_add_cpe_autodetect_source()

OSCAP_API bool xccdf_policy_model_add_cpe_autodetect_source ( struct xccdf_policy_model * model,
struct oscap_source * source )

Registers an additional CPE resource (either dictionary or language) Autodetects given file and acts accordingly.

The one embedded in the evaluated XCCDF take precedence!

◆ xccdf_policy_model_add_cpe_dict()

OSCAP_API bool xccdf_policy_model_add_cpe_dict ( struct xccdf_policy_model * model,
const char * cpe_dict )

Registers an additional CPE dictionary for applicability testing The one embedded in the evaluated XCCDF take precedence!

Deprecated
Deprecated in favor of xccdf_policy_model_add_cpe_dict_source

◆ xccdf_policy_model_add_policy()

OSCAP_API bool xccdf_policy_model_add_policy ( struct xccdf_policy_model * ,
struct xccdf_policy *  )

Add Policy to Policy Model.

Returns
true if policy has been added succesfully

◆ xccdf_policy_model_build_all_useful_policies()

OSCAP_API int xccdf_policy_model_build_all_useful_policies ( struct xccdf_policy_model * policy_model)

Build all policies that can be useful for user.

The useful policy is any that contains at least one Rule. For example the default profile oftentimes does not contain any rules.

Parameters
policy_model- XCCDF Policy Model
Returns
0 on success

◆ xccdf_policy_model_get_benchmark()

OSCAP_API struct xccdf_benchmark * xccdf_policy_model_get_benchmark ( const struct xccdf_policy_model * item)

Get Benchmark from Policy Model.

Parameters
itemPolicy model structure
Returns
XCCDF Benchmark for given policy model

◆ xccdf_policy_model_get_files()

OSCAP_API struct oscap_stringlist * xccdf_policy_model_get_files ( struct xccdf_policy_model * policy_model)

Return names of files that are used in checks of particular rules.

Every check needs this file to be evaluated properly. If this file will not be imported and bind to the XCCDF Policy system the result of rule after evaluation will be "Not checked"

◆ xccdf_policy_model_get_policies()

OSCAP_API struct xccdf_policy_iterator * xccdf_policy_model_get_policies ( const struct xccdf_policy_model * model)

Get policies from Policy Model.

Be aware, this function returns only a list of previously initialized policies. A policy can be initialized by xccdf_policy_model_get_policy_by_id.

Parameters
modelPolicy Model
Returns
Iterator for list of policies

◆ xccdf_policy_model_get_policy_by_id()

OSCAP_API struct xccdf_policy * xccdf_policy_model_get_policy_by_id ( struct xccdf_policy_model * policy_model,
const char * id )

Get XCCDF Policy from Policy model by speciefied ID of Profile.

Parameters
policy_modelXCCDF Policy model
idID of Profile
Returns
XCCDF Policy

◆ xccdf_policy_model_get_systems_and_files()

OSCAP_API struct oscap_file_entry_list * xccdf_policy_model_get_systems_and_files ( struct xccdf_policy_model * policy_model)

Return names of files that are used in checks of particular rules.

Every check needs this file to be evaluated properly. If this file will not be imported and bind to the XCCDF Policy system the result of rule after evaluation will be "Not checked"

The resulting list should be freed with oscap_filelist_free.

◆ xccdf_policy_model_new()

OSCAP_API struct xccdf_policy_model * xccdf_policy_model_new ( struct xccdf_benchmark * benchmark)

Constructor of Policy Model structure.

Parameters
benchmarkStruct xccdf_benchmark with benchmark model
Returns
new xccdf_policy_model
Note
The policy model will take ownership of given benchmark and free it when it's being destructed!

◆ xccdf_policy_model_register_engine_and_query_callback()

OSCAP_API bool xccdf_policy_model_register_engine_and_query_callback ( struct xccdf_policy_model * model,
char * sys,
xccdf_policy_engine_eval_fn eval_fn,
void * usr,
xccdf_policy_engine_query_fn query_fn )

Function to register callback for checking system.

Parameters
modelXCCDF Policy Model
sysString representing given checking system
eval_fnCallback - pointer to function called by XCCDF Policy system when rule parsed
usroptional parameter for passing user data to callback
query_fn- optional parameter for providing xccdf_policy_engine_query_fn implementation for given system.
Returns
true if callback registered succesfully, false otherwise

◆ xccdf_policy_model_register_multicheck_callback()

OSCAP_API bool xccdf_policy_model_register_multicheck_callback ( struct xccdf_policy_model * model,
policy_reporter_multicheck func,
void * usr )

Function to register callback for checking system that will be called DURING each rule evaluation if rule sets multi-check="true".

Parameters
modelXCCDF Policy Model
funcCallback - pointer to function called by XCCDF Policy system when rule parsed
usroptional parameter for passing user data to callback
Returns
true if callback registered successfully, false otherwise

◆ xccdf_policy_model_register_output_callback()

OSCAP_API bool xccdf_policy_model_register_output_callback ( struct xccdf_policy_model * model,
policy_reporter_output func,
void * usr )

Function to register output callback for checking system that will be called AFTER each rule evaluation.

Parameters
modelXCCDF Policy Model
funcCallback - pointer to function called by XCCDF Policy system when rule parsed
usroptional parameter for passing user data to callback
Returns
true if callback registered succesfully, false otherwise

◆ xccdf_policy_model_register_start_callback()

OSCAP_API bool xccdf_policy_model_register_start_callback ( struct xccdf_policy_model * model,
policy_reporter_start func,
void * usr )

Function to register start callback for checking system that will be called BEFORE each rule evaluation.

Parameters
modelXCCDF Policy Model
funcCallback - pointer to function called by XCCDF Policy system when rule parsed
usroptional parameter for passing user data to callback
Returns
true if callback registered succesfully, false otherwise

◆ xccdf_policy_model_set_tailoring()

OSCAP_API bool xccdf_policy_model_set_tailoring ( struct xccdf_policy_model * model,
struct xccdf_tailoring * tailoring )

Sets the Tailoring element to use in the policy.

Profiles from the Benchmark may be shadowed by profiles in the given Tailoring element! Calling this function will affect the results of xccdf_policy_model_get_policy_by_id calls.

@important This does INVALIDATE preexisting xccdf_policy pointers in this xccdf_policy_model! It is recommended to call this function before policy for any profile is queried.

Note
The policy model will take ownership of given tailoring and free it when it's being destructed or when new tailoring is being set.

◆ xccdf_policy_new()

OSCAP_API struct xccdf_policy * xccdf_policy_new ( struct xccdf_policy_model * model,
struct xccdf_profile * profile )

Constructor of Policy structure.

Parameters
modelPolicy model
profileProfile from XCCDF Benchmark

◆ xccdf_policy_recalculate_score()

OSCAP_API int xccdf_policy_recalculate_score ( struct xccdf_policy * policy,
struct xccdf_result * test_result )

Recalculate score of the XCCDF Benchmark.

Parameters
policyXCCDF Policy
test_resultTest Result model
Returns
zero on success

◆ xccdf_policy_resolve()

OSCAP_API bool xccdf_policy_resolve ( struct xccdf_policy * policy)

Resolve benchmark by applying all refine_rules and refine_values to rules / values of benchmark.

All properties in benchmark will be irreversible changed and user has to load benchmark (from XML) again to discard these changes.

Parameters
policyXCCDF policy containing rules/values that will be applied to benchmark rules/values.
Returns
true if process ends succesfuly or false in case of error

◆ xccdf_policy_substitute()

OSCAP_API char * xccdf_policy_substitute ( const char * text,
struct xccdf_policy * policy )

Perform textual substitution of cdf:sub elements with respect to given XCCDF policy.

Parameters
texttext to be substituted
policypolicy to be used

◆ xccdf_test_result_resolve_and_operation()

OSCAP_API xccdf_test_result_type_t xccdf_test_result_resolve_and_operation ( xccdf_test_result_type_t A,
xccdf_test_result_type_t B )

Return result of the AND operation for two given attributes.

For more details about the attributes A and B please consult 'Table 26: Possible Results for a Single Test' from NISTIR-7275r4. For more details about the AND operation please consult 'Table 12: Truth Table for AND' in the very same document.

◆ xccdf_value_binding_get_name()

OSCAP_API char * xccdf_value_binding_get_name ( const struct xccdf_value_binding * )

Get variable name from value bindings.

Returns
String

◆ xccdf_value_binding_get_operator()

OSCAP_API xccdf_operator_t xccdf_value_binding_get_operator ( const struct xccdf_value_binding * )

get Value operator from value bindings

Returns
xccdf_operator_t

◆ xccdf_value_binding_get_setvalue()

OSCAP_API char * xccdf_value_binding_get_setvalue ( const struct xccdf_value_binding * )

get Set Value from value bindings

Returns
String

◆ xccdf_value_binding_get_type()

OSCAP_API xccdf_value_type_t xccdf_value_binding_get_type ( const struct xccdf_value_binding * )

get variable type from value bindings

Returns
xccdf_value_type_t

◆ xccdf_value_binding_get_value()

OSCAP_API char * xccdf_value_binding_get_value ( const struct xccdf_value_binding * )

Get value from value bindings.

Returns
String

◆ xccdf_value_binding_new()

OSCAP_API struct xccdf_value_binding * xccdf_value_binding_new ( void )

Constructor of structure with profile bindings - refine_rules, refine_values and set_values.

Returns
new structure of xccdf_value_binding