Skip to content

Commit 8117153

Browse files
bluesentinelsecMichael Long
andauthored
add --out-scan-markdown CLI arg (#36)
* add --out-scan-markdown CLI arg * change --out-scan-markdown to string from bool * pass --display-vuln-findings as string * write markdown report to disk --------- Co-authored-by: Michael Long <mlongii@amazon.com>
1 parent c715a2b commit 8117153

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

action.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ inputs:
1313
default: './'
1414

1515
display_vulnerability_findings:
16-
description: 'If true, the action will display detailed vulnerability findings in the action summary page; see here for an example: https://github.com/aws-actions/vulnerability-scan-github-action-for-amazon-inspector/actions/runs/8742638284/attempts/1#summary-23991378549'
16+
description: 'If set to "enabled", the action will display detailed vulnerability findings in the action summary page; see here for an example: https://github.com/aws-actions/vulnerability-scan-github-action-for-amazon-inspector/actions/runs/8742638284/attempts/1#summary-23991378549'
1717
required: True
18-
default: False
18+
default: "disabled"
1919

2020
output_sbom_path:
2121
description: "The destination file path for the generated SBOM."
@@ -32,6 +32,11 @@ inputs:
3232
required: False
3333
default: 'inspector_scan_${{ github.run_id }}.csv'
3434

35+
output_inspector_scan_path_markdown:
36+
description: "The destination file path for Inspector's vulnerability scan (CSV format)."
37+
required: False
38+
default: 'inspector_scan_${{ github.run_id }}.md'
39+
3540

3641
sbomgen_version:
3742
description: "The inspector-sbomgen version you wish to use for SBOM generation. See here for more info: https://docs.aws.amazon.com/inspector/latest/user/sbom-generator.html"
@@ -113,6 +118,7 @@ runs:
113118
- --out-sbom=${{ inputs.output_sbom_path}}
114119
- --out-scan=${{ inputs.output_inspector_scan_path }}
115120
- --out-scan-csv=${{ inputs.output_inspector_scan_path_csv }}
121+
- --out-scan-markdown=${{ inputs.output_inspector_scan_path_markdown }}
116122
- --sbomgen-version=${{ inputs.sbomgen_version }}
117123
- --thresholds
118124
- --critical=${{ inputs.critical_threshold }}

entrypoint/entrypoint/cli.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ def init(sys_argv=None) -> argparse.Namespace:
1313
help='The artifact you would like to scan with Amazon Inspector. Valid choices are "repository", "container", "binary", or "archive".')
1414
parser.add_argument("--artifact-path", type=str, default="./",
1515
help='The path to the artifact you would like to scan with Amazon Inspector. If scanning a container image, you must provide a value that follows the docker pull convention: "NAME[:TAG|@DIGEST]", for example, "alpine:latest", or a path to an image exported as tarball using "docker save".')
16+
parser.add_argument("--display-vuln-findings", type=str, default="disabled",
17+
help="If set, this program will present Inspector findings in the GitHub Actions job summary page")
1618
parser.add_argument("--out-sbom", type=str, default="sbom.json",
1719
help="The destination file path for the generated SBOM.")
1820
parser.add_argument("--out-scan", type=str, default="inspector-scan.json",
1921
help="The destination file path for Inspector's vulnerability scan in JSON format.")
20-
parser.add_argument("--out-scan-csv", type=str, default="/tmp/scan.csv",
22+
parser.add_argument("--out-scan-csv", type=str, default="inspector-scan.csv",
2123
help="The destination file path for Inspector's vulnerability scan in CSV format.")
24+
parser.add_argument("--out-scan-markdown", type=str, default="inspector-scan.md",
25+
help="The destination file path for Inspector's vulnerability scan results in markdown format.")
2226
parser.add_argument("--verbose", action="store_true", help="Enables verbose console logging.")
2327
parser.add_argument("--sbomgen-version", type=str, default="latest",
2428
help="The inspector-sbomgen version you wish to use for SBOM generation.")
@@ -42,8 +46,6 @@ def init(sys_argv=None) -> argparse.Namespace:
4246
help="Specifies one or more files and/or directories that should NOT be inventoried.")
4347
parser.add_argument("--timeout", type=str, default="600",
4448
help="The amount of time in seconds that inspector-sbomgne will run. When this timeout is exceeded, sbomgen will gracefully conclude and present any findings discovered up to that point.")
45-
parser.add_argument("--display-vuln-findings", action='store_true',
46-
help="If toggled, this program will present Inspector findings in the GitHub Actions job summary page")
4749

4850
args = ""
4951
if sys_argv:

entrypoint/entrypoint/orchestrator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,13 @@ def execute(args) -> int:
334334
lows=lows,
335335
others=others)
336336

337-
if args.display_vuln_findings:
337+
if args.display_vuln_findings == "enabled":
338338
logging.info("posting markdown to job summary")
339339
converter.post_github_step_summary(markdown)
340340

341+
with open(args.out_scan_markdown, "w") as f:
342+
f.write(markdown)
343+
341344
is_exceeded = exceeds_threshold(criticals, args.critical,
342345
highs, args.high,
343346
mediums, args.medium,

0 commit comments

Comments
 (0)