Closed victoria-miltcheva closed 2 years ago
To test the reporting functionality directly, create a test.py
file in the root of detect-secrets
, and run it with python test.py
.
Example contents (uncomment sections to test, you'll also need to edit values in your secrets (see https://github.com/victoria-miltcheva/detect-secrets/blob/reporting-pr-8/detect_secrets/core/report/conditions.py) to cause conditions to fail):
import detect_secrets.main
# provide cli args as an array here
# detect_secrets.main.main(['audit', '.secrets.baseline'])
### Error cases ###
# Case --fail-on-live
# detect_secrets.main.main(["audit", "--fail-on-live", ".secrets.baseline",])
# Case --fail-on-audited-real
# detect_secrets.main.main(["audit", "--fail-on-audited-real"], ".secrets.baseline", )
# Case --fail-on-unaudited
# detect_secrets.main.main(["audit", "--fail-on-unaudited", ".secrets.baseline", ])
# Case --omit-instructions
# detect_secrets.main.main(["audit", "--omit-instructions", ".secrets.baseline"])
# Case --json
# detect_secrets.main.main(["audit", "--json", ".secrets.baseline",])
# Case: json with omit instructions, error
# detect_secrets.main.main(["audit", "--report", "--json", "--omit-instructions"])
### Help ###
# Case: audit report help
# detect_secrets.main.main(["audit", "--report", "--help"])
### Reporting ###
# Case: report only
# detect_secrets.main.main(["audit", "--report", ".secrets.baseline"])
# Case: all fail args and default report
# detect_secrets.main.main(
# [
# "audit",
# "--report",
# "--fail-on-unaudited",
# "--fail-on-live",
# "--fail-on-audited-real",
# ".secrets.baseline",
# ]
# )
# # Case: omit instructions
# detect_secrets.main.main(
# [
# "audit",
# "--report",
# "--fail-on-unaudited",
# "--fail-on-live",
# "--fail-on-audited-real",
# "--omit-instructions",
# ".secrets.baseline",
# ]
# )
# Case: JSON
# detect_secrets.main.main(
# [
# "audit",
# "--report",
# "--fail-on-unaudited",
# "--fail-on-live",
# "--fail-on-audited-real",
# "--json",
# ".secrets.baseline",
# ]
# )
# Case: fail on unaudited
# detect_secrets.main.main(["audit", "--report", "--fail-on-unaudited", ".secrets.baseline",])
# Case: fail on live only
# detect_secrets.main.main(["audit", "--report", "--fail-on-live", ".secrets.baseline",])
# Case: fail on audited real only
# detect_secrets.main.main(["audit", "--report", "--fail-on-audited-real, ".secrets.baseline","])
Related issue
Supports internal issue 623 in Team-backlog
Description of changes
This is a sub-PR of https://github.com/IBM/detect-secrets/pull/46 (I'm breaking down the reporting PR for easier readability for reviewers).
report.py
, which serves as the entrypoint for the audit reporting functionality.main.py
, so reporting can now be used.usage.py
: moves filename argument to end, updates usage string to be more readable.