Skip to content

Commit c1fb5ff

Browse files
committed
add cfn_nag in github static checking workflow
also regroup black and ruff under a single python job
1 parent 04fe052 commit c1fb5ff

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

.github/workflows/static-checking.yml

+19-16
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,38 @@ permissions:
99
contents: read
1010

1111
jobs:
12-
cfnlint:
12+
cfn:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v3
1616
- name: Set up Python 3.11
1717
uses: actions/setup-python@v4
1818
with:
1919
python-version: 3.11
20+
- name: Set up Ruby 3.2
21+
uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: 3.2
2024
- name: install requirements
2125
run: |
2226
python -m pip install --upgrade pip
2327
python -m pip install cfn-lint
28+
gem install cfn-nag
2429
- name: cfn-lint
2530
run: |
2631
find . -not \( -path ./sdlf-utils -prune \) -type f -name '*.yaml' -print0 \
2732
| xargs -0 cfn-lint
28-
black:
33+
- name: cfn-nag
34+
run: |
35+
cat <<EOT >> .cfn-nag-deny-list.yml
36+
- id: W61
37+
reason: |-
38+
Certificates are handled by customers downstream, see https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-encryption-enable.html#emr-encryption-certificates
39+
This is ignored only during CI as we want customers to be aware they need to update the security configuration should they choose to use it.
40+
EOT
41+
find . -not \( -path ./sdlf-utils -prune -o -type f -name 'template-glue-job.yaml' -o -type f -name 'template-lambda-layer.yaml' \) -type f -name '*.yaml' -print0 \
42+
| xargs -0 -L 1 cfn_nag_scan --fail-on-warnings --ignore-fatal --deny-list-path .cfn-nag-deny-list.yml --input-path
43+
python:
2944
runs-on: ubuntu-latest
3045
steps:
3146
- uses: actions/checkout@v3
@@ -36,21 +51,9 @@ jobs:
3651
- name: install requirements
3752
run: |
3853
python -m pip install --upgrade pip
39-
python -m pip install black
54+
python -m pip install black ruff
4055
- name: black
4156
run: black --check .
42-
ruff:
43-
runs-on: ubuntu-latest
44-
steps:
45-
- uses: actions/checkout@v3
46-
- name: Set up Python 3.11
47-
uses: actions/setup-python@v4
48-
with:
49-
python-version: 3.11
50-
- name: install requirements
51-
run: |
52-
python -m pip install --upgrade pip
53-
python -m pip install ruff
5457
- name: ruff
5558
run: ruff check .
5659
shellcheck:
@@ -64,4 +67,4 @@ jobs:
6467
- name: shellcheck
6568
run: |
6669
find . -not \( -path ./sdlf-utils -prune \) -type f \( -name '*.sh' -o -name '*.bash' -o -name '*.ksh' \) -print0 \
67-
| xargs -0 shellcheck -x --format gcc
70+
| xargs -0 shellcheck -x --format gcc

validate.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ find . -not \( -path ./sdlf-utils -prune \) -type f \( -name '*.sh' -o -name '*.
1414
# cloudformation
1515
find . -not \( -path ./sdlf-utils -prune \) -type f -name '*.yaml' -print0 \
1616
| xargs -0 cfn-lint
17-
find . -not \( -path ./sdlf-utils -prune \) -type f -name '*.yaml' -print0 \
18-
| xargs -0 -L 1 cfn_nag_scan --deny-list-path .cfn-nag-deny-list.yml --input-path
17+
## unfortunately cfn_nag doesn't support fn::foreach so we exclude files using it: https://github.com/stelligent/cfn_nag/issues/621
18+
find . -not \( -path ./sdlf-utils -prune -o -type f -name 'template-glue-job.yaml' -o -type f -name 'template-lambda-layer.yaml' \) -type f -name '*.yaml' -print0 \
19+
| xargs -0 -L 1 cfn_nag_scan --fail-on-warnings --ignore-fatal --deny-list-path .cfn-nag-deny-list.yml --input-path

0 commit comments

Comments
 (0)