Skip to content
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 318 commits into from
Oct 1, 2014
Merged
Show file tree
Hide file tree
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 Sep 3, 2014
41ef893
Refactor: Extract function: oscap_xml_save_filename
isimluk Sep 3, 2014
0d8e2ed
Build xmlTextReader from the existing DOM.
isimluk Sep 5, 2014
b45feaf
Do not pass NULL to strregcomp
isimluk Sep 5, 2014
7eed220
Do not report the same error multiple times
isimluk Sep 5, 2014
a2ebd53
Do not report errno when xmlError is encountered
isimluk Sep 5, 2014
b6ae176
tests: Expect different output after xmlTextReader changes.
isimluk Sep 5, 2014
178a3f1
Refactor: Extract function: oval_determine_document_schema_version_priv.
isimluk Sep 5, 2014
7b31641
Do not try to open file again to determine oval version
isimluk Sep 5, 2014
6cce6ae
Avoid using xmlTextReaderReadString function.
isimluk Sep 5, 2014
269e699
OVAL Results export should use oscap_source_save_as.
isimluk Sep 3, 2014
ca4cbb8
Use oscap_source within _xccdf_session_export_oval_result_file
isimluk Sep 3, 2014
d709c25
Move oval_results_model_export_source to public API.
isimluk Sep 5, 2014
207289f
Refactor: Extract function: lookup_xsi_ns.
isimluk Sep 5, 2014
d5fad88
Do not export namespaced property by xmlNewPror
isimluk Sep 5, 2014
b453009
Drop OVAL_XMLNS_XSI.
isimluk Sep 5, 2014
8153bbd
Drop XCCDF_XSI_NAMESPACE.
isimluk Sep 5, 2014
67c7ae6
tests: namespaces gets exported before the properties
isimluk Sep 5, 2014
21615de
tests: XSI namespace is now exported only once
isimluk Sep 5, 2014
6e0d98a
Store oval result sources to a map instead of disposing them
isimluk Sep 6, 2014
b7be92d
Do not free string when you need to allocate it again.
isimluk Sep 6, 2014
4b19e3e
Make sure that oscap_source is added to the table.
isimluk Sep 6, 2014
e687c44
Refactor: Extract function: _build_oval_result_sources
isimluk Sep 6, 2014
d18f59a
Export all oval results at once, after sources are prepared.
isimluk Sep 6, 2014
218fa4c
We cannot use realpath easily, we need to play guessing game
isimluk Sep 8, 2014
5c38c17
Refactor: Extract function: xccdf_benchmark_export_source
isimluk Sep 9, 2014
6948481
Use oscap_source to export XCCDF results from session.
isimluk Sep 9, 2014
a86b1b7
Validate XCCDF results using oscap_source
isimluk Sep 9, 2014
4c3c5ef
Do not export namespaced property by xmlNewProp
isimluk Sep 9, 2014
1768c91
Refactor: Extract function: _build_xccdf_result_source
isimluk Sep 9, 2014
d45edb0
Refactor: Extract function: lookup_xccdf_ns
isimluk Sep 9, 2014
7cc9762
Make sure to create xccdf namespace if that is missing.
isimluk Sep 9, 2014
62c043a
Make sure that xccdf:item gets always created with namespace
isimluk Sep 9, 2014
207fc99
Do not set namespace to Benchmark element. It already has one assigned.
isimluk Sep 9, 2014
99b5c8b
Refactor: Declutter code and make it more compact and readable
isimluk Sep 9, 2014
3b51bc9
Do not recreate xccdf namespace, just look it up.
isimluk Sep 9, 2014
43e330e
Refactor: pass version_info downto xccdf_fix_to_dom()
isimluk Sep 10, 2014
b91cf44
Export <fix> element to the XCCDF namespace
isimluk Sep 10, 2014
ca655fc
Export <metadata> to XCCDF namespace
isimluk Sep 10, 2014
dabae51
Build oscap_source for main file of xccdf_session.
isimluk Sep 10, 2014
8ac1532
Use oscap_source to query scap_type of session document.
isimluk Sep 10, 2014
7008e82
Use already parsed sds for validation.
isimluk Sep 10, 2014
dcd2847
Introduce new structure ds_sds_registry.
isimluk Sep 2, 2014
9d2d016
Refactor: Promote ds_sds_index_parse to privileged
isimluk Sep 10, 2014
620baf8
xmlTextReader should not be cached by oscap_source
isimluk Sep 10, 2014
1d8c6a1
Refactor: Drop _build_new_xmlTextReader function.
isimluk Sep 10, 2014
d7743f8
Introduce ds_sds_registry_get_sds_idx
isimluk Sep 10, 2014
f8671bc
ds_sds_registry should better not own the oscap_source.
isimluk Sep 10, 2014
091612d
Make sure the sds_idx is available.
isimluk Sep 10, 2014
3306b58
Start using ds_sds_registry to query sds_index
isimluk Sep 10, 2014
1e6fbfe
Never try to export a file twice.
isimluk Sep 10, 2014
029d4f1
Refactor: Extract function: ds_sds_dump_component_sce.
isimluk Sep 10, 2014
22acadc
Refactor: Extract function: ds_doc_from_foreign_node
isimluk Sep 11, 2014
06b495f
Refactor: Rename structure: sds_registry --> sds_session
isimluk Sep 11, 2014
d969b35
temp_directory will be property of ds_sds_session
isimluk Sep 15, 2014
00af002
Refactor: Rename function: xccdf_session_get_ds_sds_session
isimluk Sep 16, 2014
0816b31
Refactor: Checklist selection is responsibility of ds_sds_session.
isimluk Sep 15, 2014
2ec0a5e
Refactor: Extract function: _containter_get_component_ref_by_id
isimluk Sep 16, 2014
1aef1a5
Wrap DOM within ds_sds_decompose_custom by oscap_source.
isimluk Sep 16, 2014
96ada41
Yell an error message when a datastream session could not be created.
isimluk Sep 16, 2014
2e3f5aa
Wrap oscap_source within ds_sds_decompose_custom by sds_session.
isimluk Sep 16, 2014
62269a3
Introduce function: ds_sds_session_set_datastream_id
isimluk Sep 16, 2014
7f6223f
Refactor: Extract function: ds_sds_session_get_selected_datastream
isimluk Sep 16, 2014
84d2730
Introduce function: ds_sds_session_get_xmlDoc
isimluk Sep 16, 2014
9844a1d
Pass only sds_session to ds_sds_dump_component_ref.
isimluk Sep 16, 2014
73d95d2
Pass only sds_session to ds_sds_dump_component_ref_as
isimluk Sep 16, 2014
00fef9e
Reuse existing code in ds_sds_find_component_ref.
isimluk Sep 16, 2014
bd803d3
Pass sds_session downto ds_sds_dump_componen
isimluk Sep 16, 2014
363f70e
Introduce function: ds_sds_session_register_component_source
isimluk Sep 16, 2014
c41eb36
Refactor: Promote _guess_real_path to oscap_acquire module.
isimluk Sep 16, 2014
8d942e1
Register parsed components with sds_session.
isimluk Sep 16, 2014
018d922
Introduce function: ds_sds_session_dump_component_files.
isimluk Sep 16, 2014
c9bbb08
Serialize all files from sds split at once
isimluk Sep 18, 2014
818971a
Override return code of oscap_xml_save_filename
isimluk Sep 18, 2014
8d5cdb9
Tests: Files are now exported with encoding="UTF-8".
isimluk Sep 18, 2014
2aa9406
Introduce target_dir as a property of ds_sds_session.
isimluk Sep 18, 2014
4c0012c
Remove oscap_debug.log.* from split directory
isimluk Sep 18, 2014
3fc445c
Set target_dir to sds_session before split.
isimluk Sep 18, 2014
60cff1c
Do not pass target_dir to ds_sds_find_component_ref.
isimluk Sep 18, 2014
bb1c505
Postpone the creation of target dir.
isimluk Sep 18, 2014
c1822d1
Refactor: Promote: containter_get_component_ref_by_id to privileged.,
isimluk Sep 18, 2014
c5f5184
Refactor: Promote: ds_sds_dump_component_ref* to privileged.
isimluk Sep 18, 2014
aa069c5
Refactor: Extract function: ds_sds_session_register_component_with_de…
isimluk Sep 18, 2014
d52e405
Start building oscap_source for XCCDF file within session.
isimluk Sep 18, 2014
2009a23
Refactor: Extract function: xccdf_detect_version_priv.
isimluk Sep 18, 2014
60b17b9
Use existing DOM to detect version of XCCDF file.
isimluk Sep 18, 2014
6d82553
Use oscap_source to validate XCCDF document within session.
isimluk Sep 18, 2014
7e8c306
Drop XCCDF version from XCCDF Session
isimluk Sep 18, 2014
b6779fc
Refactor: Extract function: xccdf_benchmark_import_source
isimluk Sep 18, 2014
6fe0405
Use oscap_source to parse XCCDF content within session.
isimluk Sep 18, 2014
43f2ada
Avoid using xmlTextReaderReadString function.
isimluk Sep 18, 2014
01c1a8c
Pass NS to the node upon creation.
isimluk Sep 18, 2014
44d8435
Firsly created XCCDF namespace shall be assigned with Benchmark node.
isimluk Sep 18, 2014
6b5e990
Do not pass oval_context to oval_parser_text_value
isimluk Sep 18, 2014
c0ef76d
Promote oval_xml_value_consumer to commons
isimluk Sep 18, 2014
8cbbcec
Promote oval_parser_text_value to commons
isimluk Sep 18, 2014
85ac446
Promote oscap_text_consumer to commons
isimluk Sep 18, 2014
907feb1
Allows for elements like: <plain-text id='empty'/>
isimluk Sep 18, 2014
d9507df
ds_sds_session_select_checklist should return XCCDF source.
isimluk Sep 18, 2014
af6dccb
Start using XCCDF source from DataStream.
isimluk Sep 18, 2014
a690fea
Plug a memory leak.
isimluk Sep 18, 2014
d95bf99
Plug a memory leak
isimluk Sep 18, 2014
7b966da
Avoid using session->xccdf.source
isimluk Sep 18, 2014
40f559c
Drop session->xccdf.file property.
isimluk Sep 18, 2014
f0e8642
Drop XCCDF_XML literal constant
isimluk Sep 18, 2014
5f3caf7
Do not set target_directory for sds_session.
isimluk Sep 18, 2014
4f9fb12
Refactor: replace variable with function call.
isimluk Sep 19, 2014
2942b14
Refactor: Drop datastream_id property from xccdf_session.
isimluk Sep 19, 2014
b2dcd7c
Refactor: Drop component_id property from xccdf_session.
isimluk Sep 19, 2014
a1fa918
Introduce function: ds_sds_session_get_component_by_href
isimluk Sep 19, 2014
fdee1ed
Prepare already parsed oscap_sources to oval_content_resource list.
isimluk Sep 19, 2014
4504db8
Return NULL on error
isimluk Sep 19, 2014
6e6aeda
Fix sorting in error message arguments.
isimluk Sep 19, 2014
e27d487
Use existing oscap_source for validation.
isimluk Sep 19, 2014
ec16e2b
oval_content_resource should always point to an oscap_source.
isimluk Sep 19, 2014
2295a40
Remove a dead code
isimluk Sep 19, 2014
fe31e40
Re-use existing oscap_source for each OVAL file.
isimluk Sep 19, 2014
098b984
Drop filename property from oval_content_resource.
isimluk Sep 19, 2014
b8c5a30
Stop storing component files on disk.
isimluk Sep 19, 2014
a5f7f8a
Introduce: ds_sds_session_select_tailoring
isimluk Sep 19, 2014
70ef745
Use oscap_source to validate tailoring file.
isimluk Sep 19, 2014
441f29b
Remove unneeded code.
isimluk Sep 19, 2014
b2e1ae9
Use oscap_source to parse tailoring file.
isimluk Sep 19, 2014
b2cc713
Refactor: Extract function: xccdf_tailoring_import_source
isimluk Sep 19, 2014
c0b4724
Use oscap_source to import tailoring from session.
isimluk Sep 19, 2014
82dee34
Deprecate: xccdf_tailoring_import.
isimluk Sep 19, 2014
d9c5d2a
Do not store tailoring component on disk.
isimluk Sep 19, 2014
4be3b4c
Move CPE dicts from policy to a new child structure.
isimluk Sep 19, 2014
1e2c9fe
Move CPE lang_models from policy to a child structure.
isimluk Sep 19, 2014
6ba38c9
Move CPE oval_sessions from policy to a child structure.
isimluk Sep 19, 2014
fc4b068
Move CPE applicable_platforms from policy to child structure.
isimluk Sep 19, 2014
7030e94
Refactor: Extract structure: cpe_session
isimluk Sep 19, 2014
7909824
Use oscap_source to validate embedded CPE.
isimluk Sep 21, 2014
96dd251
Use oscap_source when determining version of OVAL document.
isimluk Sep 21, 2014
e45beed
Use oscap_source to validate OVAL results within datastream
isimluk Sep 21, 2014
1878fa8
Promote oscap_source_get_schema_version to public API.
isimluk Sep 21, 2014
fb072e0
Deprecate: oval_determine_document_schema_version.
isimluk Sep 21, 2014
fb36d8c
Refactor: Extract function: cpe_dict_detect_version_priv.
isimluk Sep 21, 2014
dd6906e
CPE version should be received using existing textReader.
isimluk Sep 21, 2014
21f4ec6
Use oscap_source when determining version of CPE dict
isimluk Sep 21, 2014
a79a21d
Use oscap_source to validate CPE file from user.
isimluk Sep 21, 2014
2667b94
Use oscap_source to validate cpe documents from command-line
isimluk Sep 21, 2014
9271ec1
Deprecate: cpe_dict_detect_version
isimluk Sep 21, 2014
b1ced95
Refactor: Extract function: cpe_lang_model_detect_version_priv
isimluk Sep 21, 2014
86a7de6
Do not pass filepath to cpe_lang_model_detect_version.
isimluk Sep 21, 2014
3e71b4f
Use oscap_source to determine XCCDF version within info module.
isimluk Sep 21, 2014
9b3599a
Use oscap_source to validate input testresult.
isimluk Sep 21, 2014
b72642b
Use oscap_source to validate resolved XCCDF.
isimluk Sep 21, 2014
b5a4e2f
Use oscap_source to validate input of xccdf resolve.
isimluk Sep 21, 2014
1d6089b
Use oscap_source to validate input XCCDF for evaluation.
isimluk Sep 21, 2014
3b7895e
Deprecate: xccdf_detect_version.
isimluk Sep 21, 2014
aadf079
Avoid use of ds_sds_decompose_custom
isimluk Sep 21, 2014
5a36f71
oscap_source_get_scap_type shall recognize TestResult.
isimluk Sep 22, 2014
d0cbc1e
Make cpe an allocated property.
isimluk Sep 22, 2014
bb4de0b
Refactor: Extract funciton: cpe_session_new
isimluk Sep 22, 2014
57898f9
Refactor: Extract function: cpe_session_free.
isimluk Sep 22, 2014
0275be1
Refactor: Extract function: cpe_session_lookup_oval_session.
isimluk Sep 22, 2014
bd3d5e7
Use oscap_source to parse cpe_lang_model.
isimluk Sep 22, 2014
a0649dc
Refactor: Extract function: cpe_lang_model_import_source.
isimluk Sep 22, 2014
a578925
Drop cpe_lang_model_parse_xml.
isimluk Sep 22, 2014
fdf4aca
Introduce: cpe_session_add_cpe_lang_model_source.
isimluk Sep 22, 2014
ab8c7fc
Always use oscap_source to import cpe_lang.
isimluk Sep 22, 2014
6ac3b58
Deprecate: cpe_lang_model_import.
isimluk Sep 22, 2014
5aa332c
Use oscap_source for parsing cpe_dict.
isimluk Sep 22, 2014
3271b6a
Drop cpe_parser_ctx_new.
isimluk Sep 22, 2014
e7924dc
Refactor: Extract function: cpe_dict_model_import_source.
isimluk Sep 22, 2014
73d107f
Drop cpe_dict_model_parse_xml
isimluk Sep 22, 2014
e484014
Introduce: cpe_session_add_cpe_dict_source.
isimluk Sep 22, 2014
928fe85
Always use oscap_source to import cpe_dict.
isimluk Sep 23, 2014
3cc5a93
Refactor: Extract function: cpe_session_add_cpe_autodetect_source.
isimluk Sep 23, 2014
112ed1c
Move default_cpe initializator to cpe_session.
isimluk Sep 23, 2014
7867870
Introduce xccdf_policy_model_get_cpe_session.
isimluk Sep 23, 2014
2f15296
Introduce: ds_sds_session_get_component_sources.
isimluk Sep 23, 2014
803e310
CPE sesion may take external cache of oscap_sources
isimluk Sep 23, 2014
507503f
Use ds_sds_session to cache oscap_source for OVAL CPE.
isimluk Sep 23, 2014
ea78bf3
Do not dispose an item that is not owned
isimluk Sep 23, 2014
f853232
Remove duplicate definitions.
isimluk Sep 23, 2014
5532fbc
Do not dump CPE files from DataStream on the disc.
isimluk Sep 24, 2014
691ebab
Do not open XCCDF and CPE again when we already have them parsed.
isimluk Sep 24, 2014
63860ec
Build ds_sds_session when querying DataStream for info
isimluk Sep 24, 2014
fbd8d4a
Use ds_sds_session to build ds_sds_index.
isimluk Sep 24, 2014
9b6118c
No need to set-up temp_dir when loading XCCDF.
isimluk Sep 24, 2014
1ab068b
Avoid using xccdf_benchmark_import.
isimluk Sep 24, 2014
6aa4b58
Deprecate xccdf_benchmark_import
isimluk Sep 24, 2014
1b10b21
Import XCCDF file from the DataStream DOM.
isimluk Sep 24, 2014
7eb17f2
Drop oscap_acquire_cleanup_dir_bundled.
isimluk Sep 24, 2014
944fcb1
Promote oscap_source_readable_origin to public API.
isimluk Sep 24, 2014
1ae4a64
Avoid use of oscap_determine_document_type.
isimluk Sep 24, 2014
7b0bead
Deprecate oscap_determine_document_type.
isimluk Sep 24, 2014
352ab16
Promote ds_sds_session_set_datastream_id to public API.
isimluk Sep 24, 2014
21ab30f
Use ds_sds_session to extract OVAL file from DataStream.
isimluk Sep 24, 2014
484d051
Promote ds_sds_session_get_component_by_href to public API.
isimluk Sep 24, 2014
7ec2769
Promote ds_sds_session_register_component_with_dependencies to public…
isimluk Sep 24, 2014
7a5d19d
Drop oscap_acquire_temp_dir_bundled.
isimluk Sep 24, 2014
f916d21
Avoid use of oscap_validate_document within oscap-ds.
isimluk Sep 24, 2014
63603be
Avoid use of oscap_validate_document within oscap-cve.
isimluk Sep 24, 2014
3408f5a
Drop validation_failed.
isimluk Sep 24, 2014
0c0f8ce
Promote ds_sds_session_dump_component_files to public API.
isimluk Sep 24, 2014
4fbb899
Promote ds_sds_session_set_target_dir to public API.
isimluk Sep 24, 2014
c34c364
Avoid use of oscap_validate_document from xccdf_session.
isimluk Sep 24, 2014
bfa2c60
Do not forget to take break
isimluk Sep 24, 2014
1916a78
Deprecate: oscap_validate_document.
isimluk Sep 24, 2014
44ddd8b
Error shall go to stderr.
isimluk Sep 27, 2014
74a657c
Show errno to the user.
isimluk Sep 27, 2014
b94e994
Refactor: Extract function: _gcwd.
isimluk Sep 27, 2014
b8c400c
Use ds_sds_session within oscap ds sds-split.
isimluk Sep 24, 2014
83d7eca
Introduce function: ds_sds_session_reset.
isimluk Sep 27, 2014
627a3ac
Reset sds_session after each checklist selection
isimluk Sep 27, 2014
d410230
Deprecate: ds_sds_decompose.
isimluk Sep 27, 2014
8c6be6f
Deprecate: ds_sds_decompose_custom.
isimluk Sep 27, 2014
c252bc0
Deprecate: ds_sds_index_import
isimluk Sep 27, 2014
f72678c
Avoid use of xmlReaderForFile
isimluk Sep 27, 2014
47eb5bf
Drop libxml_error_handler.
isimluk Sep 27, 2014
f0ec4ab
tests: Introduce test for a codestyle
isimluk Sep 27, 2014
8741172
Avoid using xmlTextReaderReadString function.
isimluk Sep 27, 2014
72672ae
Tests: Forbid use of xmlTextReaderReadString.
isimluk Sep 27, 2014
0e15c4e
Avoid use of cpe_dict_model_import
isimluk Sep 27, 2014
2bbafb6
Refactor: rename variable.
isimluk Sep 27, 2014
187bfd1
ds_sds_session switches from absolute paths to relative
isimluk Sep 27, 2014
64b6b23
Deprecate: cpe_dict_model_import.
isimluk Sep 27, 2014
b9dd12c
Promote oscap_path_to_xslt to privileged.
isimluk Sep 27, 2014
26af338
Avoid using oscap_apply_xslt.
isimluk Sep 27, 2014
da346a8
Use exported XCCDF dom to generate HTML report.
isimluk Sep 28, 2014
8ff5f4f
Refactor: Extract function ds_sds_compose_component_add_script_content
isimluk Sep 28, 2014
cbaa2c7
session->xccdf.source should never be owned directly.
isimluk Sep 28, 2014
eeaba3d
Drop xccdf_session->filename.
isimluk Sep 28, 2014
5daef09
Avoid direct use of xmlReadFile.
isimluk Sep 28, 2014
afa6810
Do not attempt to open SCE script to DOM
isimluk Sep 28, 2014
75ae103
Refactor: Merge two subsequent conditions together
isimluk Sep 28, 2014
906bf34
Avoid direct use of xmlReadFile
isimluk Sep 28, 2014
aee3ec3
Avoid direct use of xmlReadFile
isimluk Sep 28, 2014
1bf9168
Re-use existing oscap_source to add component with dependencies.
isimluk Sep 28, 2014
46f44f1
Avoid direct use of xmlReadFile
isimluk Sep 28, 2014
80af854
Avoid direct use of xmlReadFile
isimluk Sep 28, 2014
0d850d3
Avoid direct use of xmlReadFile.
isimluk Sep 28, 2014
994b686
tests: Check codestyle only in C,C++ sources and header files.
isimluk Sep 28, 2014
1c6a2ea
tests: Forbid direct use of xmlReadFile within OpenSCAP project
isimluk Sep 28, 2014
235845f
Refactor: Extract function: ds_rds_create_source.
isimluk Sep 28, 2014
00165b4
Avoid direct use of xmlSaveFileEnc.
isimluk Sep 28, 2014
c7b718b
Use exported source to validate ARF DOM directly.
isimluk Sep 28, 2014
4d7902d
Drop xccdf_session->oval.result_files.
isimluk Sep 28, 2014
7d908c1
Export XCCDF TestResult only when explicitly requested.
isimluk Sep 28, 2014
2a0cbc8
Avoid direct use of xmlSaveFileEnc.
isimluk Sep 28, 2014
54a2d4b
Merge branch 'master' into oscap_source
isimluk Sep 28, 2014
a54d84a
Make sure that error message is generic enough.
isimluk Sep 28, 2014
d545da9
Fix a typo.
isimluk Sep 28, 2014
769ea3e
Improve documentation of oscap_source and ds_sds_session.
isimluk Sep 28, 2014
5318d21
Remove TODO that no longer applies
isimluk Sep 28, 2014
593c2ad
Rename private constant to better reflect its use.
isimluk Sep 28, 2014
4437034
tests: Assume.h is not needed to test codestyle.
isimluk Sep 30, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ac_probes/configure.ac.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ AC_CONFIG_FILES([Makefile
selinux/Makefile
libopenscap.pc
src/common/Makefile
src/source/Makefile
tests/Makefile
tests/API/Makefile

Expand Down Expand Up @@ -636,6 +637,7 @@ AC_CONFIG_FILES([Makefile
tests/API/XCCDF/variable_instance/Makefile

tests/schemas/Makefile
tests/codestyle/Makefile

src/SCE/Makefile
tests/sce/Makefile])
Expand Down
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,7 @@ AC_CONFIG_FILES([Makefile
selinux/Makefile
libopenscap.pc
src/common/Makefile
src/source/Makefile
tests/Makefile
tests/API/Makefile

Expand Down Expand Up @@ -1439,6 +1440,7 @@ AC_CONFIG_FILES([Makefile
tests/API/XCCDF/variable_instance/Makefile

tests/schemas/Makefile
tests/codestyle/Makefile

src/SCE/Makefile
tests/sce/Makefile])
Expand Down
10 changes: 6 additions & 4 deletions src/CCE/cce.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

/*
* Copyright 2008-2009 Red Hat Inc., Durham, North Carolina.
* Copyright 2008-2014 Red Hat Inc., Durham, North Carolina.
* All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -37,6 +37,8 @@

#include "common/public/oscap.h"
#include "common/elements.h"
#include "oscap_source.h"
#include "source/oscap_source_priv.h"

#define CCE_SUPPORTED "5"

Expand Down Expand Up @@ -80,18 +82,18 @@ struct cce_entry *cce_entry_new_empty(void)

static void cce_parse(const char *docname, struct cce *cce)
{
xmlTextReaderPtr reader;
struct oscap_source *source = oscap_source_new_from_file(docname);
xmlTextReaderPtr reader = oscap_source_get_xmlTextReader(source);
int ret;
reader = xmlNewTextReaderFilename(docname);
if (reader != NULL) {
xmlTextReaderSetErrorHandler(reader, &libxml_error_handler, NULL);
ret = xmlTextReaderRead(reader);
while (ret == 1) {
process_node(reader, cce);
ret = xmlTextReaderRead(reader);
}
xmlFreeTextReader(reader);
}
oscap_source_free(source);
}

struct cce *cce_new(const char *fname)
Expand Down
6 changes: 5 additions & 1 deletion src/CPE/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ libcpe_la_SOURCES = cpedict.c \
cpedict_ext_priv.c \
cpelang_priv.h \
cpedict_ext_priv.h \
cpedict_priv.h
cpedict_priv.h \
cpe_session.c \
cpe_session_priv.h

libcpe_la_CPPFLAGS = @xml2_CFLAGS@ \
@pcre_CFLAGS@ \
-I$(srcdir)/public \
-I$(top_srcdir)/src/CPE/public \
-I$(top_srcdir)/src/common/public \
-I$(top_srcdir)/src/source/public \
-I$(top_srcdir)/src

libcpe_la_LDFLAGS = @xml2_LIBS@ \
Expand Down
16 changes: 1 addition & 15 deletions src/CPE/cpe_ctx_priv.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013 Red Hat Inc., Durham, North Carolina.
* Copyright 2013--2014 Red Hat Inc., Durham, North Carolina.
* All Rights Reserved.
Copy link
Member

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)

Copy link
Member Author

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

*
* This library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -43,20 +43,6 @@ static inline struct cpe_parser_ctx *_cpe_parser_ctx_new()
return oscap_calloc(1, sizeof(struct cpe_parser_ctx));
}

struct cpe_parser_ctx *cpe_parser_ctx_new(const char *filename)
{
struct cpe_parser_ctx *ctx = _cpe_parser_ctx_new();
ctx->reader = xmlReaderForFile(filename, NULL, 0);
if (ctx->reader == NULL) {
oscap_seterr(OSCAP_EFAMILY_GLIBC, "Unable to open file: '%s'", filename);
cpe_parser_ctx_free(ctx);
return NULL;
}
xmlTextReaderSetErrorHandler(ctx->reader, &libxml_error_handler, NULL);
ctx->owns_reader = true;
return ctx;
}

struct cpe_parser_ctx *cpe_parser_ctx_from_reader(xmlTextReaderPtr reader)
{
struct cpe_parser_ctx *ctx = _cpe_parser_ctx_new();
Expand Down
9 changes: 1 addition & 8 deletions src/CPE/cpe_ctx_priv.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013 Red Hat Inc., Durham, North Carolina.
* Copyright 2013--2014 Red Hat Inc., Durham, North Carolina.
* All Rights Reserved.
*
* This library is free software; you can redistribute it and/or
Expand Down Expand Up @@ -33,13 +33,6 @@ OSCAP_HIDDEN_START;
*/
struct cpe_parser_ctx;

/**
* Constructor for cpe_parser_ctx
* @param filename File path to CPE file to parse
* @returns parser's context
*/
struct cpe_parser_ctx *cpe_parser_ctx_new(const char *filename);

/**
* Construct cpe_parser_ctx from existing xmlTextReader
* @param reader existing XML reader
Expand Down
150 changes: 150 additions & 0 deletions src/CPE/cpe_session.c
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;
}
52 changes: 52 additions & 0 deletions src/CPE/cpe_session_priv.h
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
Loading