-
Notifications
You must be signed in to change notification settings - Fork 0
2370 lines (2288 loc) · 92.3 KB
/
Copy pathvulnetix-scanners.yml
File metadata and controls
2370 lines (2288 loc) · 92.3 KB
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Managed by `vulnetix gha setup`.
# Re-run `vulnetix gha setup <tool>` to add a scanner; edits here are overwritten.
#
# Each scanner runs independently and uploads its report as a workflow
# artifact. The publish job then hands every artifact to Vulnetix in one go,
# attributed to the tool that produced it.
name: Third-Party Scanners
on:
schedule:
- cron: '47 11 * * 3'
workflow_dispatch:
permissions:
contents: read
jobs:
bandit:
name: Bandit (Python SAST)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up uv
continue-on-error: true
uses: astral-sh/setup-uv@v6
- name: Run Bandit
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
if ! command -v uvx >/dev/null 2>&1; then
curl -LsSf https://astral.sh/uv/install.sh | sh >/dev/null 2>&1 || true
export PATH="$HOME/.local/bin:$PATH"
fi
if ! command -v uvx >/dev/null 2>&1; then
echo '::warning::uv is unavailable on this runner; skipping'
exit 0
fi
if ! find . -path ./.git -prune -o -type f -name '*.py' -print | head -n 1 | grep -q .; then
echo '::notice::no Python files found; skipping Bandit'
exit 0
fi
uvx --from 'bandit[sarif]' bandit -r . -f sarif -o bandit.sarif || true
if ! jq -e '.version and (.runs | type == "array")' bandit.sarif >/dev/null 2>&1; then
echo '::warning::bandit produced no valid SARIF; dropping the artifact'
rm -f bandit.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: bandit
path: bandit.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
bearer:
name: Bearer (SAST)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Run Bearer
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
set -uo pipefail
curl -sfL https://raw.githubusercontent.com/Bearer/bearer/main/contrib/install.sh | sh -s -- -b "$HOME/.local/bin" >/dev/null 2>&1 || true
export PATH="$HOME/.local/bin:$PATH"
if ! command -v bearer >/dev/null 2>&1; then
echo '::warning::bearer could not be installed on this runner; skipping'
exit 0
fi
# --exit-code 0 because a finding is a successful scan, not a broken one.
bearer scan . --format sarif --output bearer.sarif --exit-code 0 --quiet 2>bearer.stderr || true
if ! jq -e '.version and (.runs | type == "array")' bearer.sarif >/dev/null 2>&1; then
echo '::warning::bearer produced no valid SARIF; dropping the artifact'
rm -f bearer.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: bearer
path: bearer.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
brakeman:
name: Brakeman (Ruby on Rails SAST)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up Ruby
continue-on-error: true
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
- name: Run Brakeman
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
if [ ! -f Gemfile ] || ! grep -E 'rails|railties' Gemfile Gemfile.lock >/dev/null 2>&1; then
echo '::notice::no Rails app detected; skipping Brakeman'
exit 0
fi
gem install brakeman
brakeman -f sarif -o brakeman.sarif || true
if ! jq -e '.version and (.runs | type == "array")' brakeman.sarif >/dev/null 2>&1; then
echo '::warning::brakeman produced no valid SARIF; dropping the artifact'
rm -f brakeman.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: brakeman
path: brakeman.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
cdxgen:
name: cdxgen (multi-ecosystem SBOM)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up Node.js
continue-on-error: true
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Run cdxgen
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
if ! find . -maxdepth 4 -type f \( -name package-lock.json -o -name go.mod -o -name requirements.txt -o -name pyproject.toml -o -name pom.xml -o -name build.gradle -o -name Cargo.lock -o -name composer.lock -o -name Gemfile.lock -o -name '*.csproj' \) -print | head -n 1 | grep -q .; then
echo '::notice::no supported package manifest found; skipping cdxgen'
exit 0
fi
npx --yes @cyclonedx/cdxgen -o cdxgen.cdx.json . || true
if ! jq -e '.bomFormat == "CycloneDX"' cdxgen.cdx.json >/dev/null 2>&1; then
echo '::warning::cdxgen produced no valid CycloneDX JSON; dropping the artifact'
rm -f cdxgen.cdx.json
fi
- uses: actions/upload-artifact@v6
with:
name: cdxgen
path: cdxgen.cdx.json
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
checkov:
name: Checkov (IaC)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up uv
continue-on-error: true
uses: astral-sh/setup-uv@v6
- name: Run Checkov
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
if ! command -v uvx >/dev/null 2>&1; then
curl -LsSf https://astral.sh/uv/install.sh | sh >/dev/null 2>&1 || true
export PATH="$HOME/.local/bin:$PATH"
fi
if ! command -v uvx >/dev/null 2>&1; then
echo '::warning::uv is unavailable on this runner; skipping'
exit 0
fi
uvx --from checkov checkov -d . -o sarif --output-file-path . --soft-fail || true
- uses: actions/upload-artifact@v6
with:
name: checkov
path: results.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
clippy:
name: Rust Clippy (SAST)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Run Clippy
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
set -uo pipefail
rustup component add clippy
cargo install clippy-sarif sarif-fmt
# cargo clippy exits non-zero when it emits warnings, which is a successful run.
cargo clippy --all-targets --all-features --message-format=json \
| clippy-sarif >clippy.sarif 2>clippy.stderr
if ! jq -e '.version and (.runs | type == "array")' clippy.sarif >/dev/null 2>&1; then
echo "::warning::clippy produced no valid SARIF; dropping the artifact"
sed -n '1,20p' clippy.stderr
rm -f clippy.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: clippy
path: clippy.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
cppcheck:
name: Cppcheck (C/C++ SAST)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Run Cppcheck
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
if ! find . -path ./.git -prune -o -type f -print | grep -E '\.(c|cc|cpp|h|hpp)$' | head -n 1 | grep -q .; then
echo '::notice::no C/C++ files found; skipping Cppcheck'
exit 0
fi
# Resolve how to become root, or do without it.
#
# The AWS runner pools grant exactly one sudo rule — writing the busy/idle
# heartbeat — because general NOPASSWD sudo would hand the instance role to
# every workflow on the box through IMDS. A blind `sudo` there does not fail
# with "permission denied": it blocks on a password prompt and dies with
# "sudo: a terminal is required to read the password".
SUDO=""
if [ "$(id -u)" -ne 0 ]; then
if sudo -n true 2>/dev/null; then
SUDO="sudo -n"
fi
fi
if [ -n "$SUDO" ] || [ "$(id -u)" -eq 0 ]; then
if command -v apt-get >/dev/null 2>&1; then
$SUDO apt-get update -qq && $SUDO apt-get install -y -qq cppcheck || true
elif command -v dnf >/dev/null 2>&1; then
$SUDO dnf install -y -q cppcheck || true
elif command -v apk >/dev/null 2>&1; then
$SUDO apk add --no-cache cppcheck || true
fi
fi
if ! command -v cppcheck >/dev/null 2>&1; then
echo '::warning::cppcheck could not be installed on this runner; skipping'
exit 0
fi
cppcheck --enable=warning,style,performance,portability --output-format=sarif --output-file=cppcheck.sarif . || true
if ! jq -e '.version and (.runs | type == "array")' cppcheck.sarif >/dev/null 2>&1; then
echo '::warning::cppcheck produced no valid SARIF; dropping the artifact'
rm -f cppcheck.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: cppcheck
path: cppcheck.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
cyclonedx-go:
name: CycloneDX Go SBOM
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up Go
continue-on-error: true
uses: actions/setup-go@v6
with:
go-version: stable
- name: Generate Go CycloneDX SBOM
continue-on-error: true
env:
GO_MODULE_PATTERN: '${{ vars.GO_MODULE_PATTERN }}'
GO_MODULE_TOKEN: '${{ secrets.PACKAGES_TOKEN }}'
shell: bash --noprofile --norc {0}
run: |
if [ -n "${GO_MODULE_TOKEN:-}" ]; then
go env -w GOPRIVATE="${GO_MODULE_PATTERN:-github.com/$(echo "${GITHUB_REPOSITORY:-}" | cut -d/ -f1)/*}"
git config --global url."https://x-access-token:${GO_MODULE_TOKEN}@github.com/".insteadOf "https://github.com/"
fi
if [ ! -f go.mod ]; then
echo '::notice::no go.mod found; skipping CycloneDX Go'
exit 0
fi
go install github.com/CycloneDX/cyclonedx-gomod/cmd/cyclonedx-gomod@latest
cyclonedx-gomod app -json -output cyclonedx-go.cdx.json . || true
if ! jq -e '.bomFormat == "CycloneDX"' cyclonedx-go.cdx.json >/dev/null 2>&1; then
echo '::warning::cyclonedx go produced no valid CycloneDX JSON; dropping the artifact'
rm -f cyclonedx-go.cdx.json
fi
- uses: actions/upload-artifact@v6
with:
name: cyclonedx-go
path: cyclonedx-go.cdx.json
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
cyclonedx-maven:
name: CycloneDX Maven (SBOM)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up Java
continue-on-error: true
uses: actions/setup-java@v4
with:
cache: maven
distribution: temurin
java-version: 17
- name: Generate Maven CycloneDX SBOM
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
set -uo pipefail
if [ ! -f pom.xml ]; then
echo '::notice::no pom.xml found; skipping CycloneDX Maven'
exit 0
fi
mvn -B -q org.cyclonedx:cyclonedx-maven-plugin:2.9.1:makeAggregateBom \
-DoutputFormat=json -DoutputName=cyclonedx-maven 2>cyclonedx-maven.stderr || true
found=$(find . -name 'cyclonedx-maven.json' -print -quit)
if [ -n "$found" ]; then
cp "$found" cyclonedx-maven.cdx.json
fi
if ! jq -e '.bomFormat == "CycloneDX"' cyclonedx-maven.cdx.json >/dev/null 2>&1; then
echo '::warning::cyclonedx maven produced no valid CycloneDX JSON; dropping the artifact'
rm -f cyclonedx-maven.cdx.json
fi
- uses: actions/upload-artifact@v6
with:
name: cyclonedx-maven
path: cyclonedx-maven.cdx.json
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
cyclonedx-node:
name: CycloneDX npm SBOM
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up Node.js
continue-on-error: true
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Generate npm CycloneDX SBOM
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
if [ ! -f package-lock.json ]; then
echo '::notice::no package-lock.json found; skipping CycloneDX npm'
exit 0
fi
npm ci
npx --yes @cyclonedx/cyclonedx-npm --omit dev --flatten-components --output-format JSON --output-file cyclonedx-node.cdx.json || true
if ! jq -e '.bomFormat == "CycloneDX"' cyclonedx-node.cdx.json >/dev/null 2>&1; then
echo '::warning::cyclonedx npm produced no valid CycloneDX JSON; dropping the artifact'
rm -f cyclonedx-node.cdx.json
fi
- uses: actions/upload-artifact@v6
with:
name: cyclonedx-node
path: cyclonedx-node.cdx.json
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
cyclonedx-php:
name: CycloneDX PHP SBOM
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 30
steps:
- uses: actions/checkout@v5
- name: Detect PHP setup capability
id: php-setup
shell: bash --noprofile --norc {0}
run: |
# shivammathur/setup-php shells out to sudo. The runner pools grant one
# narrow sudo rule, so on those runners the action blocks forever on a
# password prompt and the job dies at its timeout-minutes cap having done
# nothing. Only run it where sudo is non-interactive.
if sudo -n true >/dev/null 2>&1; then
echo 'run=true' >>"$GITHUB_OUTPUT"
else
echo 'run=false' >>"$GITHUB_OUTPUT"
echo '::notice::passwordless sudo is unavailable on this runner; using the PHP already installed'
fi
- name: Set up PHP
if: steps.php-setup.outputs.run == 'true'
continue-on-error: true
timeout-minutes: 5
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
tools: composer
- name: Generate PHP CycloneDX SBOM
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
if [ ! -f composer.lock ]; then
echo '::notice::no composer.lock found; skipping CycloneDX PHP'
exit 0
fi
composer require --dev cyclonedx/cyclonedx-php-composer || true
composer CycloneDX:make-sbom --output-format=JSON --output-file=cyclonedx-php.cdx.json || true
if ! jq -e '.bomFormat == "CycloneDX"' cyclonedx-php.cdx.json >/dev/null 2>&1; then
echo '::warning::cyclonedx php produced no valid CycloneDX JSON; dropping the artifact'
rm -f cyclonedx-php.cdx.json
fi
- uses: actions/upload-artifact@v6
with:
name: cyclonedx-php
path: cyclonedx-php.cdx.json
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
cyclonedx-ruby:
name: CycloneDX Ruby SBOM
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up Ruby
continue-on-error: true
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby
- name: Generate Ruby CycloneDX SBOM
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
if [ ! -f Gemfile.lock ]; then
echo '::notice::no Gemfile.lock found; skipping CycloneDX Ruby'
exit 0
fi
gem install cyclonedx-ruby
cyclonedx-ruby --path . --output cyclonedx-ruby.cdx.json --format JSON || true
if ! jq -e '.bomFormat == "CycloneDX"' cyclonedx-ruby.cdx.json >/dev/null 2>&1; then
echo '::warning::cyclonedx ruby produced no valid CycloneDX JSON; dropping the artifact'
rm -f cyclonedx-ruby.cdx.json
fi
- uses: actions/upload-artifact@v6
with:
name: cyclonedx-ruby
path: cyclonedx-ruby.cdx.json
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
cyclonedx-rust:
name: CycloneDX Rust SBOM
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Generate Rust CycloneDX SBOM
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
if [ ! -f Cargo.lock ] && [ ! -f Cargo.toml ]; then
echo '::notice::no Cargo project found; skipping CycloneDX Rust'
exit 0
fi
cargo install cargo-cyclonedx
cargo cyclonedx --format json --output-cdx cyclonedx-rust.cdx.json || true
if ! jq -e '.bomFormat == "CycloneDX"' cyclonedx-rust.cdx.json >/dev/null 2>&1; then
echo '::warning::cyclonedx rust produced no valid CycloneDX JSON; dropping the artifact'
rm -f cyclonedx-rust.cdx.json
fi
- uses: actions/upload-artifact@v6
with:
name: cyclonedx-rust
path: cyclonedx-rust.cdx.json
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
detect-secrets:
name: detect-secrets (secrets)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up uv
continue-on-error: true
uses: astral-sh/setup-uv@v6
- name: Run detect-secrets
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
# The converter below runs under uv rather than whatever `python3` happens to
# be on the runner. uv carries its own interpreter, so the script runs the same
# way on every image, cannot be broken by a system Python that is missing or
# externally managed, and cannot install anything into one.
if ! command -v uv >/dev/null 2>&1; then
curl -LsSf https://astral.sh/uv/install.sh | sh >/dev/null 2>&1 || true
export PATH="$HOME/.local/bin:$PATH"
fi
if ! command -v uv >/dev/null 2>&1; then
echo '::warning::uv is unavailable on this runner; cannot convert the report'
exit 0
fi
if ! command -v uvx >/dev/null 2>&1; then
curl -LsSf https://astral.sh/uv/install.sh | sh >/dev/null 2>&1 || true
export PATH="$HOME/.local/bin:$PATH"
fi
if ! command -v uvx >/dev/null 2>&1; then
echo '::warning::uv is unavailable on this runner; skipping'
exit 0
fi
if [ -f .secrets.baseline ]; then
uvx --from detect-secrets detect-secrets scan --baseline .secrets.baseline >detect-secrets-results.json || true
else
uvx --from detect-secrets detect-secrets scan --all-files >detect-secrets-results.json || true
fi
uv run --no-project --python 3.12 python - <<'PY'
import json
import os
sarif = {
"$schema": "https://json.schemastore.org/sarif-2.1.0.json",
"version": "2.1.0",
"runs": [{
"tool": {
"driver": {
"name": "detect-secrets",
"informationUri": "https://github.com/Yelp/detect-secrets",
"rules": [],
}
},
"results": [],
}],
}
rules_seen = set()
def to_int(value):
try:
return max(1, int(value))
except (TypeError, ValueError):
return 1
def add_rule(rule_id, plugin_name):
if rule_id in rules_seen:
return
sarif["runs"][0]["tool"]["driver"]["rules"].append({
"id": rule_id,
"shortDescription": {"text": f"Potential leaked credential detected ({plugin_name})"},
"defaultConfiguration": {"level": "error"},
})
rules_seen.add(rule_id)
if os.path.exists("detect-secrets-results.json") and os.path.getsize("detect-secrets-results.json") > 0:
with open("detect-secrets-results.json", "r", encoding="utf-8") as fh:
data = json.load(fh)
results = data.get("results") or {}
for file_path, findings in results.items():
for finding in findings:
plugin_name = str(finding.get("type") or "detect-secrets")
rule_id = plugin_name.replace(" ", "-") or "detect-secrets"
add_rule(rule_id, plugin_name)
hashed_secret = finding.get("hashed_secret")
message = f"Potential secret exposed. Type: {plugin_name}."
if hashed_secret:
message += f" Hashed representation: {hashed_secret}"
sarif["runs"][0]["results"].append({
"ruleId": rule_id,
"level": "error",
"message": {"text": message},
"locations": [{
"physicalLocation": {
"artifactLocation": {"uri": file_path},
"region": {"startLine": to_int(finding.get("line_number"))},
}
}],
})
with open("detect-secrets-results.sarif", "w", encoding="utf-8") as fh:
json.dump(sarif, fh, indent=2)
PY
if ! jq -e '.version and (.runs | type == "array")' detect-secrets-results.sarif >/dev/null 2>&1; then
echo '::warning::detect-secrets produced no valid SARIF; dropping the artifact'
rm -f detect-secrets-results.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: detect-secrets
path: detect-secrets-results.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
detekt:
name: detekt (Kotlin SAST)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up Java
continue-on-error: true
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Run detekt
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
set -uo pipefail
if ! find . -path ./.git -prune -o -type f -name '*.kt' -print | head -n 1 | grep -q .; then
echo '::notice::no Kotlin files found; skipping detekt'
exit 0
fi
version=1.23.8
curl -fsSL -o detekt-cli.zip "https://github.com/detekt/detekt/releases/download/v${version}/detekt-cli-${version}.zip" || true
if [ ! -s detekt-cli.zip ]; then
echo '::warning::could not download detekt; skipping'
exit 0
fi
unzip -q -o detekt-cli.zip
# detekt exits 2 when it reports issues, which is a successful run.
"detekt-cli-${version}/bin/detekt-cli" --input . --report sarif:detekt.sarif 2>detekt.stderr || true
if ! jq -e '.version and (.runs | type == "array")' detekt.sarif >/dev/null 2>&1; then
echo '::warning::detekt produced no valid SARIF; dropping the artifact'
rm -f detekt.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: detekt
path: detekt.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
dockle:
name: Dockle (container image)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up Go
continue-on-error: true
uses: actions/setup-go@v6
with:
go-version: stable
- name: Run Dockle
continue-on-error: true
env:
GO_MODULE_PATTERN: '${{ vars.GO_MODULE_PATTERN }}'
GO_MODULE_TOKEN: '${{ secrets.PACKAGES_TOKEN }}'
shell: bash --noprofile --norc {0}
run: |
if [ -n "${GO_MODULE_TOKEN:-}" ]; then
go env -w GOPRIVATE="${GO_MODULE_PATTERN:-github.com/$(echo "${GITHUB_REPOSITORY:-}" | cut -d/ -f1)/*}"
git config --global url."https://x-access-token:${GO_MODULE_TOKEN}@github.com/".insteadOf "https://github.com/"
fi
if [ ! -f Dockerfile ] && [ ! -f Containerfile ]; then
echo '::notice::no Dockerfile or Containerfile found; skipping Dockle'
exit 0
fi
dockerfile=Dockerfile
if [ -f Containerfile ]; then
dockerfile=Containerfile
fi
image="vulnetix-dockle:${GITHUB_SHA:-local}"
docker build -f "$dockerfile" -t "$image" .
go install github.com/goodwithtech/dockle/cmd/dockle@latest
dockle --format sarif --output dockle.sarif "$image" || true
if ! jq -e '.version and (.runs | type == "array")' dockle.sarif >/dev/null 2>&1; then
echo '::warning::dockle produced no valid SARIF; dropping the artifact'
rm -f dockle.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: dockle
path: dockle.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
eslint:
name: ESLint (JavaScript lint)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up Node.js
continue-on-error: true
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Run ESLint
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
if [ ! -f package.json ]; then
echo '::notice::no package.json found; skipping ESLint'
exit 0
fi
if ! ls eslint.config.* .eslintrc .eslintrc.* >/dev/null 2>&1; then
echo '::notice::no ESLint config found; skipping ESLint'
exit 0
fi
if [ -f package-lock.json ]; then
npm ci
else
npm install --no-audit --no-fund
fi
npm install --no-audit --no-fund --no-save @microsoft/eslint-formatter-sarif
npx eslint -f @microsoft/eslint-formatter-sarif -o eslint.sarif . || true
if ! jq -e '.version and (.runs | type == "array")' eslint.sarif >/dev/null 2>&1; then
echo '::warning::eslint produced no valid SARIF; dropping the artifact'
rm -f eslint.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: eslint
path: eslint.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
flawfinder:
name: Flawfinder (C/C++ SAST)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up uv
continue-on-error: true
uses: astral-sh/setup-uv@v6
- name: Run Flawfinder
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
if ! command -v uvx >/dev/null 2>&1; then
curl -LsSf https://astral.sh/uv/install.sh | sh >/dev/null 2>&1 || true
export PATH="$HOME/.local/bin:$PATH"
fi
if ! command -v uvx >/dev/null 2>&1; then
echo '::warning::uv is unavailable on this runner; skipping'
exit 0
fi
if ! find . -path ./.git -prune -o -type f -print | grep -E '\.(c|cc|cpp|h|hpp)$' | head -n 1 | grep -q .; then
echo '::notice::no C/C++ files found; skipping Flawfinder'
exit 0
fi
uvx --from flawfinder flawfinder --sarif . >flawfinder.sarif 2>flawfinder.stderr
rc=$?
if [ $rc -ne 0 ] && [ $rc -ne 1 ]; then
echo "::warning::flawfinder exited $rc"
sed -n '1,20p' flawfinder.stderr
fi
if ! jq -e '.version and (.runs | type == "array")' flawfinder.sarif >/dev/null 2>&1; then
echo '::warning::flawfinder produced no valid SARIF; dropping the artifact'
rm -f flawfinder.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: flawfinder
path: flawfinder.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
github-sbom:
name: GitHub SBOM (SPDX)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Export the dependency graph
continue-on-error: true
env:
GH_TOKEN: '${{ github.token }}'
shell: bash --noprofile --norc {0}
run: |
set -uo pipefail
# 404 when the dependency graph is disabled for the repository, which is a
# setting rather than a failure.
if ! gh api "repos/${GITHUB_REPOSITORY}/dependency-graph/sbom" --jq '.sbom' >github-sbom.spdx.json 2>github-sbom.stderr; then
echo '::notice::the dependency graph is not available for this repository; skipping'
rm -f github-sbom.spdx.json
exit 0
fi
if ! jq -e '.spdxVersion' github-sbom.spdx.json >/dev/null 2>&1; then
echo '::warning::GitHub returned no valid SPDX; dropping the artifact'
rm -f github-sbom.spdx.json
fi
- uses: actions/upload-artifact@v6
with:
name: github-sbom
path: github-sbom.spdx.json
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
gitleaks:
name: Gitleaks (Secrets)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Run Gitleaks
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
set -uo pipefail
# Gitleaks exits 1 when it finds leaks, which is a successful scan.
docker run --rm -v "$PWD:/repo" zricethezav/gitleaks:v8.24.0 \
detect --source /repo --report-format sarif --report-path /repo/gitleaks.sarif --no-git || true
if ! jq -e '.version and (.runs | type == "array")' gitleaks.sarif >/dev/null 2>&1; then
echo "::warning::gitleaks produced no valid SARIF; dropping the artifact"
rm -f gitleaks.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: gitleaks
path: gitleaks.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
golangci-lint:
name: golangci-lint (Go lint)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up Go
continue-on-error: true
uses: actions/setup-go@v6
with:
go-version: stable
- name: Run golangci-lint
continue-on-error: true
env:
GO_MODULE_PATTERN: '${{ vars.GO_MODULE_PATTERN }}'
GO_MODULE_TOKEN: '${{ secrets.PACKAGES_TOKEN }}'
shell: bash --noprofile --norc {0}
run: |
if [ -n "${GO_MODULE_TOKEN:-}" ]; then
go env -w GOPRIVATE="${GO_MODULE_PATTERN:-github.com/$(echo "${GITHUB_REPOSITORY:-}" | cut -d/ -f1)/*}"
git config --global url."https://x-access-token:${GO_MODULE_TOKEN}@github.com/".insteadOf "https://github.com/"
fi
if [ ! -f go.mod ]; then
echo '::notice::no go.mod found; skipping golangci-lint'
exit 0
fi
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
golangci-lint run --output.sarif.path=golangci-lint.sarif || true
if ! jq -e '.version and (.runs | type == "array")' golangci-lint.sarif >/dev/null 2>&1; then
echo '::warning::golangci-lint produced no valid SARIF; dropping the artifact'
rm -f golangci-lint.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: golangci-lint
path: golangci-lint.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
gosec:
name: gosec (Go SAST)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up Go
continue-on-error: true
uses: actions/setup-go@v6
with:
go-version: stable
- name: Run gosec
continue-on-error: true
env:
GO_MODULE_PATTERN: '${{ vars.GO_MODULE_PATTERN }}'
GO_MODULE_TOKEN: '${{ secrets.PACKAGES_TOKEN }}'
shell: bash --noprofile --norc {0}
run: |
if [ -n "${GO_MODULE_TOKEN:-}" ]; then
go env -w GOPRIVATE="${GO_MODULE_PATTERN:-github.com/$(echo "${GITHUB_REPOSITORY:-}" | cut -d/ -f1)/*}"
git config --global url."https://x-access-token:${GO_MODULE_TOKEN}@github.com/".insteadOf "https://github.com/"
fi
if [ ! -f go.mod ]; then
echo '::notice::no go.mod found; skipping gosec'
exit 0
fi
go install github.com/securego/gosec/v2/cmd/gosec@v2.28.0
gosec -no-fail -fmt sarif -out gosec.sarif ./... || true
if ! jq -e '.version and (.runs | type == "array")' gosec.sarif >/dev/null 2>&1; then
echo '::warning::gosec produced no valid SARIF; dropping the artifact'
rm -f gosec.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: gosec
path: gosec.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
govulncheck:
name: govulncheck (Go SCA)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Set up Go
continue-on-error: true
uses: actions/setup-go@v6
with:
go-version: stable
- name: Run govulncheck
continue-on-error: true
env:
GO_MODULE_PATTERN: '${{ vars.GO_MODULE_PATTERN }}'
GO_MODULE_TOKEN: '${{ secrets.PACKAGES_TOKEN }}'
shell: bash --noprofile --norc {0}
run: |
if [ -n "${GO_MODULE_TOKEN:-}" ]; then
go env -w GOPRIVATE="${GO_MODULE_PATTERN:-github.com/$(echo "${GITHUB_REPOSITORY:-}" | cut -d/ -f1)/*}"
git config --global url."https://x-access-token:${GO_MODULE_TOKEN}@github.com/".insteadOf "https://github.com/"
fi
if [ ! -f go.mod ]; then
echo '::notice::no go.mod found; skipping govulncheck'
exit 0
fi
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck -format sarif ./... >govulncheck.sarif 2>govulncheck.stderr
rc=$?
if [ $rc -ne 0 ]; then
echo "::warning::govulncheck exited $rc"
sed -n '1,20p' govulncheck.stderr
fi
if ! jq -e '.version and (.runs | type == "array")' govulncheck.sarif >/dev/null 2>&1; then
echo '::warning::govulncheck produced no valid SARIF; dropping the artifact'
rm -f govulncheck.sarif
fi
- uses: actions/upload-artifact@v6
with:
name: govulncheck
path: govulncheck.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
grype:
name: Grype (SCA)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Run Grype
id: grype
continue-on-error: true
uses: anchore/scan-action@v7
with:
fail-build: false
output-format: sarif
path: .
- name: Stage Grype SARIF
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
cp "${{ steps.grype.outputs.sarif }}" grype.sarif
- uses: actions/upload-artifact@v6
with:
name: grype
path: grype.sarif
if-no-files-found: warn
include-hidden-files: true
retention-days: 7
grype-image:
name: Grype image (OCI)
runs-on: [self-hosted, Linux, X64, vulnetix-local]
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
- name: Build the image
id: build
continue-on-error: true
shell: bash --noprofile --norc {0}
run: |
if [ ! -f Dockerfile ] && [ ! -f Containerfile ]; then
echo '::notice::no Dockerfile or Containerfile found; skipping'
exit 0
fi