-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (55 loc) · 2.21 KB
/
main.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
on:
push:
branches:
- main
workflow_dispatch:
jobs:
harden_validate_mongodb:
name: Harden and Validate MongoDB Container
runs-on: ubuntu-latest
env:
REPORT_TO_HEIMDALL: true
HEIMDALL_URL: https://heimdall-demo.mitre.org/evaluations
HEIMDALL_API_KEY: ${{ secrets.SAF_HEIMDALL_UPLOAD_KEY }}
CA_FILE_BASE64_AA: ${{ secrets.CA_FILE_BASE64_AA }}
CA_FILE_BASE64_AB: ${{ secrets.CA_FILE_BASE64_AB }}
CERTIFICATE_KEY_FILE: ${{ secrets.CERTIFICATE_KEY_FILE }}
INSPEC_INPUTS: ${{ secrets.INSPEC_INPUTS }}
steps:
- name: Add Dependencies
run: |
npm install -g @mitre/saf
curl -L https://omnitruck.cinc.sh/install.sh | sudo bash -s -- -P cinc-auditor
- name: Clone Repository
uses: actions/checkout@v4
- name: Move Certificates and Input file
shell: bash
run: |
echo "${{ env.CA_FILE_BASE64_AA }}" > CA_FILE
echo "${{ env.CA_FILE_BASE64_AB }}" >> CA_FILE
base64 --decode CA_FILE > certificates/dod_CAs.pem
echo "${{ env.CERTIFICATE_KEY_FILE }}" > certificates/mongodb.pem
echo "${{ env.INSPEC_INPUTS }}" > spec/mongo-inspec-profile/inputs.yml
- name: Run Packer Hardening
run: |
packer init mongo-hardening.pkr.hcl
packer build mongo-hardening.pkr.hcl
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Tag and Push Docker Image
run: |
docker tag mongo-hardened:latest ghcr.io/${{ github.repository_owner }}/mongo-hardened:latest
docker push ghcr.io/${{ github.repository_owner }}/mongo-hardened:latest
- name: Run Packer Validation
run: |
packer build -var 'report={"report_to_heimdall":"${{ env.REPORT_TO_HEIMDALL }}","heimdall_url":"${{ env.HEIMDALL_URL }}","heimdall_api_key":"${{ env.HEIMDALL_API_KEY }}"}' mongo-validate.pkr.hcl
docker ps -a
- name: Save Scan Artifacts
uses: actions/upload-artifact@v4
with:
path: reports/*.json
if: always()