Extend SSG with functions to manage variables#12717
Conversation
|
I am working on Python unit tests and will provide an update soon. |
Variables are processed differently depending on the content and the existing functions are heavily dependent of SCAP, making it hard to process variables in other contexts such as OSCAL. This extension provides the necessary functions for an easier integration with other tools. Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
Remove unnecessary "." from paths. Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
97e85e1 to
538ace9
Compare
vojtapolasek
left a comment
There was a problem hiding this comment.
Hello,
thank you for this enhancement. I found some small things worth fixing, see other comments.
I used the script from the PR description and it seems it works.
However, do you plan to supply unit tests for this file?
Could you please test at least public functions in the file?
Unit tests would prevent regressions in the future.
Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
Thanks @vojtapolasek Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
The former two functions were pretty similar. With this approach code duplication is avoided and one single function make it simpler in this context. Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
Hi, I already provided the Unit tests but probably you started reviewing some minutes before the relevant commit. : ) I also incorporated your feedback. Could you take a look again, please? |
8d32e8a to
467a848
Compare
|
Ok. I need to take a better look on failed tests for Suse and Ubuntu, but can't continue today. |
Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
467a848 to
ebe2d92
Compare
|
@marcusburghardt thank you for adding unit tests. I am looking at them and comparing to other unit tests. In the content project, usually test data are defined outside the actual test. You define them directly in the test... please what is the idea behind this approach? |
It avoids code duplication for similar tests. By centralizing the setup of test files it is also easier to update the tests. For example, in this new function more options were included for variables and used in tests. Signed-off-by: Marcus Burghardt <maburgha@redhat.com>
There are many different cases in unit tests since there is no Style Guide definition for this in the project. The tests I wrote don't use |
Co-authored-by: vojtapolasek <krecoun@gmail.com>
|
Code Climate has analyzed commit dc6235b and detected 5 issues on this pull request. Here's the issue category breakdown:
Note: there is 1 critical issue. The test coverage on the diff in this pull request is 90.7% (50% is the threshold). This pull request will bring the total coverage in the repository to 61.6% (0.7% change). View more on Code Climate. |
|
It looks good now. The Codeclimate is complaining about too high complexity of some functions, but I looked at it and I think that they could be split into smaller chunks, however I am not sure if it would improve overall code readibility. So I am waiving this check. |
Description:
Variables are processed differently depending on the type of content and the existing functions are heavily dependent of SCAP, making it hard to process variables in other contexts. For example to use in OSCAL files.
This extension provide the necessary functions for an easier integration with other tools.
Rationale:
Sometimes it is necessary to process the variables and the respective options taking into account the selected options in control files and profiles. These functions are independent of SCAP format.
Review Hints:
I implemented the minimal necessary functions that should be enough to collect the variables information. More functions can be included on-demand. Here is a simple script that can be used to test the results: