-
Notifications
You must be signed in to change notification settings - Fork 698
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
Implement a tool for parsing profiles and outputing rules #10455
Conversation
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.
Thanks for the PR!
I have few other items that are not in my code comments:
- Please take look at the Code Climate findings. Especially the PEP8 findings.
- Add some documentation about this script in
docs/manual/developer/05_tools_and_utilities.md
. Explaining what format of spreadsheets is needed would be helpful.
utils/generate_profile.py
Outdated
|
||
yaml.add_representer(literal_unicode, literal_unicode_representer) | ||
|
||
parser = argparse.ArgumentParser( |
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 move this to a method
a3670cf
to
2fe2bbb
Compare
Thanks for the review @Mab879 - I still need to get the documentation ironed out. |
utils/generate_profile.py
Outdated
def parse(self): | ||
return NotImplemented | ||
|
||
class Section: |
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.
The Section
, Control
, and Benchmark
classes really could be their own library. That'd actually be pretty useful in other scripts, too.
2fe2bbb
to
60143a7
Compare
utils/generate_profile.py
Outdated
self.description = None | ||
self.level = None | ||
self.remediation = None | ||
self.rationale = 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.
to bring a slack conversation over here and tag @Mab879 - would it be a good idea to merge this class with the control
class from srg/controls.py
?
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.
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 think that shared library would sense.
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.
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 threw together a quick library https://github.com/rhmdnd/pycompliance
This is a port from a patch proposed to another project: ComplianceAsCode/content#10455 Documentation and release will come after initial round of feedback.
60143a7
to
dba466f
Compare
|
||
import json | ||
import yaml | ||
from pycompliance import pycompliance |
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.
This is based on the latest content in https://github.com/rhmdnd/pycompliance
If folks are ok with that approach, I'll package it and release to PyPI.
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.
Is it correct to say that this library will be focused on making compliance content in various formats (xslx, pdf) available in CaC content formats (i.e. controls, profiles, rule in yaml)?
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 wasn't sure if we'd want to put all the parsing in the pycompliance library. I kept it pretty limited so that it only focused on the common parts of my script and the script from #10469
dba466f
to
85c2246
Compare
The tool currently outputs the following if you have the benchmark available locally:
|
10df58c
to
5d30159
Compare
5d30159
to
76caca0
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 like and support the direction the library and script are going
raise NotImplemented | ||
|
||
|
||
class XLSXParser(Parser): |
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.
Maybe the XLSXParser should actually be in pycompliance library?
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 could be. I figured once we take that step, we may get asked to support parsing additional formats (PDFs).
cols = [ | ||
'section #', | ||
'recommendation #', | ||
'profile', | ||
'title', | ||
'assessment status', | ||
'description', | ||
'remediation procedure', | ||
'rationale statement', | ||
'audit procedure'] |
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.
And in the future these columns would be easily customizable for other spreadsheets, not only CIS.
|
||
import json | ||
import yaml | ||
from pycompliance import pycompliance |
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.
Is it correct to say that this library will be focused on making compliance content in various formats (xslx, pdf) available in CaC content formats (i.e. controls, profiles, rule in yaml)?
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.
@Mab879 Do you have anything to add?
I would like some basic docs before this merged. |
76caca0
to
7222f78
Compare
7222f78
to
6615f4b
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.
Looks good other than that one code climate issue. Once that is fixed we should be good to merge.
This adds the basic skeleton of a tool that parses CIS profiles using an XLSX parser and converts controls to rules that we can use in OpenSCAP. The primary purpose is to help maintain CIS profiles by generating most of the boilerplate rule template.
6615f4b
to
1c5812d
Compare
Fixed - thanks for the reviews! |
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.
Thanks!
Code Climate has analyzed commit 1c5812d 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 52.4% (0.0% change). View more on Code Climate. |
I'll get a pycompliance release on PyPI tomorrow and we can iterate there. |
/packit build |
This adds the basic skeleton of a tool that parses CIS profiles using an
XLSX parser and converts controls to rules that we can use in OpenSCAP.
The primary purpose is to help maintain CIS profiles by generating most
of the boilerplate rule template.