-
Notifications
You must be signed in to change notification settings - Fork 2
112 lines (93 loc) · 4.33 KB
/
verify-container.yml
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: UBI9 Testing Matrix
on:
pull_request:
push:
branches:
- main
jobs:
validate:
name: Validate my profile
runs-on: ubuntu-latest
env:
CHEF_LICENSE: accept-silent
CHEF_LICENSE_KEY: ${{ secrets.SAF_CHEF_LICENSE_KEY }}
KITCHEN_LOCAL_YAML: kitchen.container.yml
LC_ALL: "en_US.UTF-8"
PLATFORM: "ubi9"
HARDENED_CONTAINER_IMAGE: "registry1.dso.mil/ironbank/redhat/ubi/ubi9"
VANILLA_CONTAINER_IMAGE: "registry.access.redhat.com/ubi9/ubi:9.3-1610"
strategy:
matrix:
suite: ["vanilla", "hardened"]
fail-fast: false
steps:
- name: add needed packages
run: |
sudo apt-get update
sudo apt -y install jq
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ secrets.SAF_IRONBANK_REGISTRY }}
username: ${{ secrets.SAF_IRONBANK_CLI_USERNAME }}
password: ${{ secrets.SAF_IRONBANK_CLI_TOKEN }}
- name: Check out repository
uses: actions/checkout@v4
- name: Clone full repository so we can push
run: git fetch --prune --unshallow
- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- name: Confirm git commit SHA output
run: echo ${{ env.COMMIT_SHORT_SHA }}
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1"
- name: Disable ri and rdoc
run: 'echo "gem: --no-ri --no-rdoc" >> ~/.gemrc'
- name: Run Bundle Install
run: bundle install
- name: Installed Inspec
run: bundle exec inspec version
- name: Vendor the Profile
run: bundle exec inspec vendor . --overwrite
- name: Run kitchen test
if: ${{ !contains(steps.commit.outputs.message, 'only-validate-profile') }}
continue-on-error: true
run: bundle exec kitchen test --destroy=always ${{ matrix.suite }}-${{ env.PLATFORM }}
- name: Save our ${{ matrix.suite }} results summary
continue-on-error: true
if: ${{ !contains(steps.commit.outputs.message, 'only-validate-profile') }}
uses: mitre/saf_action@v1.5.2
with:
command_string: "view summary -j -i spec/results/${{ env.PLATFORM }}_${{ matrix.suite }}.json -o spec/results/${{ env.PLATFORM }}_${{ matrix.suite }}-data.json"
- name: Save Test Result JSON
if: ${{ !contains(steps.commit.outputs.message, 'only-validate-profile') }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.PLATFORM }}_${{ matrix.suite }}.json
path: spec/results/
- name: Upload ${{ matrix.suite }} to Heimdall
if: ${{ !contains(steps.commit.outputs.message, 'only-validate-profile') }}
continue-on-error: true
run: |
curl -# -s -F data=@spec/results/${{ env.PLATFORM }}_${{ matrix.suite }}.json -F "filename=${{ env.PLATFORM }}_${{ matrix.suite }}-${{ env.COMMIT_SHORT_SHA }}.json" -F "public=true" -F "evaluationTags=${{ env.COMMIT_SHORT_SHA }},${{ github.repository }},${{ github.workflow }}" -H "Authorization: Api-Key ${{ secrets.SAF_HEIMDALL_UPLOAD_KEY }}" "${{ vars.SAF_HEIMDALL_URL }}/evaluations"
- name: Display our ${{ matrix.suite }} results summary
if: ${{ !contains(steps.commit.outputs.message, 'only-validate-profile') }}
uses: mitre/saf_action@v1.5.2
with:
command_string: "view summary -i spec/results/${{ env.PLATFORM }}_${{ matrix.suite }}.json"
- name: Generate Markdown Summary
continue-on-error: true
id: generate-summary
run: |
cat spec/results/${{ env.PLATFORM }}_${{ matrix.suite }}-data.json | python markdown-summary.py > spec/results/${{ env.PLATFORM }}_${{ matrix.suite }}-markdown-summary.md
cat spec/results/${{ env.PLATFORM }}_${{ matrix.suite }}-markdown-summary.md >> $GITHUB_STEP_SUMMARY
- name: Ensure the scan meets our ${{ matrix.suite }} results threshold
if: ${{ !contains(steps.commit.outputs.message, 'only-validate-profile') }}
uses: mitre/saf_action@v1.5.2
with:
command_string: "validate threshold -i spec/results/${{ env.PLATFORM }}_${{ matrix.suite }}.json -F ubi9_${{ matrix.suite }}.threshold.yml"