Skip to content

Commit ab71619

Browse files
authored
feat(ci/cd): Add scanning for M365 Image and Terraform Config (#10)
1 parent 6daeb66 commit ab71619

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

.github/workflows/m365_image_build.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ env:
1616

1717
jobs:
1818
build:
19+
name: Build
20+
runs-on: windows-latest
21+
# This condition prevents duplicate runs.
22+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
1923
# based on https://github.com/orgs/community/discussions/26253#discussioncomment-6745038
2024
# intent is to run on current ref, unless this is a scheduled run, then run on list defined below
2125
strategy:
@@ -29,7 +33,6 @@ jobs:
2933
- { scheduled: false }
3034
include:
3135
- ref: ${{ github.head_ref || github.ref_name }}
32-
runs-on: windows-latest
3336
permissions:
3437
contents: read
3538
packages: write
@@ -98,6 +101,7 @@ jobs:
98101
99102
docker build $docker_args m365/image
100103
echo "digest=$(docker images --no-trunc --quiet $Env:IMAGE.ToLower())" >> $Env:GITHUB_OUTPUT
104+
echo "image=$($Env:IMAGE.ToLower())" >> $Env:GITHUB_OUTPUT
101105
if ($Env:PUSH -eq "true") {
102106
docker push $Env:IMAGE.ToLower() --all-tags
103107
}
@@ -122,3 +126,25 @@ jobs:
122126
cosign sign --yes "$_@$digest"
123127
}
124128
exit 0
129+
outputs:
130+
image: ${{ steps.build-and-push.outputs.image }}
131+
m365-scan:
132+
name: Scan
133+
if: github.ref == 'refs/heads/main'
134+
permissions:
135+
security-events: write
136+
needs: build
137+
runs-on: ubuntu-latest
138+
steps:
139+
- name: Run Trivy vulnerability scanner
140+
uses: aquasecurity/trivy-action@0.28.0
141+
with:
142+
image-ref: ${{ needs.build.outputs.image }}:latest
143+
format: 'sarif'
144+
output: 'trivy-results.sarif'
145+
146+
- name: Upload Trivy scan results to GitHub Security tab
147+
uses: github/codeql-action/upload-sarif@v3
148+
with:
149+
sarif_file: 'trivy-results.sarif'
150+
category: m365-image
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Terraform Scan
2+
permissions:
3+
security-events: write
4+
on:
5+
push:
6+
branches: [ "*" ]
7+
pull_request:
8+
branches: [ "main" ]
9+
jobs:
10+
scan:
11+
name: Scan
12+
runs-on: ubuntu-latest
13+
# This condition prevents duplicate runs.
14+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Run Trivy vulnerability scanner in IaC mode
20+
uses: aquasecurity/trivy-action@0.28.0
21+
with:
22+
scan-type: 'config'
23+
hide-progress: true
24+
format: 'sarif'
25+
output: 'trivy-results.sarif'
26+
exit-code: '0'
27+
severity: 'CRITICAL,HIGH,MEDIUM'
28+
- name: Upload Trivy scan results to GitHub Security tab
29+
uses: github/codeql-action/upload-sarif@v3
30+
with:
31+
sarif_file: 'trivy-results.sarif'
32+
category: terraform

0 commit comments

Comments
 (0)