| oscap.h | | oscap.h | |
| /* | | /* | |
|
| * Copyright 2009 Red Hat Inc., Durham, North Carolina. | | * Copyright 2009,2010,2011 Red Hat Inc., Durham, North Carolina. | |
| * All Rights Reserved. | | * All Rights Reserved. | |
| * | | * | |
| * This library is free software; you can redistribute it and/or | | * This library is free software; you can redistribute it and/or | |
| * modify it under the terms of the GNU Lesser General Public | | * modify it under the terms of the GNU Lesser General Public | |
| * License as published by the Free Software Foundation; either | | * License as published by the Free Software Foundation; either | |
| * version 2.1 of the License, or (at your option) any later version. | | * version 2.1 of the License, or (at your option) any later version. | |
| * | | * | |
| * This library is distributed in the hope that it will be useful, | | * This library is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| * Lesser General Public License for more details. | | * Lesser General Public License for more details. | |
| * | | * | |
| * You should have received a copy of the GNU Lesser General Public | | * You should have received a copy of the GNU Lesser General Public | |
| * License along with this library; if not, write to the Free Software | | * License along with this library; if not, write to the Free Software | |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
A | | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 US
A | |
| * | | * | |
| * Authors: | | * Authors: | |
| * Lukas Kuklinek <lkuklinek@redhat.com> | | * Lukas Kuklinek <lkuklinek@redhat.com> | |
|
| | | * Peter Vrabec <pvrabec@redhat.com> | |
| */ | | */ | |
| | | | |
| /** | | /** | |
| * @file | | * @file | |
| * General OpenScap functions and types. | | * General OpenScap functions and types. | |
| * @author Lukas Kuklinek <lkuklinek@redhat.com> | | * @author Lukas Kuklinek <lkuklinek@redhat.com> | |
| * | | * | |
| * @addtogroup COMMON | | * @addtogroup COMMON | |
| * @{ | | * @{ | |
| */ | | */ | |
| | | | |
| skipping to change at line 42 | | skipping to change at line 43 | |
| #ifndef OSCAP_H_ | | #ifndef OSCAP_H_ | |
| #define OSCAP_H_ | | #define OSCAP_H_ | |
| #include <stdbool.h> | | #include <stdbool.h> | |
| #include <wchar.h> | | #include <wchar.h> | |
| | | | |
| #include "text.h" | | #include "text.h" | |
| #include "reference.h" | | #include "reference.h" | |
| #include "reporter.h" | | #include "reporter.h" | |
| | | | |
| /** | | /** | |
|
| * @addtogroup ITER | | * This macro will warn, when a deprecated function is used. | |
| * @{ | | | |
| * | | | |
| * Iterators concept. | | | |
| * | | | |
| * Any iterator name takes a form of <tt>struct OBJECT_iterator</tt>, where | | | |
| @c OBJECT | | | |
| * is a name of particular datatype the iterator iterates over. | | | |
| * | | | |
| * Each iterator type defines several manipulation functions, namely: | | | |
| * - @c OBJECT_iterator_has_more - returns true if there is anything left t | | | |
| o iterate over | | | |
| * - @c OBJECT_iterator_next - returns next item in the collection | | | |
| * - @c OBJECT_iterator_free - destroys the iterator | | | |
| * | | | |
| * You can also use @ref OSCAP_FOREACH convience macro. | | | |
| */ | | | |
| | | | |
| /** | | | |
| * Iterate over an array, given an iterator. | | | |
| * Execute @a code for each array member stored in @a val. | | | |
| * It is NOT safe to use return or goto inside of the @a code, | | | |
| * the iterator would not be freed properly. | | | |
| */ | | | |
| #define OSCAP_FOREACH_GENERIC(itype, vtype, val, init_val, code) \ | | | |
| { \ | | | |
| struct itype##_iterator *val##_iter = (init_val); \ | | | |
| vtype val; \ | | | |
| while (itype##_iterator_has_more(val##_iter)) { \ | | | |
| val = itype##_iterator_next(val##_iter); \ | | | |
| code \ | | | |
| } \ | | | |
| itype##_iterator_free(val##_iter); \ | | | |
| } | | | |
| | | | |
| /** | | | |
| * Iterate over an array, given an iterator. | | | |
| * @param type type of array elements (w/o the struct keyword) | | | |
| * @param val name of an variable the member will be sequentially stored in | | | |
| * @param init_val initial member value (i.e. an iterator pointing to the s | | | |
| tart element) | | | |
| * @param code code to be executed for each element the iterator hits | | | |
| * @see OSCAP_FOREACH_GENERIC | | | |
| */ | | | |
| #define OSCAP_FOREACH(type, val, init_val, code) \ | | | |
| OSCAP_FOREACH_GENERIC(type, struct type *, val, init_val, code) | | | |
| | | | |
| /** | | | |
| * Iterate over an array of strings, given an iterator. | | | |
| * @param val name of an variable the string will be sequentially stored in | | | |
| * @param init_val initial member value (i.e. an iterator pointing to the s | | | |
| tart element) | | | |
| * @param code code to be executed for each string the iterator hits | | | |
| * @see OSCAP_FOREACH_GENERIC | | | |
| */ | | | |
| #define OSCAP_FOREACH_STR(val, init_val, code) \ | | | |
| OSCAP_FOREACH_GENERIC(oscap_string, const char *, val, init_val, co | | | |
| de) | | | |
| | | | |
| /** | | | |
| * Iterate over an array, given an iterator. | | | |
| * It is generally not safe to use break, return or goto inside the loop | | | |
| * (iterator wouldn't be properly freed otherwise). | | | |
| * Two variables, named VAL and VAL_iter (substitute VAL for actual macro a | | | |
| rgument) | | | |
| * will be added to current variable scope. You can free the iterator expli | | | |
| citly | | | |
| * after previous unusual escape from the loop (e.g. using break). | | | |
| * @param val name of an variable the string will be sequentially stored in | | | |
| * @param init_val initial member value (i.e. an iterator pointing to the s | | | |
| tart element) | | | |
| * @param code code to be executed for each string the iterator hits | | | |
| */ | | | |
| #define OSCAP_FOR_GENERIC(itype, vtype, val, init_val) \ | | | |
| vtype val = NULL; struct itype##_iterator *val##_iter = (init_val); \ | | | |
| while (itype##_iterator_has_more(val##_iter) \ | | | |
| ? (val = itype##_iterator_next(val##_iter), true) \ | | | |
| : (itype##_iterator_free(val##_iter), val##_iter = NULL, false) | | | |
| ) | | | |
| | | | |
| /** | | | |
| * Iterate over an array, given an iterator. | | | |
| * @param type type of array elements (w/o the struct keyword) | | | |
| * @param val name of an variable the member will be sequentially stored in | | | |
| * @param init_val initial member value (i.e. an iterator pointing to the s | | | |
| tart element) | | | |
| * @see OSCAP_FOR_GENERIC | | | |
| */ | | */ | |
|
| #define OSCAP_FOR(type, val, init_val) OSCAP_FOR_GENERIC(type, struct type | | #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) | |
| *, val, init_val) | | # define OSCAP_DEPRECATED(func) func __attribute__ ((deprecated)) | |
| | | #elif defined(_MSC_VER) | |
| /** | | # define OSCAP_DEPRECATED(func) __declspec(deprecated) func | |
| * Iterate over an array of strings, given an iterator. | | #else | |
| * @param val name of an variable the member will be sequentially stored in | | # pragma message("WARNING: You need to implement OSCAP_DEPRECATED for this | |
| * @param init_val initial member value (i.e. an iterator pointing to the s | | compiler---in order to get deprecation warnings.") | |
| tart element) | | # define OSCAP_DEPRECATED(func) func | |
| * @see OSCAP_FOR_GENERIC | | #endif | |
| */ | | | |
| #define OSCAP_FOR_STR(val, init_val) OSCAP_FOR_GENERIC(oscap_string, const | | | |
| char *, val, init_val) | | | |
| | | | |
| /** @} */ | | | |
| | | | |
| /// OS-specific filesystem path delimiter | | | |
| extern const char * const OSCAP_OS_PATH_DELIM; | | | |
| | | | |
| /// Default XML Schema path (if not overridden by the environment variable) | | | |
| extern const char * const OSCAP_SCHEMA_PATH; | | | |
| | | | |
| /// Default XSLT path (if not overridden by the environment variable) | | | |
| extern const char * const OSCAP_XSLT_PATH; | | | |
| | | | |
| /** | | /** | |
| * Initialize OpenSCAP library. | | * Initialize OpenSCAP library. | |
| * | | * | |
| * This is currently needed only in multithreaded applications | | * This is currently needed only in multithreaded applications | |
| * (needs to be called before any child threads are spawned) | | * (needs to be called before any child threads are spawned) | |
| * or applications using the XSLT facility w/ EXSLT extensions. | | * or applications using the XSLT facility w/ EXSLT extensions. | |
| * However, it is a good practice to call this function | | * However, it is a good practice to call this function | |
| * always at the beginning of the program execution. | | * always at the beginning of the program execution. | |
| */ | | */ | |
| | | | |
| skipping to change at line 188 | | skipping to change at line 101 | |
| OSCAP_DOCUMENT_CPE_LANGUAGE, ///< CPE language file | | OSCAP_DOCUMENT_CPE_LANGUAGE, ///< CPE language file | |
| OSCAP_DOCUMENT_CPE_DICTIONARY, ///< CPE dictionary file | | OSCAP_DOCUMENT_CPE_DICTIONARY, ///< CPE dictionary file | |
| OSCAP_DOCUMENT_SCE_RESULT, ///< SCE result file | | OSCAP_DOCUMENT_SCE_RESULT, ///< SCE result file | |
| OSCAP_DOCUMENT_SDS, ///< Source Data Stream file | | OSCAP_DOCUMENT_SDS, ///< Source Data Stream file | |
| OSCAP_DOCUMENT_ARF ///< Result Data Stream file | | OSCAP_DOCUMENT_ARF ///< Result Data Stream file | |
| } oscap_document_type_t; | | } oscap_document_type_t; | |
| | | | |
| /** | | /** | |
| * Validate a SCAP document file against a XML schema. | | * Validate a SCAP document file against a XML schema. | |
| * | | * | |
|
| * Schemas are searched relative to path specified by the OSCAP_SCHEMA_PATH | | * Schemas are searched relative to path specified by the OSCAP_SCHEMA_PATH | |
| environment variable, | | environment variable. | |
| * which contains a list of colon-separated paths. | | | |
| * If the variable does not exist a default path is used (usually something
like $PREFIX/share/openscap/schemas). | | * If the variable does not exist a default path is used (usually something
like $PREFIX/share/openscap/schemas). | |
| * | | * | |
| * Directory structure must adhere $SCHEMA_PATH/$STANDARD/$VERSION/$SCHEMAF
ILE.xsd structure, where $STANDARD | | * Directory structure must adhere $SCHEMA_PATH/$STANDARD/$VERSION/$SCHEMAF
ILE.xsd structure, where $STANDARD | |
| * is oval, xccdf, etc., and $VERSION is a version of the standard. | | * is oval, xccdf, etc., and $VERSION is a version of the standard. | |
| * | | * | |
| * @param xmlfile File to be validated. | | * @param xmlfile File to be validated. | |
| * @param doctype Document type represented by the file. | | * @param doctype Document type represented by the file. | |
| * @param version Version of the document, use NULL for library's default. | | * @param version Version of the document, use NULL for library's default. | |
| * @param reporetr A reporter to by notified of encountered issues. Can be
NULL, if a binary document validates / does not validate answer is satisfac
tonary. | | * @param reporetr A reporter to by notified of encountered issues. Can be
NULL, if a binary document validates / does not validate answer is satisfac
tonary. | |
| * @param arg Argument for the reporter. | | * @param arg Argument for the reporter. | |
| * @return 0 on pass; -1 error; 1 fail | | * @return 0 on pass; -1 error; 1 fail | |
| */ | | */ | |
| int oscap_validate_document(const char *xmlfile, oscap_document_type_t doct
ype, const char *version, oscap_reporter reporter, void *arg); | | int oscap_validate_document(const char *xmlfile, oscap_document_type_t doct
ype, const char *version, oscap_reporter reporter, void *arg); | |
| | | | |
| /** | | /** | |
| * Validate a SCAP document file against schematron rules. | | * Validate a SCAP document file against schematron rules. | |
| * | | * | |
|
| * The rules are searched relative to path specified by the OSCAP_SCHEMA_PA | | * The rules are searched relative to path specified by the OSCAP_SCHEMA_PA | |
| TH environment variable, | | TH environment variable. | |
| * which contains a list of colon-separated paths. | | | |
| * If the variable does not exist a default path is used (usually something
like $PREFIX/share/openscap/schemas). | | * If the variable does not exist a default path is used (usually something
like $PREFIX/share/openscap/schemas). | |
| * | | * | |
| * @param xmlfile File to be validated. | | * @param xmlfile File to be validated. | |
| * @param doctype Document type represented by the file. | | * @param doctype Document type represented by the file. | |
| * @param version Version of the document, use NULL for library's default. | | * @param version Version of the document, use NULL for library's default. | |
| * @param outfile Report from schematron validation is written into the out
file. If NULL, stdou will be used. | | * @param outfile Report from schematron validation is written into the out
file. If NULL, stdou will be used. | |
| * @return 0 on pass; <0 error; >0 fail | | * @return 0 on pass; <0 error; >0 fail | |
| */ | | */ | |
| int oscap_schematron_validate_document(const char *xmlfile, oscap_document_
type_t doctype, const char *version, const char *outfile); | | int oscap_schematron_validate_document(const char *xmlfile, oscap_document_
type_t doctype, const char *version, const char *outfile); | |
| | | | |
| /** | | /** | |
| * Apply a XSLT stylesheet to a XML file. | | * Apply a XSLT stylesheet to a XML file. | |
| * | | * | |
|
| * Stylesheets are searched relative to path specified by the OSCAP_XSLT_PA | | * Stylesheets are searched relative to path specified by the OSCAP_XSLT_PA | |
| TH environment variable, | | TH environment variable. | |
| * which contains a list of colon-separated paths. | | | |
| * If the variable does not exist a default path is used (usually something
like $PREFIX/share/openscap/schemas). | | * If the variable does not exist a default path is used (usually something
like $PREFIX/share/openscap/schemas). | |
| * | | * | |
| * @param xmlfile File to be transformed. | | * @param xmlfile File to be transformed. | |
| * @param xsltfile XSLT filename | | * @param xsltfile XSLT filename | |
| * @param outfile Result file shall be written here (NULL for stdout). | | * @param outfile Result file shall be written here (NULL for stdout). | |
| * @param params list of key-value pairs to pass to the stylesheet. | | * @param params list of key-value pairs to pass to the stylesheet. | |
| * @return the number of bytes written or -1 in case of failure | | * @return the number of bytes written or -1 in case of failure | |
| */ | | */ | |
| int oscap_apply_xslt(const char *xmlfile, const char *xsltfile, const char
*outfile, const char **params); | | int oscap_apply_xslt(const char *xmlfile, const char *xsltfile, const char
*outfile, const char **params); | |
| | | | |
| /** | | /** | |
|
| * Apply XSLT stylesheet to a XML file. | | * Function returns path used to locate OpenSCAP XML schemas | |
| * | | */ | |
| * This function lets user specify environment variable with | | const char * oscap_path_to_schemas(void); | |
| * a XSL stylesheet search path(s) and a fallback path if the variable is n | | | |
| ot defined. | | /** | |
| * Except for this it is completely identical to oscap_apply_xslt(). | | * Function returns path used to locate OpenSCAP Schematron files | |
| * | | | |
| * @param xmlfile File to be transformed. | | | |
| * @param xsltfile XSLT filename | | | |
| * @param outfile Result file shall be written here (NULL for stdout). | | | |
| * @param params list of key-value pairs to pass to the stylesheet. | | | |
| * @return the number of bytes written or -1 in case of failure | | | |
| */ | | */ | |
|
| int oscap_apply_xslt_var(const char *xmlfile, const char *xsltfile, const c
har *outfile, const char **params, const char *pathvar, const char *defpath
); | | const char * oscap_path_to_schematron(void); | |
| | | | |
| /************************************************************/ | | /************************************************************/ | |
| /** @} validation group end */ | | /** @} validation group end */ | |
| | | | |
| /** @} */ | | /** @} */ | |
| | | | |
| #endif | | #endif | |
| | | | |
End of changes. 9 change blocks. |
| 133 lines changed or deleted | | 25 lines changed or added | |
|
| oval_definitions.h | | oval_definitions.h | |
| | | | |
| skipping to change at line 209 | | skipping to change at line 209 | |
| OVAL_COMPONENT_VARREF = 3, | | OVAL_COMPONENT_VARREF = 3, | |
| OVAL_COMPONENT_FUNCTION = 4, | | OVAL_COMPONENT_FUNCTION = 4, | |
| OVAL_FUNCTION_BEGIN = OVAL_FUNCTION + 1, | | OVAL_FUNCTION_BEGIN = OVAL_FUNCTION + 1, | |
| OVAL_FUNCTION_CONCAT = OVAL_FUNCTION + 2, | | OVAL_FUNCTION_CONCAT = OVAL_FUNCTION + 2, | |
| OVAL_FUNCTION_END = OVAL_FUNCTION + 3, | | OVAL_FUNCTION_END = OVAL_FUNCTION + 3, | |
| OVAL_FUNCTION_SPLIT = OVAL_FUNCTION + 4, | | OVAL_FUNCTION_SPLIT = OVAL_FUNCTION + 4, | |
| OVAL_FUNCTION_SUBSTRING = OVAL_FUNCTION + 5, | | OVAL_FUNCTION_SUBSTRING = OVAL_FUNCTION + 5, | |
| OVAL_FUNCTION_TIMEDIF = OVAL_FUNCTION + 6, | | OVAL_FUNCTION_TIMEDIF = OVAL_FUNCTION + 6, | |
| OVAL_FUNCTION_ESCAPE_REGEX = OVAL_FUNCTION + 7, | | OVAL_FUNCTION_ESCAPE_REGEX = OVAL_FUNCTION + 7, | |
| OVAL_FUNCTION_REGEX_CAPTURE = OVAL_FUNCTION + 8, | | OVAL_FUNCTION_REGEX_CAPTURE = OVAL_FUNCTION + 8, | |
|
| OVAL_FUNCTION_ARITHMETIC = OVAL_FUNCTION + 9 | | OVAL_FUNCTION_ARITHMETIC = OVAL_FUNCTION + 9, | |
| | | OVAL_FUNCTION_COUNT = OVAL_FUNCTION + 10, | |
| | | OVAL_FUNCTION_LAST = OVAL_FUNCTION + 11 | |
| } oval_component_type_t; | | } oval_component_type_t; | |
| | | | |
| /// Arithmetic format enumeration | | /// Arithmetic format enumeration | |
| typedef enum { | | typedef enum { | |
| OVAL_ARITHMETIC_UNKNOWN = 0, | | OVAL_ARITHMETIC_UNKNOWN = 0, | |
| OVAL_ARITHMETIC_ADD = 1, | | OVAL_ARITHMETIC_ADD = 1, | |
| OVAL_ARITHMETIC_MULTIPLY = 2, | | OVAL_ARITHMETIC_MULTIPLY = 2, | |
| OVAL_ARITHMETIC_SUBTRACT = 3, //NOT YET SUPPORTED BY OVAL | | OVAL_ARITHMETIC_SUBTRACT = 3, //NOT YET SUPPORTED BY OVAL | |
| OVAL_ARITHMETIC_DIVIDE = 4 //NOT YET SUPPORTED BY OVAL | | OVAL_ARITHMETIC_DIVIDE = 4 //NOT YET SUPPORTED BY OVAL | |
| } oval_arithmetic_operation_t; | | } oval_arithmetic_operation_t; | |
| | | | |
| skipping to change at line 471 | | skipping to change at line 473 | |
| * OVAL variable component | | * OVAL variable component | |
| * Oval_component instances specify evaluation constraints on local variabl
es (see @ref oval_variable_get_type). | | * Oval_component instances specify evaluation constraints on local variabl
es (see @ref oval_variable_get_type). | |
| * | | * | |
| * - If @ref oval_component_get_type == @ref OVAL_FUNCTION_CONCAT - Con
catenation function | | * - If @ref oval_component_get_type == @ref OVAL_FUNCTION_CONCAT - Con
catenation function | |
| * - Oval_function_CONCAT takes two or more components and sub-
concatenates them together to form a single string. | | * - Oval_function_CONCAT takes two or more components and sub-
concatenates them together to form a single string. | |
| * The first component makes up the begining of the resulting s
tring and any following components are added to the end it. | | * The first component makes up the begining of the resulting s
tring and any following components are added to the end it. | |
| * If one of the components returns multiple values then the co
ncat function would be performed multiple times and the end result would be
an array of values for the local variable. | | * If one of the components returns multiple values then the co
ncat function would be performed multiple times and the end result would be
an array of values for the local variable. | |
| * For example assume a local variable has two sub-components:
a basic component element returns the values "abc" and "def", and a literal
component element that has a value of "xyz". | | * For example assume a local variable has two sub-components:
a basic component element returns the values "abc" and "def", and a literal
component element that has a value of "xyz". | |
| * The local_variable element would be evaluated to have two va
lues, "abcxyz" and "defxyz". If one of the components does not exist, | | * The local_variable element would be evaluated to have two va
lues, "abcxyz" and "defxyz". If one of the components does not exist, | |
| * then the result of the concat operation should be does not e
xist. | | * then the result of the concat operation should be does not e
xist. | |
|
| | | * - If @ref oval_component_get_type == @ref OVAL_FUNCTION_COUNT - Coun | |
| | | ting function. | |
| | | * - The count function counts the values represented by one or | |
| | | more components as an integer. This function determines the total number o | |
| | | f values referenced | |
| | | * by all of thespecified sub-components. | |
| * - If @ref oval_component_get_type == @ref OVAL_FUNCTION_ARITHMETIC -
Arithmetic function. | | * - If @ref oval_component_get_type == @ref OVAL_FUNCTION_ARITHMETIC -
Arithmetic function. | |
| * - The arithmetic function takes two or more integer or float
components and performs a basic mathmetical function on them. | | * - The arithmetic function takes two or more integer or float
components and performs a basic mathmetical function on them. | |
| * The result of this function in a single integer or float unl
ess one of the components returns multiple values. | | * The result of this function in a single integer or float unl
ess one of the components returns multiple values. | |
| * In this case the specified arithmetic function would be perf
ormed multiple times and the end result would be an array of values for the
local variable. | | * In this case the specified arithmetic function would be perf
ormed multiple times and the end result would be an array of values for the
local variable. | |
| * For example assume a local_variable specifies the arithmetic
function with an arithmetic_operation of "add" and has two sub-components
under this function: | | * For example assume a local_variable specifies the arithmetic
function with an arithmetic_operation of "add" and has two sub-components
under this function: | |
| * the first component returns multiple values "1" and "2", and
the second component returns multiple values "3" and "4" and "5". | | * the first component returns multiple values "1" and "2", and
the second component returns multiple values "3" and "4" and "5". | |
| * The local_variable element would be evaluated to have six va
lues: 1+3, 1+4, 1+5, 2+3, 2+4, and 2+5. | | * The local_variable element would be evaluated to have six va
lues: 1+3, 1+4, 1+5, 2+3, 2+4, and 2+5. | |
| * - If @ref oval_component_get_type == @ref OVAL_FUNCTION_REGEX_CAPTUR
E - Regex_capture function. | | * - If @ref oval_component_get_type == @ref OVAL_FUNCTION_REGEX_CAPTUR
E - Regex_capture function. | |
| * - The regex_capture function captures a single substring fro
m a string component. | | * - The regex_capture function captures a single substring fro
m a string component. | |
| * The 'pattern' attribute provides a regular expression that
must contain a single subexpression (using parentheses). | | * The 'pattern' attribute provides a regular expression that
must contain a single subexpression (using parentheses). | |
| | | | |
| skipping to change at line 931 | | skipping to change at line 936 | |
| */ | | */ | |
| struct oval_reference_iterator *oval_definition_get_references(struct oval_
definition *); | | struct oval_reference_iterator *oval_definition_get_references(struct oval_
definition *); | |
| /** | | /** | |
| * Returns attribute @ref oval_definition->notes. | | * Returns attribute @ref oval_definition->notes. | |
| * @return A new iterator for the notes attribute of the specified @ref ova
l_definition. | | * @return A new iterator for the notes attribute of the specified @ref ova
l_definition. | |
| * It should be freed after use by the calling application. | | * It should be freed after use by the calling application. | |
| * @memberof oval_definition | | * @memberof oval_definition | |
| */ | | */ | |
| struct oval_string_iterator *oval_definition_get_notes(struct oval_definiti
on *); | | struct oval_string_iterator *oval_definition_get_notes(struct oval_definiti
on *); | |
| /** | | /** | |
|
| * @return A pointer to the xmlNode element holding any unstructured metada | | | |
| ta included | | | |
| * in the definition. Adding and removing child elements is permitted. | | | |
| * All the child elements will be exported in the metadata of the definitio | | | |
| n. | | | |
| * @memberof oval_definition | | | |
| */ | | | |
| xmlNode *oval_definition_get_metadata(struct oval_definition *); | | | |
| /** | | | |
| * Returns attribute @ref oval_definition->criteria. | | * Returns attribute @ref oval_definition->criteria. | |
| * @return A pointer to the criteria attribute of the specified @ref oval_d
efinition. | | * @return A pointer to the criteria attribute of the specified @ref oval_d
efinition. | |
| * @memberof oval_definition | | * @memberof oval_definition | |
| */ | | */ | |
| struct oval_criteria_node *oval_definition_get_criteria(struct oval_definit
ion *); | | struct oval_criteria_node *oval_definition_get_criteria(struct oval_definit
ion *); | |
| /** @} */ | | /** @} */ | |
| | | | |
| /** | | /** | |
| * @name Evaluators | | * @name Evaluators | |
| * @{ | | * @{ | |
| | | | |
| skipping to change at line 1978 | | skipping to change at line 1976 | |
| * @name Setters | | * @name Setters | |
| * @{ | | * @{ | |
| */ | | */ | |
| /** | | /** | |
| * Set attribute @ref Oval_criteria_node->negate. | | * Set attribute @ref Oval_criteria_node->negate. | |
| * @param negate - the required value of the negate attribute | | * @param negate - the required value of the negate attribute | |
| * @memberof oval_criteria_node | | * @memberof oval_criteria_node | |
| */ | | */ | |
| void oval_criteria_node_set_negate(struct oval_criteria_node *, bool negate
); | | void oval_criteria_node_set_negate(struct oval_criteria_node *, bool negate
); | |
| /** | | /** | |
|
| | | * Set attribute @ref Oval_criteria_node->applicability_check. | |
| | | * @param applicability_check - the required value of the applicability_che | |
| | | ck attribute | |
| | | * @memberof oval_criteria_node | |
| | | */ | |
| | | void oval_criteria_node_set_applicability_check(struct oval_criteria_node * | |
| | | , bool applicability_check); | |
| | | /** | |
| * Set attribute @ref Oval_criteria_node->type. | | * Set attribute @ref Oval_criteria_node->type. | |
| * @param type - the required value of the type attribute | | * @param type - the required value of the type attribute | |
| * @memberof oval_criteria_node | | * @memberof oval_criteria_node | |
| */ | | */ | |
| void oval_criteria_set_node_type(struct oval_criteria_node *node, oval_crit
eria_node_type_t type); | | void oval_criteria_set_node_type(struct oval_criteria_node *node, oval_crit
eria_node_type_t type); | |
| /** | | /** | |
| * set attribute @ref Oval_criteria_node->comment. | | * set attribute @ref Oval_criteria_node->comment. | |
| * @param comm - (Not NULL) a copy of the comment parameter is set as the
comment attribute. | | * @param comm - (Not NULL) a copy of the comment parameter is set as the
comment attribute. | |
| * @memberof oval_criteria_node | | * @memberof oval_criteria_node | |
| */ | | */ | |
| | | | |
| skipping to change at line 2041 | | skipping to change at line 2045 | |
| * Returns attribute @ref Oval_criteria_node->type. | | * Returns attribute @ref Oval_criteria_node->type. | |
| * @memberof oval_criteria_node | | * @memberof oval_criteria_node | |
| */ | | */ | |
| oval_criteria_node_type_t oval_criteria_node_get_type(struct oval_criteria_
node *); | | oval_criteria_node_type_t oval_criteria_node_get_type(struct oval_criteria_
node *); | |
| /** | | /** | |
| * Returns attribute @ref Oval_criteria_node->negate. | | * Returns attribute @ref Oval_criteria_node->negate. | |
| * @memberof oval_criteria_node | | * @memberof oval_criteria_node | |
| */ | | */ | |
| bool oval_criteria_node_get_negate(struct oval_criteria_node *); | | bool oval_criteria_node_get_negate(struct oval_criteria_node *); | |
| /** | | /** | |
|
| | | * Returns attribute @ref Oval_criteria_node->applicability_check. | |
| | | * @memberof oval_criteria_node | |
| | | */ | |
| | | bool oval_criteria_node_get_applicability_check(struct oval_criteria_node * | |
| | | ); | |
| | | | |
| | | /** | |
| * Returns attribute @ref Oval_criteria_node->comment. | | * Returns attribute @ref Oval_criteria_node->comment. | |
| * @return A pointer to the comment attribute of the specified @ref oval_cr
iteria_node. | | * @return A pointer to the comment attribute of the specified @ref oval_cr
iteria_node. | |
| * @memberof oval_criteria_node | | * @memberof oval_criteria_node | |
| */ | | */ | |
| char *oval_criteria_node_get_comment(struct oval_criteria_node *); | | char *oval_criteria_node_get_comment(struct oval_criteria_node *); | |
| /** | | /** | |
| * Returns attribute @ref Oval_criteria->operator HOWDI. | | * Returns attribute @ref Oval_criteria->operator HOWDI. | |
| * @note If Oval_criteria_node->type <> @ref OVAL_NODETYPE_CRITERIA, this m
ethod shall return @ref OVAL_OPERATOR_UNKNOWN. | | * @note If Oval_criteria_node->type <> @ref OVAL_NODETYPE_CRITERIA, this m
ethod shall return @ref OVAL_OPERATOR_UNKNOWN. | |
| * @memberof oval_criteria_node | | * @memberof oval_criteria_node | |
| */ | | */ | |
| | | | |
| skipping to change at line 2858 | | skipping to change at line 2868 | |
| * @{ | | * @{ | |
| */ | | */ | |
| /** @} */ | | /** @} */ | |
| | | | |
| /** | | /** | |
| * Construct new intance of @ref Oval_component. | | * Construct new intance of @ref Oval_component. | |
| * Attribute values shall be initialized: | | * Attribute values shall be initialized: | |
| * - type -- initialized to the value of the type parameter. | | * - type -- initialized to the value of the type parameter. | |
| * - If type == @ref OVAL_FUNCTION_CONCAT | | * - If type == @ref OVAL_FUNCTION_CONCAT | |
| * - components -- initialized to empty iterator | | * - components -- initialized to empty iterator | |
|
| | | * - If type == @ref OVAL_FUNCTION_COUNT | |
| | | * - components -- initialized to empty iterator | |
| * - If type == @ref OVAL_FUNCTION_ESCAPE_REGEX | | * - If type == @ref OVAL_FUNCTION_ESCAPE_REGEX | |
| * - components -- initialized to empty iterator | | * - components -- initialized to empty iterator | |
| * - If type == @ref OVAL_FUNCTION_ARITHMETIC | | * - If type == @ref OVAL_FUNCTION_ARITHMETIC | |
| * - arithmetic_operation -- initialized to @ref OVAL_ARITHMETI
C_UNKNOWN | | * - arithmetic_operation -- initialized to @ref OVAL_ARITHMETI
C_UNKNOWN | |
| * - components -- initialized to empty iterator | | * - components -- initialized to empty iterator | |
| * - If type == @ref OVAL_FUNCTION_BEGIN | | * - If type == @ref OVAL_FUNCTION_BEGIN | |
| * - prefix -- initialized to NULL | | * - prefix -- initialized to NULL | |
| * - components -- initialized to empty iterator | | * - components -- initialized to empty iterator | |
| * - If type == @ref OVAL_FUNCTION_END | | * - If type == @ref OVAL_FUNCTION_END | |
| * - suffix -- initialized to NULL | | * - suffix -- initialized to NULL | |
| | | | |
End of changes. 6 change blocks. |
| 10 lines changed or deleted | | 26 lines changed or added | |
|
| oval_results.h | | oval_results.h | |
| | | | |
| skipping to change at line 556 | | skipping to change at line 556 | |
| | | | |
| /** | | /** | |
| * @name Evaluators | | * @name Evaluators | |
| * @{ | | * @{ | |
| */ | | */ | |
| /** @} */ | | /** @} */ | |
| | | | |
| /** | | /** | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
|
| struct oval_result_criteria_node *oval_result_criteria_node_new(struct oval | | struct oval_result_criteria_node *oval_result_criteria_node_new(struct oval | |
| _result_system *, oval_criteria_node_type_t, | | _result_system *, | |
| int, ...); | | oval_criteri | |
| | | a_node_type_t, | |
| | | int, int, .. | |
| | | .); | |
| /** | | /** | |
| * @return A copy of the specified @ref oval_result_criteria_node. | | * @return A copy of the specified @ref oval_result_criteria_node. | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
| struct oval_result_criteria_node *oval_result_criteria_node_clone | | struct oval_result_criteria_node *oval_result_criteria_node_clone | |
| (struct oval_result_system *new_system, struct oval_result_criteria_nod
e *old_node); | | (struct oval_result_system *new_system, struct oval_result_criteria_nod
e *old_node); | |
| /** | | /** | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
| void oval_result_criteria_node_free(struct oval_result_criteria_node *); | | void oval_result_criteria_node_free(struct oval_result_criteria_node *); | |
| | | | |
| skipping to change at line 584 | | skipping to change at line 585 | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
| void oval_result_criteria_node_set_result(struct oval_result_criteria_node
*, oval_result_t); | | void oval_result_criteria_node_set_result(struct oval_result_criteria_node
*, oval_result_t); | |
| /** | | /** | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
| void oval_result_criteria_node_set_negate(struct oval_result_criteria_node
*, bool); | | void oval_result_criteria_node_set_negate(struct oval_result_criteria_node
*, bool); | |
| /** | | /** | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
|
| | | void oval_result_criteria_node_set_applicability_check(struct oval_result_c | |
| | | riteria_node *, bool); | |
| | | /** | |
| | | * @memberof oval_result_criteria_node | |
| | | */ | |
| void oval_result_criteria_node_set_operator(struct oval_result_criteria_nod
e *, oval_operator_t); //type==NODETYPE_CRITERIA | | void oval_result_criteria_node_set_operator(struct oval_result_criteria_nod
e *, oval_operator_t); //type==NODETYPE_CRITERIA | |
| /** | | /** | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
| void oval_result_criteria_node_add_subnode(struct oval_result_criteria_node
*, struct oval_result_criteria_node *); //type==NODETYPE_CRITERIA | | void oval_result_criteria_node_add_subnode(struct oval_result_criteria_node
*, struct oval_result_criteria_node *); //type==NODETYPE_CRITERIA | |
| /** | | /** | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
| void oval_result_criteria_node_set_test(struct oval_result_criteria_node *,
struct oval_result_test *); //type==NODETYPE_CRITERION | | void oval_result_criteria_node_set_test(struct oval_result_criteria_node *,
struct oval_result_test *); //type==NODETYPE_CRITERION | |
| /** | | /** | |
| | | | |
| skipping to change at line 621 | | skipping to change at line 626 | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
| oval_result_t oval_result_criteria_node_get_result(struct oval_result_crite
ria_node *); | | oval_result_t oval_result_criteria_node_get_result(struct oval_result_crite
ria_node *); | |
| /** | | /** | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
| bool oval_result_criteria_node_get_negate(struct oval_result_criteria_node
*); | | bool oval_result_criteria_node_get_negate(struct oval_result_criteria_node
*); | |
| /** | | /** | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
|
| | | bool oval_result_criteria_node_get_applicability_check(struct oval_result_c | |
| | | riteria_node *); | |
| | | /** | |
| | | * @memberof oval_result_criteria_node | |
| | | */ | |
| oval_operator_t oval_result_criteria_node_get_operator(struct oval_result_c
riteria_node *); //type==NODETYPE_CRITERIA | | oval_operator_t oval_result_criteria_node_get_operator(struct oval_result_c
riteria_node *); //type==NODETYPE_CRITERIA | |
| /** | | /** | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
| struct oval_result_criteria_node_iterator *oval_result_criteria_node_get_su
bnodes(struct oval_result_criteria_node *); //type==NODETYPE_CRITERIA | | struct oval_result_criteria_node_iterator *oval_result_criteria_node_get_su
bnodes(struct oval_result_criteria_node *); //type==NODETYPE_CRITERIA | |
| /** | | /** | |
| * @memberof oval_result_criteria_node | | * @memberof oval_result_criteria_node | |
| */ | | */ | |
| struct oval_result_test *oval_result_criteria_node_get_test(struct oval_res
ult_criteria_node *); //type==NODETYPE_CRITERION | | struct oval_result_test *oval_result_criteria_node_get_test(struct oval_res
ult_criteria_node *); //type==NODETYPE_CRITERION | |
| /** | | /** | |
| | | | |
End of changes. 3 change blocks. |
| 3 lines changed or deleted | | 16 lines changed or added | |
|
| xccdf_policy.h | | xccdf_policy.h | |
| | | | |
| skipping to change at line 33 | | skipping to change at line 33 | |
| * @{ | | * @{ | |
| * @file xccdf_policy.h | | * @file xccdf_policy.h | |
| * Open-scap XCCDF Policy library interface. | | * Open-scap XCCDF Policy library interface. | |
| * @author Maros Barabas <mbarabas@redhat.com> | | * @author Maros Barabas <mbarabas@redhat.com> | |
| * @author Dave Niemoller <david.niemoller@g2-inc.com> | | * @author Dave Niemoller <david.niemoller@g2-inc.com> | |
| */ | | */ | |
| | | | |
| #ifndef XCCDF_POLICY_H_ | | #ifndef XCCDF_POLICY_H_ | |
| #define XCCDF_POLICY_H_ | | #define XCCDF_POLICY_H_ | |
| | | | |
|
| | | #include <xccdf_benchmark.h> | |
| #include <stdbool.h> | | #include <stdbool.h> | |
| #include <time.h> | | #include <time.h> | |
| #include <oscap.h> | | #include <oscap.h> | |
|
| #include <xccdf.h> | | | |
| #include <reporter.h> | | #include <reporter.h> | |
| | | | |
| /** | | /** | |
| * @struct xccdf_policy_model | | * @struct xccdf_policy_model | |
| * Handle all policies for given XCCDF benchmark | | * Handle all policies for given XCCDF benchmark | |
| */ | | */ | |
| struct xccdf_policy_model; | | struct xccdf_policy_model; | |
| | | | |
| /** | | /** | |
| * @struct xccdf_policy | | * @struct xccdf_policy | |
| | | | |
| skipping to change at line 66 | | skipping to change at line 66 | |
| | | | |
| struct xccdf_value_binding_iterator; | | struct xccdf_value_binding_iterator; | |
| | | | |
| /** | | /** | |
| * @struct xccdf_policy_iterator | | * @struct xccdf_policy_iterator | |
| * Iterate through policies | | * Iterate through policies | |
| * @see xccdf_policy_model_get_policies | | * @see xccdf_policy_model_get_policies | |
| */ | | */ | |
| struct xccdf_policy_iterator; | | struct xccdf_policy_iterator; | |
| | | | |
|
| | | /** | |
| | | * Type of a query over checking-engine data. | |
| | | * This allows xccdf_policy module to query checking engine and acquire com | |
| | | prehensive info. | |
| | | */ | |
| | | typedef enum { | |
| | | POLICY_ENGINE_QUERY_NAMES_FOR_HREF = 1, /// Considering xccd | |
| | | f:check-content-ref, what are possible @name attributes for given href? | |
| | | } xccdf_policy_engine_query_t; | |
| | | | |
| | | /** | |
| | | * Type of function which implements queries defined within xccdf_policy_en | |
| | | gine_query_t. | |
| | | * | |
| | | * Each checking engine may register its own function of the xccdf_policy_e | |
| | | ngine_query_fn | |
| | | * type. The registered function is then used by xccdf_policy module to acq | |
| | | uire 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. Th | |
| | | ird argument is | |
| | | * dependent on query and defined as follows: | |
| | | * - (const char *)href -- for POLICY_ENGINE_QUERY_NAMES_FOR_HREF | |
| | | * | |
| | | * Expected return type depends also on query as follows: | |
| | | * - (struct oscap_stringlists *) -- for POLICY_ENGINE_QUERY_NAMES_FOR_HRE | |
| | | F | |
| | | * - NULL shall be returned if the function doesn't understand the query. | |
| | | */ | |
| | | typedef void *(*xccdf_policy_engine_query_fn) (void *, xccdf_policy_engine_ | |
| | | query_t, void *); | |
| | | | |
| /************************************************************/ | | /************************************************************/ | |
| | | | |
| /** | | /** | |
| * Constructor of Policy Model structure | | * Constructor of Policy Model structure | |
| * @param benchmark Struct xccdf_benchmark with benchmark model | | * @param benchmark Struct xccdf_benchmark with benchmark model | |
| * @return new xccdf_policy_model | | * @return new xccdf_policy_model | |
| * @memberof xccdf_policy_model | | * @memberof xccdf_policy_model | |
| */ | | */ | |
| struct xccdf_policy_model *xccdf_policy_model_new(struct xccdf_benchmark *b
enchmark); | | struct xccdf_policy_model *xccdf_policy_model_new(struct xccdf_benchmark *b
enchmark); | |
| | | | |
| | | | |
| skipping to change at line 121 | | skipping to change at line 145 | |
| * @param model XCCDF Policy Model | | * @param model XCCDF Policy Model | |
| * @param sys String representing given checking system | | * @param sys String representing given checking system | |
| * @param func Callback - pointer to function called by XCCDF Policy system
when rule parsed | | * @param func Callback - pointer to function called by XCCDF Policy system
when rule parsed | |
| * @param usr optional parameter for passing user data to callback | | * @param usr optional parameter for passing user data to callback | |
| * @memberof xccdf_policy_model | | * @memberof xccdf_policy_model | |
| * @return true if callback registered succesfully, false otherwise | | * @return true if callback registered succesfully, false otherwise | |
| */ | | */ | |
| bool xccdf_policy_model_register_engine_callback(struct xccdf_policy_model
* model, char * sys, void * func, void * usr); | | bool xccdf_policy_model_register_engine_callback(struct xccdf_policy_model
* model, char * sys, void * func, void * usr); | |
| | | | |
| /** | | /** | |
|
| | | * Function to register callback for checking system | |
| | | * @param model XCCDF Policy Model | |
| | | * @param sys String representing given checking system | |
| | | * @param func Callback - pointer to function called by XCCDF Policy system | |
| | | when rule parsed | |
| | | * @param usr optional parameter for passing user data to callback | |
| | | * @param query_fn - optional parameter for providing xccdf_policy_engine_q | |
| | | uery_fn implementation for given system. | |
| | | * @memberof xccdf_policy_model | |
| | | * @return true if callback registered succesfully, false otherwise | |
| | | */ | |
| | | bool xccdf_policy_model_register_engine_and_query_callback(struct xccdf_pol | |
| | | icy_model *model, char *sys, void *eval_fn, void *usr, xccdf_policy_engine_ | |
| | | query_fn query_fn); | |
| | | | |
| | | /** | |
| * Function to register output callback for checking system that will be ca
lled AFTER each rule evaluation. | | * Function to register output callback for checking system that will be ca
lled AFTER each rule evaluation. | |
| * @param model XCCDF Policy Model | | * @param model XCCDF Policy Model | |
| * @param func Callback - pointer to function called by XCCDF Policy system
when rule parsed | | * @param func Callback - pointer to function called by XCCDF Policy system
when rule parsed | |
| * @param usr optional parameter for passing user data to callback | | * @param usr optional parameter for passing user data to callback | |
| * @memberof xccdf_policy_model | | * @memberof xccdf_policy_model | |
| * @return true if callback registered succesfully, false otherwise | | * @return true if callback registered succesfully, false otherwise | |
| * \par Example | | * \par Example | |
| * With the first function below (register output callback) user registers
the callback that will be called after | | * With the first function below (register output callback) user registers
the callback that will be called after | |
| * each rule evalution is done. Second callback is registered as callback f
or evaluation itself and will be called | | * each rule evalution is done. Second callback is registered as callback f
or evaluation itself and will be called | |
| * during the evaluation. | | * during the evaluation. | |
| | | | |
End of changes. 4 change blocks. |
| 1 lines changed or deleted | | 50 lines changed or added | |
|