-
Notifications
You must be signed in to change notification settings - Fork 6
180 lines (158 loc) · 6.3 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: "build-test"
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
jobs:
build:
# make sure build/ci work properly
runs-on: ubuntu-latest
env:
MAYHEM_TOKEN: ${{ secrets.MAYHEM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
# fetch entire history to compute diffs between jobs
fetch-depth: 0
- run: |
npm install
- run: |
npm run all
test-some-outputs:
# make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# fetch entire history to compute diffs between jobs
fetch-depth: 0
- uses: ./
id: mcode-action
with:
mayhem-url: ${{ secrets.MAYHEM_URL }}
mayhem-token: ${{ secrets.MAYHEM_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
sarif-output: out/sarif/
package: __tests__/lighttpd
args: --image forallsecure/lighttpd:vulnerable --duration 60
- name: Upload SARIF file(s)
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: out/sarif
- name: Print runId (${{ steps.mcode-action.outputs.runId }}) and test it's non-empty
run: |
[ -z "${{ steps.mcode-action.outputs.runId }}" ] && echo "runId was blank!" && exit 1;
echo "The run id was: ${{ steps.mcode-action.outputs.runId }}"
test-all-outputs:
# make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# fetch entire history to compute diffs between jobs
fetch-depth: 0
- uses: ./
id: mcode-action
with:
mayhem-url: ${{ secrets.MAYHEM_URL }}
mayhem-token: ${{ secrets.MAYHEM_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
junit-output: out/junit/
sarif-output: out/sarif/
coverage-output: out/coverage/
package: __tests__/lighttpd
args: --image forallsecure/lighttpd:vulnerable --duration 60
- name: Archive Coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: out/coverage/
if-no-files-found: error
- name: Archive JUnit results
uses: actions/upload-artifact@v4
with:
name: mcode-junit
path: out/junit/
if-no-files-found: error
- name: Upload SARIF file(s)
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: out/sarif
- name: Print runId (${{ steps.mcode-action.outputs.runId }}) and test it's non-empty
run: |
[ -z "${{ steps.mcode-action.outputs.runId }}" ] && echo "runId was blank!" && exit 1;
echo "The run id was: ${{ steps.mcode-action.outputs.runId }}"
test-no-outputs:
# make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# fetch entire history to compute diffs between jobs
fetch-depth: 0
- uses: ./
id: mcode-action
with:
mayhem-url: ${{ secrets.MAYHEM_URL }}
mayhem-token: ${{ secrets.MAYHEM_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
package: __tests__/lighttpd
args: --image forallsecure/lighttpd:vulnerable --duration 60
- name: Print runId (${{ steps.mcode-action.outputs.runId }}) and test it's non-empty
run: |
[ -z "${{ steps.mcode-action.outputs.runId }}" ] && echo "runId was blank!" && exit 1;
echo "The run id was: ${{ steps.mcode-action.outputs.runId }}"
# note: requires human inspection by checking the output and seeing the overrided inputs are picked up.
test-override-inputs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# fetch entire history to compute diffs between jobs
fetch-depth: 0
- uses: ./
id: mcode-action
with:
mayhem-url: ${{ secrets.MAYHEM_URL }}
mayhem-token: ${{ secrets.MAYHEM_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
package: __tests__/lighttpd
args: --image forallsecure/lighttpd:vulnerable --duration 60
# override the default owner which is forallsecure
# the secrets.MAYHEM_TOKEN is this case is owned by mcode-action, which is why we choose that owner here
owner: mcode-action
# override default verbosity which is info (contrary to what the `action.yml` says: https://github.com/ForAllSecure/mcode-action/blob/806778bb4a79d793f678087d0f9f3ff18f9a2d93/src/main.ts#L36)
verbosity: debug
# already covered and skipped in this test: mayhem-token, mayhem-url, github-token, sarif|junit|coverage-output, args
- name: Print runId (${{ steps.mcode-action.outputs.runId }}) and test it's non-empty
run: |
[ -z "${{ steps.mcode-action.outputs.runId }}" ] && echo "runId was blank!" && exit 1;
echo "The run id was: ${{ steps.mcode-action.outputs.runId }}"
test-fail-on-defects:
# make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# fetch entire history to compute diffs between jobs
fetch-depth: 0
- uses: ./
id: mcode-action
continue-on-error: true
with:
mayhem-url: ${{ secrets.MAYHEM_URL }}
mayhem-token: ${{ secrets.MAYHEM_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
package: __tests__/mayhemit
args: --image forallsecure/c-base-executable:latest --duration 60
fail-on-defects: true
# Previous step should fail
- name: Invert success and failure
run: if [[ ${{ steps.mcode-action.outcome }} == "failure" ]]; then exit 0; else exit 1; fi
- name: Print runId (${{ steps.mcode-action.outputs.runId }}) and test it's non-empty
run: |
[ -z "${{ steps.mcode-action.outputs.runId }}" ] && echo "runId was blank!" && exit 1;
echo "The run id was: ${{ steps.mcode-action.outputs.runId }}"