-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Oscap source #5
Merged
Merged
Oscap source #5
Changes from all commits
Commits
Show all changes
318 commits
Select commit
Hold shift + click to select a range
604c953
Refactor: Rename function to oscap_xml_save_filename_free
isimluk 41ef893
Refactor: Extract function: oscap_xml_save_filename
isimluk 0d8e2ed
Build xmlTextReader from the existing DOM.
isimluk b45feaf
Do not pass NULL to strregcomp
isimluk 7eed220
Do not report the same error multiple times
isimluk a2ebd53
Do not report errno when xmlError is encountered
isimluk b6ae176
tests: Expect different output after xmlTextReader changes.
isimluk 178a3f1
Refactor: Extract function: oval_determine_document_schema_version_priv.
isimluk 7b31641
Do not try to open file again to determine oval version
isimluk 6cce6ae
Avoid using xmlTextReaderReadString function.
isimluk 269e699
OVAL Results export should use oscap_source_save_as.
isimluk ca4cbb8
Use oscap_source within _xccdf_session_export_oval_result_file
isimluk d709c25
Move oval_results_model_export_source to public API.
isimluk 207289f
Refactor: Extract function: lookup_xsi_ns.
isimluk d5fad88
Do not export namespaced property by xmlNewPror
isimluk b453009
Drop OVAL_XMLNS_XSI.
isimluk 8153bbd
Drop XCCDF_XSI_NAMESPACE.
isimluk 67c7ae6
tests: namespaces gets exported before the properties
isimluk 21615de
tests: XSI namespace is now exported only once
isimluk 6e0d98a
Store oval result sources to a map instead of disposing them
isimluk b7be92d
Do not free string when you need to allocate it again.
isimluk 4b19e3e
Make sure that oscap_source is added to the table.
isimluk e687c44
Refactor: Extract function: _build_oval_result_sources
isimluk d18f59a
Export all oval results at once, after sources are prepared.
isimluk 218fa4c
We cannot use realpath easily, we need to play guessing game
isimluk 5c38c17
Refactor: Extract function: xccdf_benchmark_export_source
isimluk 6948481
Use oscap_source to export XCCDF results from session.
isimluk a86b1b7
Validate XCCDF results using oscap_source
isimluk 4c3c5ef
Do not export namespaced property by xmlNewProp
isimluk 1768c91
Refactor: Extract function: _build_xccdf_result_source
isimluk d45edb0
Refactor: Extract function: lookup_xccdf_ns
isimluk 7cc9762
Make sure to create xccdf namespace if that is missing.
isimluk 62c043a
Make sure that xccdf:item gets always created with namespace
isimluk 207fc99
Do not set namespace to Benchmark element. It already has one assigned.
isimluk 99b5c8b
Refactor: Declutter code and make it more compact and readable
isimluk 3b51bc9
Do not recreate xccdf namespace, just look it up.
isimluk 43e330e
Refactor: pass version_info downto xccdf_fix_to_dom()
isimluk b91cf44
Export <fix> element to the XCCDF namespace
isimluk ca655fc
Export <metadata> to XCCDF namespace
isimluk dabae51
Build oscap_source for main file of xccdf_session.
isimluk 8ac1532
Use oscap_source to query scap_type of session document.
isimluk 7008e82
Use already parsed sds for validation.
isimluk dcd2847
Introduce new structure ds_sds_registry.
isimluk 9d2d016
Refactor: Promote ds_sds_index_parse to privileged
isimluk 620baf8
xmlTextReader should not be cached by oscap_source
isimluk 1d8c6a1
Refactor: Drop _build_new_xmlTextReader function.
isimluk d7743f8
Introduce ds_sds_registry_get_sds_idx
isimluk f8671bc
ds_sds_registry should better not own the oscap_source.
isimluk 091612d
Make sure the sds_idx is available.
isimluk 3306b58
Start using ds_sds_registry to query sds_index
isimluk 1e6fbfe
Never try to export a file twice.
isimluk 029d4f1
Refactor: Extract function: ds_sds_dump_component_sce.
isimluk 22acadc
Refactor: Extract function: ds_doc_from_foreign_node
isimluk 06b495f
Refactor: Rename structure: sds_registry --> sds_session
isimluk d969b35
temp_directory will be property of ds_sds_session
isimluk 00af002
Refactor: Rename function: xccdf_session_get_ds_sds_session
isimluk 0816b31
Refactor: Checklist selection is responsibility of ds_sds_session.
isimluk 2ec0a5e
Refactor: Extract function: _containter_get_component_ref_by_id
isimluk 1aef1a5
Wrap DOM within ds_sds_decompose_custom by oscap_source.
isimluk 96ada41
Yell an error message when a datastream session could not be created.
isimluk 2e3f5aa
Wrap oscap_source within ds_sds_decompose_custom by sds_session.
isimluk 62269a3
Introduce function: ds_sds_session_set_datastream_id
isimluk 7f6223f
Refactor: Extract function: ds_sds_session_get_selected_datastream
isimluk 84d2730
Introduce function: ds_sds_session_get_xmlDoc
isimluk 9844a1d
Pass only sds_session to ds_sds_dump_component_ref.
isimluk 73d95d2
Pass only sds_session to ds_sds_dump_component_ref_as
isimluk 00fef9e
Reuse existing code in ds_sds_find_component_ref.
isimluk bd803d3
Pass sds_session downto ds_sds_dump_componen
isimluk 363f70e
Introduce function: ds_sds_session_register_component_source
isimluk c41eb36
Refactor: Promote _guess_real_path to oscap_acquire module.
isimluk 8d942e1
Register parsed components with sds_session.
isimluk 018d922
Introduce function: ds_sds_session_dump_component_files.
isimluk c9bbb08
Serialize all files from sds split at once
isimluk 818971a
Override return code of oscap_xml_save_filename
isimluk 8d5cdb9
Tests: Files are now exported with encoding="UTF-8".
isimluk 2aa9406
Introduce target_dir as a property of ds_sds_session.
isimluk 4c0012c
Remove oscap_debug.log.* from split directory
isimluk 3fc445c
Set target_dir to sds_session before split.
isimluk 60cff1c
Do not pass target_dir to ds_sds_find_component_ref.
isimluk bb1c505
Postpone the creation of target dir.
isimluk c1822d1
Refactor: Promote: containter_get_component_ref_by_id to privileged.,
isimluk c5f5184
Refactor: Promote: ds_sds_dump_component_ref* to privileged.
isimluk aa069c5
Refactor: Extract function: ds_sds_session_register_component_with_de…
isimluk d52e405
Start building oscap_source for XCCDF file within session.
isimluk 2009a23
Refactor: Extract function: xccdf_detect_version_priv.
isimluk 60b17b9
Use existing DOM to detect version of XCCDF file.
isimluk 6d82553
Use oscap_source to validate XCCDF document within session.
isimluk 7e8c306
Drop XCCDF version from XCCDF Session
isimluk b6779fc
Refactor: Extract function: xccdf_benchmark_import_source
isimluk 6fe0405
Use oscap_source to parse XCCDF content within session.
isimluk 43f2ada
Avoid using xmlTextReaderReadString function.
isimluk 01c1a8c
Pass NS to the node upon creation.
isimluk 44d8435
Firsly created XCCDF namespace shall be assigned with Benchmark node.
isimluk 6b5e990
Do not pass oval_context to oval_parser_text_value
isimluk c0ef76d
Promote oval_xml_value_consumer to commons
isimluk 8cbbcec
Promote oval_parser_text_value to commons
isimluk 85ac446
Promote oscap_text_consumer to commons
isimluk 907feb1
Allows for elements like: <plain-text id='empty'/>
isimluk d9507df
ds_sds_session_select_checklist should return XCCDF source.
isimluk af6dccb
Start using XCCDF source from DataStream.
isimluk a690fea
Plug a memory leak.
isimluk d95bf99
Plug a memory leak
isimluk 7b966da
Avoid using session->xccdf.source
isimluk 40f559c
Drop session->xccdf.file property.
isimluk f0e8642
Drop XCCDF_XML literal constant
isimluk 5f3caf7
Do not set target_directory for sds_session.
isimluk 4f9fb12
Refactor: replace variable with function call.
isimluk 2942b14
Refactor: Drop datastream_id property from xccdf_session.
isimluk b2dcd7c
Refactor: Drop component_id property from xccdf_session.
isimluk a1fa918
Introduce function: ds_sds_session_get_component_by_href
isimluk fdee1ed
Prepare already parsed oscap_sources to oval_content_resource list.
isimluk 4504db8
Return NULL on error
isimluk 6e6aeda
Fix sorting in error message arguments.
isimluk e27d487
Use existing oscap_source for validation.
isimluk ec16e2b
oval_content_resource should always point to an oscap_source.
isimluk 2295a40
Remove a dead code
isimluk fe31e40
Re-use existing oscap_source for each OVAL file.
isimluk 098b984
Drop filename property from oval_content_resource.
isimluk b8c5a30
Stop storing component files on disk.
isimluk a5f7f8a
Introduce: ds_sds_session_select_tailoring
isimluk 70ef745
Use oscap_source to validate tailoring file.
isimluk 441f29b
Remove unneeded code.
isimluk b2e1ae9
Use oscap_source to parse tailoring file.
isimluk b2cc713
Refactor: Extract function: xccdf_tailoring_import_source
isimluk c0b4724
Use oscap_source to import tailoring from session.
isimluk 82dee34
Deprecate: xccdf_tailoring_import.
isimluk d9c5d2a
Do not store tailoring component on disk.
isimluk 4be3b4c
Move CPE dicts from policy to a new child structure.
isimluk 1e2c9fe
Move CPE lang_models from policy to a child structure.
isimluk 6ba38c9
Move CPE oval_sessions from policy to a child structure.
isimluk fc4b068
Move CPE applicable_platforms from policy to child structure.
isimluk 7030e94
Refactor: Extract structure: cpe_session
isimluk 7909824
Use oscap_source to validate embedded CPE.
isimluk 96dd251
Use oscap_source when determining version of OVAL document.
isimluk e45beed
Use oscap_source to validate OVAL results within datastream
isimluk 1878fa8
Promote oscap_source_get_schema_version to public API.
isimluk fb072e0
Deprecate: oval_determine_document_schema_version.
isimluk fb36d8c
Refactor: Extract function: cpe_dict_detect_version_priv.
isimluk dd6906e
CPE version should be received using existing textReader.
isimluk 21f4ec6
Use oscap_source when determining version of CPE dict
isimluk a79a21d
Use oscap_source to validate CPE file from user.
isimluk 2667b94
Use oscap_source to validate cpe documents from command-line
isimluk 9271ec1
Deprecate: cpe_dict_detect_version
isimluk b1ced95
Refactor: Extract function: cpe_lang_model_detect_version_priv
isimluk 86a7de6
Do not pass filepath to cpe_lang_model_detect_version.
isimluk 3e71b4f
Use oscap_source to determine XCCDF version within info module.
isimluk 9b3599a
Use oscap_source to validate input testresult.
isimluk b72642b
Use oscap_source to validate resolved XCCDF.
isimluk b5a4e2f
Use oscap_source to validate input of xccdf resolve.
isimluk 1d6089b
Use oscap_source to validate input XCCDF for evaluation.
isimluk 3b7895e
Deprecate: xccdf_detect_version.
isimluk aadf079
Avoid use of ds_sds_decompose_custom
isimluk 5a36f71
oscap_source_get_scap_type shall recognize TestResult.
isimluk d0cbc1e
Make cpe an allocated property.
isimluk bb4de0b
Refactor: Extract funciton: cpe_session_new
isimluk 57898f9
Refactor: Extract function: cpe_session_free.
isimluk 0275be1
Refactor: Extract function: cpe_session_lookup_oval_session.
isimluk bd3d5e7
Use oscap_source to parse cpe_lang_model.
isimluk a0649dc
Refactor: Extract function: cpe_lang_model_import_source.
isimluk a578925
Drop cpe_lang_model_parse_xml.
isimluk fdf4aca
Introduce: cpe_session_add_cpe_lang_model_source.
isimluk ab8c7fc
Always use oscap_source to import cpe_lang.
isimluk 6ac3b58
Deprecate: cpe_lang_model_import.
isimluk 5aa332c
Use oscap_source for parsing cpe_dict.
isimluk 3271b6a
Drop cpe_parser_ctx_new.
isimluk e7924dc
Refactor: Extract function: cpe_dict_model_import_source.
isimluk 73d107f
Drop cpe_dict_model_parse_xml
isimluk e484014
Introduce: cpe_session_add_cpe_dict_source.
isimluk 928fe85
Always use oscap_source to import cpe_dict.
isimluk 3cc5a93
Refactor: Extract function: cpe_session_add_cpe_autodetect_source.
isimluk 112ed1c
Move default_cpe initializator to cpe_session.
isimluk 7867870
Introduce xccdf_policy_model_get_cpe_session.
isimluk 2f15296
Introduce: ds_sds_session_get_component_sources.
isimluk 803e310
CPE sesion may take external cache of oscap_sources
isimluk 507503f
Use ds_sds_session to cache oscap_source for OVAL CPE.
isimluk ea78bf3
Do not dispose an item that is not owned
isimluk f853232
Remove duplicate definitions.
isimluk 5532fbc
Do not dump CPE files from DataStream on the disc.
isimluk 691ebab
Do not open XCCDF and CPE again when we already have them parsed.
isimluk 63860ec
Build ds_sds_session when querying DataStream for info
isimluk fbd8d4a
Use ds_sds_session to build ds_sds_index.
isimluk 9b6118c
No need to set-up temp_dir when loading XCCDF.
isimluk 1ab068b
Avoid using xccdf_benchmark_import.
isimluk 6aa4b58
Deprecate xccdf_benchmark_import
isimluk 1b10b21
Import XCCDF file from the DataStream DOM.
isimluk 7eb17f2
Drop oscap_acquire_cleanup_dir_bundled.
isimluk 944fcb1
Promote oscap_source_readable_origin to public API.
isimluk 1ae4a64
Avoid use of oscap_determine_document_type.
isimluk 7b0bead
Deprecate oscap_determine_document_type.
isimluk 352ab16
Promote ds_sds_session_set_datastream_id to public API.
isimluk 21ab30f
Use ds_sds_session to extract OVAL file from DataStream.
isimluk 484d051
Promote ds_sds_session_get_component_by_href to public API.
isimluk 7ec2769
Promote ds_sds_session_register_component_with_dependencies to public…
isimluk 7a5d19d
Drop oscap_acquire_temp_dir_bundled.
isimluk f916d21
Avoid use of oscap_validate_document within oscap-ds.
isimluk 63603be
Avoid use of oscap_validate_document within oscap-cve.
isimluk 3408f5a
Drop validation_failed.
isimluk 0c0f8ce
Promote ds_sds_session_dump_component_files to public API.
isimluk 4fbb899
Promote ds_sds_session_set_target_dir to public API.
isimluk c34c364
Avoid use of oscap_validate_document from xccdf_session.
isimluk bfa2c60
Do not forget to take break
isimluk 1916a78
Deprecate: oscap_validate_document.
isimluk 44ddd8b
Error shall go to stderr.
isimluk 74a657c
Show errno to the user.
isimluk b94e994
Refactor: Extract function: _gcwd.
isimluk b8c400c
Use ds_sds_session within oscap ds sds-split.
isimluk 83d7eca
Introduce function: ds_sds_session_reset.
isimluk 627a3ac
Reset sds_session after each checklist selection
isimluk d410230
Deprecate: ds_sds_decompose.
isimluk 8c6be6f
Deprecate: ds_sds_decompose_custom.
isimluk c252bc0
Deprecate: ds_sds_index_import
isimluk f72678c
Avoid use of xmlReaderForFile
isimluk 47eb5bf
Drop libxml_error_handler.
isimluk f0ec4ab
tests: Introduce test for a codestyle
isimluk 8741172
Avoid using xmlTextReaderReadString function.
isimluk 72672ae
Tests: Forbid use of xmlTextReaderReadString.
isimluk 0e15c4e
Avoid use of cpe_dict_model_import
isimluk 2bbafb6
Refactor: rename variable.
isimluk 187bfd1
ds_sds_session switches from absolute paths to relative
isimluk 64b6b23
Deprecate: cpe_dict_model_import.
isimluk b9dd12c
Promote oscap_path_to_xslt to privileged.
isimluk 26af338
Avoid using oscap_apply_xslt.
isimluk da346a8
Use exported XCCDF dom to generate HTML report.
isimluk 8ff5f4f
Refactor: Extract function ds_sds_compose_component_add_script_content
isimluk cbaa2c7
session->xccdf.source should never be owned directly.
isimluk eeaba3d
Drop xccdf_session->filename.
isimluk 5daef09
Avoid direct use of xmlReadFile.
isimluk afa6810
Do not attempt to open SCE script to DOM
isimluk 75ae103
Refactor: Merge two subsequent conditions together
isimluk 906bf34
Avoid direct use of xmlReadFile
isimluk aee3ec3
Avoid direct use of xmlReadFile
isimluk 1bf9168
Re-use existing oscap_source to add component with dependencies.
isimluk 46f44f1
Avoid direct use of xmlReadFile
isimluk 80af854
Avoid direct use of xmlReadFile
isimluk 0d850d3
Avoid direct use of xmlReadFile.
isimluk 994b686
tests: Check codestyle only in C,C++ sources and header files.
isimluk 1c6a2ea
tests: Forbid direct use of xmlReadFile within OpenSCAP project
isimluk 235845f
Refactor: Extract function: ds_rds_create_source.
isimluk 00165b4
Avoid direct use of xmlSaveFileEnc.
isimluk c7b718b
Use exported source to validate ARF DOM directly.
isimluk 4d7902d
Drop xccdf_session->oval.result_files.
isimluk 7d908c1
Export XCCDF TestResult only when explicitly requested.
isimluk 2a0cbc8
Avoid direct use of xmlSaveFileEnc.
isimluk 54a2d4b
Merge branch 'master' into oscap_source
isimluk a54d84a
Make sure that error message is generic enough.
isimluk d545da9
Fix a typo.
isimluk 769ea3e
Improve documentation of oscap_source and ds_sds_session.
isimluk 5318d21
Remove TODO that no longer applies
isimluk 593c2ad
Rename private constant to better reflect its use.
isimluk 4437034
tests: Assume.h is not needed to test codestyle.
isimluk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/* | ||
* Copyright 2014 Red Hat Inc., Durham, North Carolina. | ||
* All Rights Reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* 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, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
* Author: | ||
* Šimon Lukašík | ||
*/ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include <config.h> | ||
#endif | ||
|
||
#include "common/alloc.h" | ||
#include "common/_error.h" | ||
#include "common/list.h" | ||
#include "common/public/oscap.h" | ||
#include "common/util.h" | ||
#include "cpe_session_priv.h" | ||
#include "CPE/public/cpe_dict.h" | ||
#include "CPE/public/cpe_lang.h" | ||
#include "OVAL/public/oval_agent_api.h" | ||
#include "source/public/oscap_source.h" | ||
#include "source/oscap_source_priv.h" | ||
|
||
static inline bool cpe_session_add_default_cpe(struct cpe_session *session) | ||
{ | ||
char* cpe_dict_path = oscap_sprintf("%s/openscap-cpe-dict.xml", oscap_path_to_cpe()); | ||
struct oscap_source *source = oscap_source_new_from_file(cpe_dict_path); | ||
oscap_free(cpe_dict_path); | ||
const bool ret = cpe_session_add_cpe_dict_source(session, source); | ||
oscap_source_free(source); | ||
return ret; | ||
} | ||
|
||
struct cpe_session *cpe_session_new(void) | ||
{ | ||
struct cpe_session *cpe = oscap_calloc(1, sizeof(struct cpe_session)); | ||
cpe->dicts = oscap_list_new(); | ||
cpe->lang_models = oscap_list_new(); | ||
cpe->oval_sessions = oscap_htable_new(); | ||
cpe->applicable_platforms = oscap_htable_new(); | ||
if (!cpe_session_add_default_cpe(cpe)) { | ||
oscap_seterr(OSCAP_EFAMILY_XCCDF, "Failed to add default CPE to newly created CPE Session."); | ||
} | ||
return cpe; | ||
} | ||
|
||
static inline void _xccdf_policy_destroy_cpe_oval_session(void* ptr) | ||
{ | ||
struct oval_agent_session* session = (struct oval_agent_session*)ptr; | ||
struct oval_definition_model* model = oval_agent_get_definition_model(session); | ||
oval_agent_destroy_session(session); | ||
oval_definition_model_free(model); | ||
} | ||
|
||
void cpe_session_free(struct cpe_session *session) | ||
{ | ||
if (session != NULL) { | ||
oscap_list_free(session->dicts, (oscap_destruct_func) cpe_dict_model_free); | ||
oscap_list_free(session->lang_models, (oscap_destruct_func) cpe_lang_model_free); | ||
oscap_htable_free(session->oval_sessions, (oscap_destruct_func) _xccdf_policy_destroy_cpe_oval_session); | ||
oscap_htable_free(session->applicable_platforms, NULL); | ||
oscap_free(session); | ||
} | ||
} | ||
|
||
static inline struct oscap_source *_lookup_source_in_cache(struct cpe_session *session, const char *prefixed_href) | ||
{ | ||
if (session->sources_cache == NULL) { | ||
return NULL; | ||
} | ||
struct oscap_source *source = oscap_htable_get(session->sources_cache, prefixed_href); | ||
return source; | ||
} | ||
|
||
struct oval_agent_session *cpe_session_lookup_oval_session(struct cpe_session *cpe, const char *prefixed_href) | ||
{ | ||
struct oval_agent_session* session = (struct oval_agent_session*)oscap_htable_get(cpe->oval_sessions, prefixed_href); | ||
|
||
if (session == NULL) | ||
{ | ||
struct oscap_source *source = NULL; | ||
struct oscap_source *cached = _lookup_source_in_cache(cpe, prefixed_href); | ||
if (cached == NULL) { | ||
source = oscap_source_new_from_file(prefixed_href); | ||
cached = source; | ||
} | ||
struct oval_definition_model* oval_model = oval_definition_model_import_source(cached); | ||
oscap_source_free(source); | ||
|
||
if (oval_model == NULL) | ||
{ | ||
oscap_seterr(OSCAP_EFAMILY_OSCAP, "Can't import OVAL definition model '%s' for CPE applicability checking", prefixed_href); | ||
return NULL; | ||
} | ||
|
||
session = oval_agent_new_session(oval_model, prefixed_href); | ||
if (session == NULL) { | ||
oscap_seterr(OSCAP_EFAMILY_OSCAP, "Cannot create OVAL session for '%s' for CPE applicability checking", prefixed_href); | ||
return NULL; | ||
} | ||
oscap_htable_add(cpe->oval_sessions, prefixed_href, session); | ||
} | ||
return session; | ||
} | ||
|
||
bool cpe_session_add_cpe_lang_model_source(struct cpe_session *session, struct oscap_source *source) | ||
{ | ||
struct cpe_lang_model *lang_model = cpe_lang_model_import_source(source); | ||
return oscap_list_add(session->lang_models, lang_model); | ||
} | ||
|
||
bool cpe_session_add_cpe_dict_source(struct cpe_session *session, struct oscap_source *source) | ||
{ | ||
struct cpe_dict_model *dict = cpe_dict_model_import_source(source); | ||
return oscap_list_add(session->dicts, dict); | ||
} | ||
|
||
bool cpe_session_add_cpe_autodetect_source(struct cpe_session *session, struct oscap_source *source) | ||
{ | ||
oscap_document_type_t doc_type = oscap_source_get_scap_type(source); | ||
if (doc_type == OSCAP_DOCUMENT_CPE_DICTIONARY) { | ||
return cpe_session_add_cpe_dict_source(session, source); | ||
} else if (doc_type == OSCAP_DOCUMENT_CPE_LANGUAGE) { | ||
return cpe_session_add_cpe_lang_model_source(session, source); | ||
} else { | ||
oscap_seterr(OSCAP_EFAMILY_OSCAP, "File '%s' wasn't detected as either CPE dictionary or " | ||
"CPE lang model. Can't register it to the XCCDF policy model.", oscap_source_readable_origin(source)); | ||
return false; | ||
} | ||
} | ||
|
||
void cpe_session_set_cache(struct cpe_session *session, struct oscap_htable *sources_cache) | ||
{ | ||
session->sources_cache = sources_cache; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright 2014 Red Hat Inc., Durham, North Carolina. | ||
* All Rights Reserved. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* 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, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
* | ||
*/ | ||
#ifndef OSCAP_CPE_CPE_SESSION_PRIV_H | ||
#define OSCAP_CPE_CPE_SESSION_PRIV_H | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include <config.h> | ||
#endif | ||
|
||
#include "common/list.h" | ||
#include "common/public/oscap.h" | ||
#include "common/util.h" | ||
#include "OVAL/public/oval_agent_api.h" | ||
|
||
OSCAP_HIDDEN_START; | ||
|
||
struct cpe_session { | ||
struct oscap_list *dicts; ///< All CPE dictionaries except the one embedded in XCCDF | ||
struct oscap_list *lang_models; ///< All CPE lang models except the one embedded in XCCDF | ||
struct oscap_htable *oval_sessions; ///< Caches CPE OVAL check results | ||
struct oscap_htable *applicable_platforms; | ||
struct oscap_htable *sources_cache; ///< Not owned cache [path -> oscap_source] | ||
}; | ||
|
||
struct cpe_session *cpe_session_new(void); | ||
void cpe_session_free(struct cpe_session *session); | ||
struct oval_agent_session *cpe_session_lookup_oval_session(struct cpe_session *cpe, const char *prefixed_href); | ||
bool cpe_session_add_cpe_lang_model_source(struct cpe_session *session, struct oscap_source *source); | ||
bool cpe_session_add_cpe_dict_source(struct cpe_session *session, struct oscap_source *source); | ||
bool cpe_session_add_cpe_autodetect_source(struct cpe_session *session, struct oscap_source *source); | ||
void cpe_session_set_cache(struct cpe_session *session, struct oscap_htable *sources_cache); | ||
|
||
OSCAP_HIDDEN_END; | ||
#endif |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be a single dash?
(feel free to ignore me -- i'm just reading the PRs to better learn/understand how the openscap code works)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Shawn! OpenSCAP uses these en-dash (--) signs to separate date ranges pretty consistently. I would consider it bug, If you found a date range in OpenSCAP that uses hyphen. The very same date rages you can see in other projects (i.e. Spacewalk) too. The reason behind is the advice from Donald Knuth, the TeX hero ( http://web.mit.edu/jgross/www/LaTeX/texbook.pdf ).
We try hard to make Donald Knuth