-
Notifications
You must be signed in to change notification settings - Fork 9
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
Present references in a table #217
Conversation
Hello @jan-cerny! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2023-12-06 12:48:06 UTC |
We will sort and show the references grouped by reference target. The well-known references will be labeled. This makes the "References" section of rule detail actually useful. Fixes: OpenSCAP#154
It really feels like the code (and developers' personal preferences) is asking for the line length limit to be 120 instead of 100. |
Not really. All the lines that are flagged as too long are in the list of URLs ( |
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 like the new style of references, but I have some ideas for improvements.
from dataclasses import replace | ||
|
||
from ..data_structures import Identifier, Reference, Rule, RuleWarning | ||
from ..namespaces import NAMESPACES | ||
from .full_text_parser import FullTextParser | ||
from .remediation_parser import RemediationParser | ||
|
||
KNOWN_REFERENCES = { |
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.
Please add comments to the code to turn off long-line warnings for this constant.
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 add the comments.
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.
Pylint is not happy. Please use # pylint: disable=line-too-long
before the constant definition and # pylint: enable=line-too-long
after the constant definition. You can check this with the tox -e code_style
command.
references.append(Reference(referenc.get("href"), referenc.text)) | ||
return references | ||
for url, ref_ids in url_to_ref_ids.items(): | ||
name = KNOWN_REFERENCES.get(url, url) |
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 would suggest creating a default value for the name
if the href
attribute is an empty string.
For example, reference SRG-OS-000003-VMM-000030
of the xccdf_org.ssgproject.content_rule_account_disable_post_pw_expiration
rule.
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.
Nice catch! You're right, the href
attribute of the reference
element is optional.
I have add code that accounts for this situation.
However, this situation shouldn't happen in our content. The reference
without href
makes little sense. Do you have a specific SCAP content or its version where this happens?
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 checked the latest content and all the href attributes are not empty strings.
I found this in:
SSG: [0, 1, 63]
Rule: xccdf_org.ssgproject.content_rule_account_disable_post_pw_expiration
Reference: SRG-OS-000003-VMM-000030
<div class="pf-l-flex pf-m-column"><div class="pf-l-flex__item"> | ||
<p class="pf-c-table__text"> | ||
<div> | ||
<table> |
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.
Please create a responsive table using CSS classes from Patternfly. Missing CCS classes cause a grey bar. See image.
I think that the rows of the internal table with references should span the full width of the table cell with the OVAL definition.
Example rule: xccdf_org.ssgproject.content_rule_account_unique_name
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 add some class name that I have seen around. I'm not sure if it's correct because I don't have any experience with that. Please check this and point me to some resources.
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.
Here is Patternfly documentation. Looks good to me.
These lines are too long according to the PEP8. But, I think we can waive this occurrence as a special case. I think it's more useful to keep the URLs as they are instead of splitting them by a backlash because if they are kept as they are they can be easily identified by grep when a need to update them arise.
The `href` attribute of the `reference` element is optional according to the XCCDF specification. This commit solves the situation when the `href` attribute is not set. In this situation, the reference source is unknown, we don't know where this reference points to so we will put in in a new "unknown" reference category to be displayed in the HTML report.
from dataclasses import replace | ||
|
||
from ..data_structures import Identifier, Reference, Rule, RuleWarning | ||
from ..namespaces import NAMESPACES | ||
from .full_text_parser import FullTextParser | ||
from .remediation_parser import RemediationParser | ||
|
||
KNOWN_REFERENCES = { |
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.
Pylint is not happy. Please use # pylint: disable=line-too-long
before the constant definition and # pylint: enable=line-too-long
after the constant definition. You can check this with the tox -e code_style
command.
I have add comments for the pylint tool |
url_to_ref_ids = collections.defaultdict(list) | ||
for reference_el in rule.findall(".//xccdf:reference", NAMESPACES): | ||
url = reference_el.get("href") | ||
if url is None: |
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.
Here is a little catch. I found out that in the reference
element is present the href
attribute but with an empty string so it looks like this: <reference href="">Example</reference>
. So in a variable url
is a present empty string. Please add a check for the empty string to the if condition.
I have extend the condition to account empty strings in href. |
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 like the new presentation style of references. I have generated a report and checked the new presentation of references. I haven't noticed any problem.
We will sort and show the references grouped by reference target. The well-known references will be labeled. This makes the "References" section of rule detail actually useful.
For example:
Fixes: #154