Skip to content
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

Add sorted results to srg_diff #9778

Merged
merged 2 commits into from
Nov 10, 2022

Conversation

Mab879
Copy link
Member

@Mab879 Mab879 commented Nov 7, 2022

Description:

  • Make the results in utils/srg_diff.py sorted
  • Minor refactoring in utils/srg_diff.py

Rationale:

  • The unstable results between runs made it hard to use the output when making improvements
  • A little cleanup shouldn't hurt

Review Hints:

  • Run this script a few times and observe the order of the rules and deltas should be the same between

Also some minor refactoring
@Mab879 Mab879 added the Infrastructure Our content build system label Nov 7, 2022
@Mab879 Mab879 added this to the 0.1.65 milestone Nov 7, 2022
@github-actions
Copy link

github-actions bot commented Nov 7, 2022

Start a new ephemeral environment with changes proposed in this pull request:

Fedora Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@jan-cerny jan-cerny self-assigned this Nov 8, 2022
@@ -116,15 +119,36 @@ def get_requirements_with_no_cces(sheet: Worksheet, end_row: int) -> list:
return result


def get_deltas(cac_cce_dict, cce_rule_id_dict, common_set, disa_cce_dict):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this function also have type parameters?


title = f"{base_path} vs {target_path}"

template = _create_template(args.root)
missing_in_base.sort()
missing_in_target.sort()
deltas.sort()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have got this traceback:

[jcerny@thinkpad scap-security-guide{pr/9778}]$ python3 utils/srg_diff.py --target "/home/jcerny/Downloads/RHEL 9 STIG Stage 3 Submission_2022_11_01.xlsx" --base cac_export.xlsx --product rhel9 --output diff.html 
/usr/lib/python3.10/site-packages/openpyxl/worksheet/_reader.py:300: UserWarning: Unknown extension is not supported and will be removed
  warn(msg)
Traceback (most recent call last):
  File "/home/jcerny/work/git/scap-security-guide/utils/srg_diff.py", line 193, in <module>
    main()
  File "/home/jcerny/work/git/scap-security-guide/utils/srg_diff.py", line 178, in main
    deltas.sort()
TypeError: '<' not supported between instances of 'SrgDiffResult' and 'SrgDiffResult'
[jcerny@thinkpad scap-security-guide{pr/9778}]$ 

Can you take a look into it?

@codeclimate
Copy link

codeclimate bot commented Nov 9, 2022

Code Climate has analyzed commit 64fc5bb and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 46.8% (0.0% change).

View more on Code Climate.

Copy link
Collaborator

@jan-cerny jan-cerny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I have generated the diff using python3 utils/srg_diff.py --target "/home/jcerny/Downloads/RHEL 9 STIG Stage 3 Submission_2022_11_01.xlsx" --base cac_export.xlsx --product rhel9 --output diff.html and I have opened it and I can see that the output is expected. I don't experience the aforementioned traceback anymore.

The CI fail on Fedora rawhide is in OpenSCAP and isn't related to this PR.

@jan-cerny jan-cerny merged commit fb1e574 into ComplianceAsCode:master Nov 10, 2022
@Mab879 Mab879 deleted the make_srg_diff_order_stable branch November 10, 2022 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Infrastructure Our content build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants