-
Notifications
You must be signed in to change notification settings - Fork 385
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
yamlfilecontent probe #1480
yamlfilecontent probe #1480
Conversation
Can you please also add the libyaml dependency? |
@evgenyz Yes, more patches are coming |
@evgenyz We have discussed this with @matejak and we think that at this moment we will expect that yaml-path is a separate .so library. For this I propose a change in OpenSCAP/yaml-filter#1 Also, I have created a new CMake find module in 9715d1d which detects the yaml-path library. Basically it depends on OpenSCAP/yaml-filter#1 |
@jan-cerny Hmm, we have to have a |
9715d1d
to
ea3b811
Compare
I'm struggling with the problem described in OpenSCAP/yaml-filter#2 |
I'm on it |
ea3b811
to
64296cb
Compare
I have rebased it on the top of maint-13 which now contains XML schemas and tests. It already works with content from test_probes_yamlfilecontent_key.xml. But when evaluating test_probes_yamlfilecontent_array.xml I get unexpected results. Apart from the correct items in |
Adds only CMake, enums and mostly empty .c and .h files.
We have to create our own find module bacuse CMake doesn't ship any find module for libyaml.
At this moment the raw returned data is directly used to populate the 'value_of' element.
Instead of emitted YAML document we will gather the scalars that match the YAML patch expression. We don't produce OVAL items directly but we use a temporary list to avoid incomplete results if a list contains non-scalar values. We don't need the yaml_emitter anymore.
And include it to the libopenscap.so.
The file was called tests_probes_yamlfilecontent_offline_mode.xml but the test script expects test_probes_yamlfilecontent_offline_mode.xml. As all the other files in this directory start with test_ it's better to be consistent and rename the file.
The states expect value of `name` key from openshift-logging.yaml not `namespace`.
The purpose of this test is to test if probe doesn't collect data from the host. The comment in oval:0:def:2 in test_probes_yamlfilecontent_offline_mode.xml says: "make sure file in host doesn't match" and the expected result is false. The corresponding state expects value of value_of to be `outstance`. Based on this, the sed command should modify the file in host, not in guest, because if the file in guest is modified the object and state will match and definition result will be true.
64296cb
to
ea04516
Compare
Missing this line caused that the test was not skipped if oscap-chrootable was not built.
@openscap-ci test this please |
Apologies for the bugs in the tests, 😬 |
Adds submodules in OpenSCAP jobs and adds libyaml-devel due to new yamlfilecontent probe. See OpenSCAP/openscap#1480 Also updates whitelist for SSG PRs.
Creates multiple value_of elements within a single yamlfilecontent_item element instead of creating multiple yamlfilecontent_item elements containing single value_of elements. According to the schema proposal the value_of element can occur 0 to unbounded times. Also, this behavior is consistent with xmlfilecontent probe.
It is impossible that a single collected item would have 2 values at the same time.
c92a14f
to
7dc6684
Compare
We will detect booleans, floats and integers using YAML 1.2 Core Schema (https://yaml.org/spec/1.2/spec.html#id2804923) and we will treat every other scalar as string.
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.
Code looks good.
Given the fundamentality of the yaml type detection, I have suggested tests for the error code path.
tests/probes/yamlfilecontent/test_probes_yamlfilecontent_types.xml
Outdated
Show resolved
Hide resolved
Adds tests that test explicit typecasts errors, and tests that quoted strings are always treated as strings. When using alternatives in regular expression '^' and '$' are part of the only alternative, therefore groups have to be used to have these anchors in all alternatives.
@yuumasato Thank you very much for the tests ideas, it helped to discover some issues. |
@evgenyz @yuumasato If the YAML document is empty or if a key specified by yamlpath expression isn't present, it collects |
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.
The probe seems to be in good shape to start processing some real yamlfilecontent_tests
from CaC.
Also, thank you for adding the type detection, it will really make content writing experience smooth.
@yuumasato SSG will probably have to start generation (pesudo) OVAL 5.11.3 content. |
Well noted. As the |
This PR will add new yamlfilecontent probe based on proposal in OVAL-Community/OVAL#91.
This PR contains: