-
Notifications
You must be signed in to change notification settings - Fork 409
Fixing inverted fields in HTML report #2265
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
Conversation
dfb38a9
to
6bfa486
Compare
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.
It looks like your change fixes most of the cases of the "inverted fields" in HTML report that are caused by elements referencing variables.
xsl/xccdf-report-oval-details.xsl
Outdated
<xsl:for-each select="$tested_var"> | ||
<xsl:value-of select="."/> | ||
</xsl:for-each> |
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.
If during an evaluation of an OVAL test there were multiple variables evaluated and tested, then there are multiple oval-res:tested_variable
elements. This solution prints all of them here and glues them together. That's wrong, only one of them should be printed here. Specifically, we should print here the value for the variable specified by the @var_ref
attribute of the object child element. This situation happens for example in rule audit_rules_unsuccessful_file_modification_chmod
.
xsl/xccdf-report-oval-details.xsl
Outdated
<tr> | ||
<xsl:variable name='variable_id' select='$object_info/*/@var_ref'/> | ||
<!-- Choose the first 'child' of an XML object, check if there is a var reference --> | ||
<xsl:variable name='variable_id' select='$object_info/*[1]/@var_ref'/> |
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.
It seems to me that this is wrong and thanks to this being wrong the rest of the code works as expected 😄 in our example of rule accounts_passwords_pam_faillock_audit
but might or might not work in other rules.
An OVAL object element (here in the $object_info
variable) can have multiple child elements and all of them can have the @var_ref
attribute. In the example of rule accounts_passwords_pam_faillock_audit
it's never the first child, it's always the second child that has the attribute, therefore this variable is always null, and as a result the following xsl:if
block isn't executed. That causes that the items are rendered correctly. But, for other rules this might not be the case, sometimes the first child references a variable using a @var_ref
attribute as well.
It seems that this xsl:variable
and the whole following xsl:if
block can be removed completely.
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.
Yeah, I've come to the same conclusion. Last commit should take care of all mentioned issues. I've also added a check, that will print all of the referenced variables line by line, if more than one variable with the same id exist ( like with no_password_auth_for_systemaccounts
rule for example).
6bfa486
to
cfad5b2
Compare
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.
I have generated HTML report from my scan results using this code. Then I have reviewed the OVAL test details for many rules. I have found that all details are displayed correctly and no columns are swapped.
The CI fail on Ubuntu is caused probably by an outdated test mock but isn't caused by the contents of this PR.
@Arden97 Please create backport PR for |
Description:
Wrong table content examples:
Example XML object, that is processed by a template:
Rationale:
var_ref
attribute in atextfilecontent54_object
and print it's value in to the first table columnpattern
field, for the lack of plain text valueReview Hints:
NOTE: This PR fixes described issue on Jira, but there are other issues related to this XSL template. Remaining issues, that were noticed (extra columns):