-
Notifications
You must be signed in to change notification settings - Fork 26
84 lines (71 loc) · 2.69 KB
/
cfn_scan.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# Licensed under the Apache License, Version 2.0 https://aws.amazon.com/apache-2-0/
name: CloudFormation Code Scanning
on: [push, pull_request]
permissions:
contents: read
jobs:
###################
# CFN Lint Checks #
###################
cfn-lint:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
runs-on: ubuntu-latest
env:
CFN_LINT_REPORT_FILE: cfn_lint_report.sarif
steps:
- name: Checkout the branch
uses: actions/checkout@v3
- name: Setup cfn-lint with latest version
uses: scottbrenner/cfn-lint-action@v2
with:
command: cfn-lint --version
- name: Run cfn-lint and generate report
run: |-
cfn-lint --config-file .github/conf/cfn_lint.yaml \
--format sarif --output-file ${{ env.CFN_LINT_REPORT_FILE }} \
deployment/dev_environment_cloud9/**/*.yaml \
deployment/init_grid/**/*.yaml
continue-on-error: true
- name: Upload cfn-lint scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: success() || failure()
with:
sarif_file: "${{ env.CFN_LINT_REPORT_FILE }}"
- name: Save report results as an artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.CFN_LINT_REPORT_FILE }}
path: ${{ env.CFN_LINT_REPORT_FILE }}
##################
# CFN Nag Checks #
##################
cfn_nag:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
runs-on: ubuntu-latest
env:
CFN_NAG_REPORT_FILE: cfn_nag_report.sarif
steps:
- name: Checkout the branch
uses: actions/checkout@v3
- name: Run cfn_nag and generate report
uses: stelligent/cfn_nag@master
with:
input_path: deployment/
extra_args: '-g -o sarif' #-t '..*\/(cfn|cloudformation)\/..*\.yaml' # This flag doesnt seem to be working.
output_path: ${{ env.CFN_NAG_REPORT_FILE }}
- name: Upload cfn_nag scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: success() || failure()
with:
sarif_file: "${{ env.CFN_NAG_REPORT_FILE }}"
- name: Save report results as an artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.CFN_NAG_REPORT_FILE }}
path: ${{ env.CFN_NAG_REPORT_FILE }}