Open SCAP Library

Public Member Functions | Data Fields
xccdf_policy Struct Reference
XCCDF_POLICY

XCCDF policy structure is abstract (class) structure of Profile element from benchmark. More...

`#include <xccdf_policy_priv.h>`

## Public Member Functions
struct xccdf_policy * | xccdf_policy_new (struct xccdf_policy_model *model, struct xccdf_profile *profile)
| Constructor of Policy structure. More...
void | xccdf_policy_free (struct xccdf_policy *)
| Destructor of Policy structure.
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. More...
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. More...
int | xccdf_policy_resolve_fix_substitution (struct xccdf_policy *policy, struct xccdf_fix *fix, struct xccdf_rule_result *rule_result, struct xccdf_result *test_result)
| Resolve text substitution in given fix element. More...
int | xccdf_policy_remediate (struct xccdf_policy *policy, struct xccdf_result *result)
| Remediate all rule-results in the given result, with settings of given policy. More...
int | xccdf_policy_report_cb (struct xccdf_policy *policy, const char *sysname, void *rule)
| Report given "rule" to all callbacks with given sysname registered with the policy. More...
struct xccdf_benchmark * | xccdf_policy_get_benchmark (const struct xccdf_policy *policy)
| Get XCCDF Benchmark for given policy. More...
Getters
Return value is pointer to structure's member. Do not free unless you null the pointer in the structure. Use remove function otherwise.
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) More...
struct xccdf_value_binding_iterator * | xccdf_policy_get_values (const struct xccdf_policy *item)
| Get Value Bindings from XCCDF Policy.
struct xccdf_select_iterator * | xccdf_policy_get_selected_rules (struct xccdf_policy *)
| Get selected rules from policy. More...
struct xccdf_profile * | xccdf_policy_get_profile (const struct xccdf_policy *)
| Get XCCDF Profile from Policy. More...
struct xccdf_select_iterator * | xccdf_policy_get_selects (const struct xccdf_policy *)
| Get rules from Policy. More...
const char * | xccdf_policy_get_id (struct xccdf_policy *policy)
| Get ID of XCCDF Profile that is implemented by XCCDF Policy. More...
Setters
For lists use add functions. Parameters of set functions are duplicated in memory and need to be freed by caller.
bool | xccdf_policy_add_select (struct xccdf_policy *, struct xccdf_select *)
| Add rule to Policy. More...
bool | xccdf_policy_set_selected (struct xccdf_policy *policy, char *idref)
| Set a new selector to the Policy structure. More...
bool | xccdf_policy_add_value (struct xccdf_policy *, struct xccdf_value_binding *)
| Add value binding to the Policy structure. More...
bool | xccdf_policy_is_item_selected (struct xccdf_policy *policy, const char *id)
| Get the selection settings of the item. More...
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. More...
Evaluators
struct xccdf_result * | xccdf_policy_evaluate (struct xccdf_policy *policy)
| Call the checking engine for each selected rule in given policy structure. More...
bool | xccdf_policy_resolve (struct xccdf_policy *policy)
| Resolve benchmark by applying all refine_rules and refine_values to rules / values of benchmark. More...
int | xccdf_policy_generate_fix (struct xccdf_policy *policy, struct xccdf_result *result, const char *sys, int output_fd)
| Generate remediation prescription (presumably a remediation script). More...
Iterators
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. More...

## Data Fields
struct xccdf_policy_model * | model
| XCCDF Policy model.
struct xccdf_profile * | profile
| Profile structure (from benchmark)
const char * | rule
| A list of all selects. More...
int | rule_found
| Single-rule feature: flag for rule - if rule is found it is set to 1 otherwise 0.
struct oscap_list * | selects
struct oscap_list * | values
| Bound values of profile.
struct oscap_list * | results
| List of XCCDF results.
struct oscap_htable * | selected_internal
| A hash which for given item points to the latest selector applicable. More...
struct oscap_htable * | selected_final
| A hash which for given item defines final selection.
struct oscap_htable * | refine_rules_internal

## Detailed Description

XCCDF policy structure is abstract (class) structure of Profile element from benchmark.

Policy structure that abstract benchmark's profile.

Structure contains rules and bound values to abstract these lists from the benchmark file. Can be modified temporaly so changes can be discarded or saved to the existing model.

## Member Function Documentation

## ◆ xccdf_policy_get_benchmark()

struct xccdf_benchmark * xccdf_policy_get_benchmark | ( | const struct xccdf_policy * | policy | ) |

Get XCCDF Benchmark for given policy.

Parameters

  policy | XCCDF Policy

Returns
  the benchmark element or NULL.

## ◆ xccdf_policy_remediate()

int xccdf_policy_remediate | ( | struct xccdf_policy * | policy,
|  | struct xccdf_result * | result
| ) |  |

Remediate all rule-results in the given result, with settings of given policy.

Parameters

  policy | XCCDF Policy
  result | TestResult containing rule-results to remediate

## ◆ xccdf_policy_report_cb()

int xccdf_policy_report_cb | ( | struct xccdf_policy * | policy,
|  | const char * | sysname,
|  | void * | rule
| ) |  |

Report given "rule" to all callbacks with given sysname registered with the policy.

Parameters

  policy | XCCDF Policy
  sysname | identifier of the reporting callback
  rule | pointer to xccdf:Rule or xccdf:rule-result

Returns
  zero on success. Non zero value may indicate user interuption or error.

## ◆ xccdf_policy_resolve_fix_substitution()

int xccdf_policy_resolve_fix_substitution | ( | struct xccdf_policy * | policy,
|  | struct xccdf_fix * | fix,
|  | struct xccdf_rule_result * | rule_result,
|  | struct xccdf_result * | test_result
| ) |  |

Resolve text substitution in given fix element.

Use given xccdf_policy settings for resolving.

Parameters

  policy | XCCDF policy used for substitution
  fix | a fix element to modify
  rule_result | the rule-result for substitution instnace in fix
  test_result | the TestResult for xccdf:fact resolution

Returns
  0 on success, 1 on failure, other value indicate warning

## Field Documentation

## ◆ rule

const char* xccdf_policy::rule

A list of all selects.

Either from profile or later added through API. Single-rule feature: if not NULL, only this one rule will be selected.

## ◆ selected_internal

struct oscap_htable* xccdf_policy::selected_internal

A hash which for given item points to the latest selector applicable.

There might not be one. Note that it migth be a selector for cluster-id.

The documentation for this struct was generated from the following files:

- xccdf_policy_priv.h
- xccdf_policy.h