Description
Existing OVAL templates are:
- lowering the enter barrier for potential SSG contributors
(since they don't require exact knowledge of particular OVAL constructs), - radically increasing the speed in which new OVAL checks can be contributed
(since it's enough to edit corresponding CSV file, and run correspondingmaketarget
to obtain new OVAL definition implementation for that product)
Since the textfilecontent54_object is the most utilized one in SSG content
(for demonstration this is the current output from RHEL/6 product:
$ ./count_oval_objects.py scap-security-guide/RHEL/6/output/ssg-rhel6-xccdf.xml
...
Count of used OVAL objects:
==================================================
textfilecontent54_object 47
partition_object 10
runlevel_object 7
file_object 5
rpminfo_object 3
variable_object 2
xmlfilecontent_object 1
environmentvariable58_object 1
selinuxsecuritycontext_object 1
interface_object 1
) we should consider implementation of OVAL template for the OVAL's textfilecontent54_test construct.
Please see the expectations / requirements on this template below:
- the corresponding CSV, AST, whatever file should allow comments,
- the template should be smart enough not to require all of the necessary element and / or attribute values to be provided (just those that would truly need updating. The rest of the element / attribute values should be prepopulated with default OVAL values from corresponding XSD,
- on the other hand the template should be flexible enough to allow:
- override default values of selected attributes in an element, for example having the default form of
<ind:instance>element reading like:
<ind:instance datatype="int" operation="equals">1</ind:instance>
by specifying e.g.operation@instance="greater than or equalthis default form would translate into:
<ind:instance datatype="int" operation="greater than or equal">1<ind:instance> - be also flexible enough to allow:
- external variables to be specified,
- extended definitions to be specified,
- and even (but this can be implemented in the future even multiple tests and multiple
objects to be specified)
- override default values of selected attributes in an element, for example having the default form of
Since the above requirements are pretty wide scoped, CSV template format might not be the right one to implement this.
During proposing the expected interface for this I was thinking if we could hopefully use Python's AST's module literal_eval helper:
[1] https://docs.python.org/2/library/ast.html#ast.literal_eval
to convert the AST (current CSV) content specification into Python object, then use some deserialization method to convert such Python dictionary into a XML representation:
-
either using means of dicttoxml module or
-
using own method for that purpose. See e.g.:
[2] http://code.activestate.com/recipes/573463-converting-xml-to-dictionary-and-back/for example.