-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor: split cli methods to easy testing #3
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Felipe Zipitria <[email protected]>
if len(flist) == 0: | ||
errmsg("List of files is empty!") | ||
sys.exit(1) | ||
errmsg(" Can't open file for indent check: %s" % (f)) |
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.
errmsg(" Can't open file for indent check: %s" % (f)) | |
errmsg("Can't open file for indent check: %s" % (f)) |
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.
Just my 2 cents: the indentations (spaces before messages here and at other reviews) helped the readability of the output, eg:
rules/REQUEST-931-APPLICATION-ATTACK-RFI.conf
Ignore case check ok.
Action order check ok.
Indentation check ok.
no 'ctl:auditLogParts' action found.
no duplicate id's
paranoia-level tags are correct.
PL anomaly_scores are correct.
All TX variables are set.
No new tags added.
No t:lowercase and (?i) flag used.
No rule without OWASP_CRS tag.
No rule without correct ver action.
No rule uses TX.N without capture action.
rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf
Ignore case check ok.
Action order check ok.
...
because the script processes files in order. If there are no indentations, I think it's a bit harder to read the output.
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.
All those are more debug than informational. Meaning, they don't provide additional information.
The only ones that do are the failures, IMHO.
So I think these should be moved to logger.debug()
instead, and if people wants to see that output just run it with --debug
or similar.
for f in flist: | ||
diff = difflib.unified_diff(from_lines, output) | ||
if from_lines == output: | ||
msg(" Indentation check ok.") |
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.
msg(" Indentation check ok.") | |
msg("Indentation check ok.") |
if from_lines == output: | ||
msg(" Indentation check ok.") | ||
else: | ||
errmsg(" Indentation check found error(s)") |
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.
errmsg(" Indentation check found error(s)") | |
errmsg("Indentation check found error(s)") |
|
||
### check case usings | ||
c.check_ignore_case() | ||
if len(c.caseerror) == 0: | ||
msg(" Ignore case check ok.") | ||
logger.info(" Ignore case check ok.") |
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.
logger.info(" Ignore case check ok.") | |
logger.info("Ignore case check ok.") |
if has_unused == False: | ||
msg(" No unused TX variable") | ||
if not has_unused: | ||
logger.info(" No unused TX variable") |
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.
logger.info(" No unused TX variable") | |
logger.info("No unused TX variable") |
Co-authored-by: Max Leske <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
Signed-off-by: Felipe Zipitria <[email protected]>
what
why