-
Notifications
You must be signed in to change notification settings - Fork 5
1618 lines (1500 loc) · 72.1 KB
/
ci-main-pull-request.yml
File metadata and controls
1618 lines (1500 loc) · 72.1 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
# CI pipeline for all application types on main and release branches
#
# use stubs/ci-main-pull-request-stub.yml in your repo to call this common action using workflow_call
#
# performs the following actions:
# 1. run source code complexity checks (SCC) using scc
# 2. run language-specific pre-compilation checks and linting (e.g., gosec, rubocop, etc.)
# 3. run language-agnostic pre-compilation checks and secret scans (e.g., OWASP dependency or top 10 checks, trufflehog)
# 4. build and unit test the application (e.g., go test, cargo test, etc.) - integration tests are in CD pipeline
# 5. run static application security tests (SAST, e.g. Sonar, Docker Scout or BlackDuck Polaris)
# 6. report to central dashboards such as harness or Irfan's quality dashboard
# 7. run packaging steps (e.g., go build, cargo build, hab build, go-releaser, etc.), publishing and optional grype scan on output
# 8. generate software bill-of-materials (SBOM) using SPDX format and lookup licenses (GitHub SBOM, Micrsosoft SBOM, license_scout, and/or BlackDuck SBOM)
# 9. run source composition analysis (SCA) scans (e.g., blackduck SCA / "purple" as a replacement to dependabot)
#
# See DEV-README.md for more details on the steps and how to use this action, or the confluence page at <TODO: URL>
#
# secrets required (by step)
# SonarQube
# SONAR_TOKEN (repository level)
# SONAR_HOST_URL (organization level)
# AKEYLESS_JWT_ID (organization level, for creation of Azure firewall rules)
# BlackDuck SAST/Polaris
# POLARIS_ACCESS_TOKEN (organization level)
# POLARIS_SERVER_URL (organization level)
# BlackDuck SCA/SBOM, Sbominator
# BLACKDUCK_SBOM_URL (organization level)
# BLACKDUCK_SCA_TOKEN (organization level)
# Custom repository properties (view these in the repo Settings > Code & Automation > Custom Properties)
# - GABuildLanguage (the primary language used in compilation and testing in GitHub Actions. select from go, ruby, erlang, rust)
# - GABuildProfile (a build profile to be used when building an application using GitHub Actions. This is experimental and will determine build, unit test paths by type of application (e.g., CLI, standard container, web API, etc.) in combination with GABuildLanguage
# - lifecycle (the current status of the repo in terms of level of engagement with the contents: indeterminate, active, inactive, under-review, in-process)
# - primaryApplication (the primary application of which this repo is a component. Which product owner is responsible for maintaining this repo? indeterminate, automate, chef-360, chef-server, chef-test-kitchen-enterprise, chef-workstation, chef-client, haabitt, inspec, non-product, online-services, other)
# - standardizationWorkflow (standardize, indtrminate, etc.)
name: CI flow containing PR checks for main & release, v2
on:
workflow_call:
inputs:
github-event-name:
description: 'GitHub event name (pass github.event_name from calling workflow for PR comment detection)'
required: false
type: string
default: ''
github-branch-name:
description: 'GitHub branch name (pass github.ref_name from calling workflow for branch-specific logic)'
required: false
type: string
default: ''
application:
# NEW IN 1.0.7
description: 'Application set in repository custom properties, typically primaryApplication'
required: false
type: string
visibility:
description: 'Visibility of the repository'
required: false
type: string
default: 'public' # (private, public, or internal) TODO: should be removed, we know this from github.event.repository.visibility
go-private-modules:
description: 'GOPRIVATE for Go private modules'
required: false
type: string
default: 'github.com/progress-platform-services/*'
version:
description: 'Version of the project'
required: false
type: string
default: '1.0.0'
detect-version-source-type: # options include "none" (do not detect), "file", "github-tag" or "github-release"
description: 'flag to determine how to detect version dynamically'
required: false
type: string
default: 'none'
detect-version-source-parameter: # use for file name
required: false
type: string
default: ''
language:
description: 'Build language (Go, Ruby, Rust, etc.), typically from the repository custom property GABuildLanguage'
required: false
type: string
default: 'ruby'
perform-complexity-checks:
description: 'Perform complexity checks with SCC'
required: false
type: boolean
default: true
scc-output-filename:
description: 'Name of the SCC complexity output file artifact, do not add file extension'
required: false
type: string
default: 'scc-complexity'
perform-language-linting:
description: 'Perform language-specific linting and pre-compilation checks'
required: false
type: boolean
default: true
perform-trufflehog-scan:
description: 'Perform trufflehog scan'
required: false
type: boolean
default: true
fail-trufflehog-on-secrets-found:
description: 'Fail the pipeline if Trufflehog finds verified secrets'
required: false
type: boolean
default: true
perform-trivy-scan:
description: 'Perform Trivy scan'
required: false
type: boolean
default: true
trivy-fail-on-high:
description: 'Fail pipeline if Trivy finds HIGH vulnerabilities'
required: false
type: boolean
default: false
trivy-fail-on-critical:
description: 'Fail pipeline if Trivy finds CRITICAL vulnerabilities'
required: false
type: boolean
default: false
perform-grype-scan:
description: 'Perform Grype scan on source code'
required: false
type: boolean
default: false
grype-fail-on-high:
description: 'Fail pipeline if Grype finds HIGH vulnerabilities'
required: false
type: boolean
default: false
grype-fail-on-critical:
description: 'Fail pipeline if Grype finds CRITICAL vulnerabilities'
required: false
type: boolean
default: false
perform-grype-image-scan:
description: 'Perform Grype scan on Docker image'
required: false
type: boolean
default: false
grype-image-fail-on-high:
description: 'Fail pipeline if Grype image scan finds HIGH vulnerabilities'
required: false
type: boolean
default: false
grype-image-fail-on-critical:
description: 'Fail pipeline if Grype image scan finds CRITICAL vulnerabilities'
required: false
type: boolean
default: false
grype-image-skip-aws:
description: 'Skip Grype image scan on AWS ECR images to avoid rate limits (assumes these images are scanned with Amazon ECR scan or Trivy)'
required: false
type: boolean
default: false
perform-grype-hab-scan:
description: 'Perform Grype scan on published Habitat packages from bldr.habitat.sh'
required: false
type: boolean
default: false
grype-hab-build-package:
description: 'Build Habitat package from source before scanning (requires checkout)'
required: false
type: boolean
default: false
grype-hab-origin:
description: 'Habitat origin (e.g., chef-platform)'
required: false
type: string
default: ''
grype-hab-package:
description: 'Habitat package name (e.g., node-management-agent)'
required: false
type: string
default: ''
grype-hab-version:
description: 'Habitat package version (optional - scans latest from channel if not specified)'
required: false
type: string
default: ''
grype-hab-release:
description: 'Habitat package release (optional - scans latest from channel if not specified)'
required: false
type: string
default: ''
grype-hab-channel:
description: 'Habitat package channel (e.g., stable, base, unstable, base-2025, lts-2024)'
required: false
type: string
default: 'stable'
grype-hab-path:
description: "Path to built Habitat package (used if build_package is true, overrides hab_origin/hab_package inputs)"
required: false
type: string
grype-hab-scan-linux:
description: 'Scan Linux (x86_64-linux) Habitat package'
required: false
type: boolean
default: true
grype-hab-scan-windows:
description: 'Scan Windows (x86_64-windows) Habitat package'
required: false
type: boolean
default: false
grype-hab-scan-macos:
description: 'Scan MacOS (x86_64-darwin) Habitat package'
required: false
type: boolean
default: false
build:
description: 'CI Build (language-specific)'
required: false
type: boolean
default: true
build-profile:
# NEW IN 1.0.7
description: 'Build profile for build step and Sonar, typically from the custom property GABuildProfile on the repository'
required: false
type: string
default: 'cli'
unit-tests:
description: 'Run unit tests (language-specific)'
required: false
type: boolean
default: true
unit-test-output-path:
# NEW IN 1.0.7
description: "Path to test results folder"
required: false
type: string
default: "test/unittest"
unit-test-command-override:
# NEW IN 1.0.7
description: "Command line for running tests in this repo, if not the language default"
required: false
type: string
perform-blackduck-polaris:
description: 'Perform BlackDuck Polaris (SAST) scan'
required: false
type: boolean
default: false
polaris-application-name:
description: 'Polaris application name, one of these {Chef-Agents | Chef-Automate | Chef-Chef360 | Chef-Habitat | Chef-Infrastructure-Server | Chef-Shared-Services}'
required: false
type: string
polaris-project-name:
description: 'Polaris project name, typically the application name, followed by - and the repository name, for example Chef-Chef360-chef-vault'
required: false
default: "${{ github.event.repository.name }}"
type: string
polaris-working-directory:
# NEW IN 1.0.7
description: 'Working directory for the scan, defaults to . but usually lang-dependent like ./src'
required: false
default: '.'
type: string
polaris-config-path:
# NEW IN 1.0.7
description: 'Path to Detect configuration file, typically a file supplied at root level like ./detect-config.yml'
required: false
default: ''
type: string
polaris-coverity-config-path:
# NEW IN 1.0.7
description: 'Path to Coverity configuration file, typically a file supplied at root level like ./coverity.yml'
required: false
default: ''
type: string
polaris-coverity-clean-command:
# NEW IN 1.0.7
description: 'Coverity clean command, typically done before build stage by language or here as param 1-liner like "mvn clean". Leave empty for buildless analysis (Ruby, Python, etc.)'
required: false
default: ''
type: string
polaris-coverity-build-command:
# NEW IN 1.0.7
description: 'Coverity build command, typically done in build stage by language or here as param 1-liner like "mvn clean install". Leave empty for buildless analysis (Ruby, Python, etc.)'
required: false
default: ''
type: string
polaris-coverity-args:
# NEW IN 1.0.7
description: 'Additional Coverity arguments,can supply extra arguments like "--config-override capture.build.build-command=make'
required: false
default: ''
type: string
polaris-detect-search-depth:
# NEW IN 1.0.7
description: 'Detect search depth, blank but can be set to "3" to search up to 3 levels of subdirectories for code to scan'
required: false
default: ''
type: string
polaris-detect-args:
# NEW IN 1.0.7
description: 'Additional Detect arguments, can supply extra arguments like "--detect.diagnostic=true"'
required: false
default: ''
type: string
polaris-assessment-mode:
# NEW IN 1.0.7
description: 'Assessment mode (CI or SOURCE_UPLOAD)'
required: false
default: 'CI'
type: string
wait-for-scan:
# NEW IN 1.0.7
description: 'Wait for scan completion'
required: false
default: true
type: boolean
polaris-fail-on-high:
description: 'Fail the pipeline if Polaris SAST scan finds HIGH vulnerabilities'
required: false
type: boolean
default: false
polaris-fail-on-critical:
description: 'Fail the pipeline if Polaris SAST scan finds CRITICAL vulnerabilities'
required: false
type: boolean
default: false
perform-sonarqube-scan:
description: 'Perform basic SonarQube scan'
required: false
type: boolean
default: true
perform-docker-scan:
description: 'Perform Docker scan of Dockerfile and built images in chef360 and other containerized applications'
required: false
type: boolean
default: false
report-unit-test-coverage:
description: 'Perform unit tests and report coverage to SonarQube'
required: false
type: boolean
default: true
report-to-atlassian-dashboard:
description: 'Report Sonar test coverage and other metrics to Atlassian dashboard (Irfans QA dashboard)'
required: false
type: boolean
default: true
quality-product-name:
description: 'Product name for quality reporting (Chef360, Courier, Inspec)'
required: false
type: string
default: 'Chef360'
quality-sonar-app-name:
description: 'Sonar application name for quality reporting'
required: false
type: string
default: 'YourSonarAppName'
quality-testing-type:
description: 'Testing type for quality reporting (Unit, Integration, e2e, api, Performance, Security)'
required: false
type: string
default: 'Integration'
quality-service-name:
description: 'Service or repository name for quality reporting'
required: false
type: string
default: 'YourServiceOrRepoName'
quality-junit-report:
description: 'Path to JUnit report for quality reporting'
required: false
type: string
default: 'path/to/junit/report'
package-binaries:
description: 'Package binaries (e.g., RPM, DEB, MSI, dpkg + signing + SHA)'
required: false
type: boolean
default: true
habitat-build:
description: 'Create Habitat packages'
required: false
type: boolean
default: true
publish-habitat-packages:
# NEW IN 1.0.7
description: 'Publish Habitat packages to Builder'
required: false
type: boolean
default: false
publish-habitat-hab_package:
# NEW IN 1.0.7
description: "Chef Habitat package to install (e.g., core/nginx)"
required: false
type: string
default: "core/nginx"
# TODO: detect from plan file if not provided
publish-habitat-hab_version:
# NEW IN 1.0.7
description: "Chef Habitat package version (optional)"
required: false
type: string
publish-habitat-hab_release:
# NEW IN 1.0.7
description: "Chef Habitat package release (optional)"
required: false
type: string
publish-habitat-hab_channel:
# NEW IN 1.0.7
description: "Chef Habitat package channel (e.g., stable, base, base-2025); default is stable"
required: false
type: string
default: "stable"
publish-habitat-hab_auth_token:
# NEW IN 1.0.7
required: false
type: string
# TODO: use secret if not provided
publish-habitat-runner_os:
description: "Runner OS to use (ubuntu-latest or windows-latest)"
type: string
# TODO: these should be options: ubuntu-latest, windows-latest, both, and add MacOS support
required: false
default: ubuntu-latest
habitat-grype-scan:
# NEW IN 1.0.7
description: 'Scan built Habitat packages with Grype for vulnerabilities'
required: false
type: boolean
default: false
publish-packages:
description: 'Publish packages (e.g., container from Dockerfile to ECR, go-releaser binary to releases page, omnibus to artifactory, gems, choco, homebrew, other app stores)'
required: false
type: boolean
default: true
generate-sbom:
description: 'Generate software bill-of-materials (SPDX SBOM)'
required: false
type: boolean
default: true
export-github-sbom:
description: 'Export SBOM to GitHub'
required: false
type: boolean
default: true
generate-msft-sbom:
description: 'Generate SBOM using MSFT tools'
required: false
type: boolean
default: true
license_scout:
description: 'Run license scout for license compliance'
required: false
type: boolean
default: true
perform-blackduck-sca-scan: # combined with generate sbom below, also needs version above
description: 'Perform BlackDuck SCA scan'
required: false
type: boolean
default: false
blackduck-project-group-name:
description: 'BlackDuck project group name, typically one of (Chef), Chef-Agents, Chef-Automate, Chef-Chef360, Chef-Habitat, Chef-Infrastructure-Server, Chef-Shared-Services'
required: false
type: string
default: 'Chef'
blackduck-project-name:
description: 'BlackDuck project name, typically the repository name'
required: false
type: string
default: ${{ github.event.repository.name }}
polaris-blackduck-executable:
# TODO: this will be obsolete with built-in polaris in action
description: 'Path to BlackDuck polaris executable after build or download step'
required: false
type: string
default: 'path/to/blackduck/binary'
polaris-executable-detect-path:
description: 'Additions to $PATH for BlackDuck polaris to find executable'
required: false
type: string
default: 'path/to/detect'
blackduck-force-low-accuracy-mode:
description: 'Force low accuracy mode for BlackDuck SCA scan to speed up scan time at the cost of accuracy (not recommended for production use)'
required: false
type: boolean
default: false
run-bundle-install: # Added to support projects without committed Gemfile.lock (e.g., chef-cli)
description: 'Run bundle install before scanning to generate Gemfile.lock at runtime'
required: false
type: boolean
default: false
ruby-app-directory:
description: 'Subdirectory containing Ruby Gemfile (e.g., "src/supermarket" for repos with non-root Gemfile location). Leave empty if Gemfile is in root.'
required: false
type: string
default: ''
blackduck-fail-on-blocker:
description: 'Fail the pipeline if BlackDuck SCA scan finds BLOCKER vulnerabilities'
required: false
type: boolean
default: false
blackduck-fail-on-critical:
description: 'Fail the pipeline if BlackDuck SCA scan finds CRITICAL vulnerabilities'
required: false
type: boolean
default: false
blackduck-fail-on-major:
description: 'Fail the pipeline if BlackDuck SCA scan finds MAJOR vulnerabilities'
required: false
type: boolean
default: false
udf1:
description: 'User defined flag 1'
required: false
type: string
default: 'default'
udf2:
description: 'User defined flag 2'
required: false
type: string
default: 'default'
udf3:
description: 'User defined flag 3'
required: false
type: string
default: 'default'
# no longer used (retained just for older stub versions)
generate-blackduck-sbom: # obsolete
description: 'Generate SBOM using BlackDuck polaris (OBSOLETE, use perform-blackduck-sca-scan instead)'
required: false
type: boolean
default: false
# polaris-server-url:
# # should be obsolete with POLARIS_SERVER_URL secret
# description: 'Polaris server URL'
# required: false
# default: 'https://polaris.blackduck.com'
# type: string
env:
PRIMARY_APPLICATION: ${{ inputs.application }} # was 'default' # Custom repo property [primaryApplication]: chef360, automate, infra-server, habitat, supermarket, licensing, downloads, chef-client, inspec, chef-workstation (or derivatives like habitat-builder)
REPO_VISIBILITY: ${{ github.event.repository.visibility }}
REPO_NAME: ${{ github.event.repository.name }}
PIPELINE_VERSION: '1.0.7' # version of this CI pipeline
GA_BUILD_LANGUAGE: ${{ inputs.language}} # Custom repo property [GABuildLanguage]: go, ruby, erlang, rust (replaces Language input)
GA_BUILD_PROFILE: ${{ inputs.build-profile }} # Custom repo property [GABuildProfile]: TBD
# APP_VERSION: $(cat VERSION)
FILE_PREFIX: $(echo "${{ github.repository }}" | sed 's|/|-|g')-$(date +%Y%m%d%H%M%S)
DEFAULT_FILE_EXTENSION: ".json"
DEFAULT_SEPARATOR: "-"
jobs:
precompilation-checks:
name: 'Pre-compilation checks'
runs-on: ubuntu-latest
steps:
- name: detect-custom-properties
# 'Detect app, language, and build profile environment variables from repository custom properties'
# GH API returns something like [{"property_name":"GABuildLanguage","value":"go"},{"property_name":"GABuildProfile","value":"cli"},{"property_name":"primaryApplication","value":"chef-360"}]'
run: |
response=$(gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ github.repository }}/properties/values)
primaryApplication=$(echo "$response" | jq -r '.[] | select(.property_name=="primaryApplication") | .value')
GABuildLanguage=$(echo "$response" | jq -r '.[] | select(.property_name=="GABuildLanguage") | .value')
GABuildProfile=$(echo "$response" | jq -r '.[] | select(.property_name=="GABuildProfile") | .value')
echo "PRIMARY APP... $primaryApplication"
echo "BUILD LANG... $GABuildLanguage"
echo "BUILD PROFILE... $GABuildProfile"
echo "PRIMARY_APPLICATION=$primaryApplication" >> $GITHUB_ENV
echo "GA_BUILD_LANGUAGE=$GABuildLanguage" >> $GITHUB_ENV
echo "GA_BUILD_PROFILE=$GABuildProfile" >> $GITHUB_ENV
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
- name: generate-filename-slug
# description: Generate a simple slug based on repo and date for use in any output artifacts
run: |
FILE_PREFIX=$(echo "${{ github.repository }}${{ env.DEFAULT_SEPARATOR }}${{ github.ref_name }}${{ env.DEFAULT_SEPARATOR }}" | sed 's|/|-|g')-$(date +%Y%m%d%H%M%S)
echo "FILE_PREFIX=${FILE_PREFIX}" >> $GITHUB_ENV
# FILE_NAME=$(echo "${{ env.FILE_PREFIX }}${{ env.DEFAULT_SEPARATOR }}${{ env.DEFAULT_FILE_NAME }}${{ env.DEFAULT_FILE_EXTENSION }}")
- name: 'Echo inputs'
run: |
echo "CI pipeline execution plan for repository [$REPO_NAME] with pipeline version $PIPELINE_VERSION"
echo "Environment variables"
echo " Repository visibility $REPO_VISIBILITY [workflow param was: ${{ inputs.visibility }}]"
echo " Repository primary application $PRIMARY_APPLICATION [workflow param was: ${{ inputs.application }}]"
echo " Repository build language $GA_BUILD_LANGUAGE [workflow param was: ${{ inputs.language }}]"
echo " Repository build profile $GA_BUILD_PROFILE [workflow param was: ${{ inputs.build-profile }}]"
echo " Computed file name prefix $FILE_PREFIX"
if [ ${{ inputs.version }} ]; then
echo " Repository version ${{ inputs.version }} from parameter ${{ inputs.detect-version-source-parameter }} and type ${{ inputs.detect-version-source-type }}"
fi
if [ ${{ inputs.go-private-modules }} ]; then
echo " GOPRIVATE ${{ inputs.go-private-modules }}"
fi
echo " Pipeline executing on ubuntu-latest"
echo "** SOURCE CODE COMPLEXITY AND LINTING ***********************************************"
if [ ${{ inputs.perform-complexity-checks }} ]; then
echo " SCC: performing complexity checks with output filename ${{ inputs.scc-output-filename }} "
fi
if [ ${{ inputs.perform-language-linting }} ]; then
echo " Linting: performing language-specific linting"
fi
echo "** TRUFFLEHOG (SECRETS) AND TRIVY (DEP SCAN) ****************************************"
if [ ${{ inputs.perform-trufflehog-scan }} ]; then
echo " Trufflehog"
fi
if [ ${{ inputs.perform-trivy-scan }} ]; then
echo " trivy"
fi
if [ ${{ inputs.perform-grype-hab-scan }} ]; then
echo "** GRYPE HABITAT PACKAGE SCAN **********************************************************"
echo " Mode: ${{ inputs.grype-hab-build-package == true && 'Build from source' || 'Download from Builder' }}"
if [ ${{ inputs.grype-hab-build-package }} ]; then
echo " Origin: ${{ inputs.grype-hab-origin }}"
fi
echo " Scanning Habitat package: ${{ inputs.grype-hab-origin }}/${{ inputs.grype-hab-package }}"
echo " Version: ${{ inputs.grype-hab-version }} Release: ${{ inputs.grype-hab-release }} Channel: ${{ inputs.grype-hab-channel }}"
echo " Platforms: Linux=${{ inputs.grype-hab-scan-linux }} Windows=${{ inputs.grype-hab-scan-windows }} MacOS=${{ inputs.grype-hab-scan-macos }}"
fi
if [ ${{ inputs.build }} ]; then
echo "** BUILD AND UNIT TEST *************************************************************"
echo " Repository build profile $GA_BUILD_PROFILE [${{ inputs.build-profile }}]"
if [ ${{ inputs.unit-tests }} ]; then
echo " Unit testing to ${{ inputs.unit-test-output-path }} with override command ${{ inputs.unit-test-command-override }}"
fi
fi
if [ ${{ inputs.perform-blackduck-polaris }} ]; then
echo "** POLARIS (SAST) TESTING *************************************************************"
echo " Polaris application name ${{ inputs.polaris-application-name }}"
echo " Polaris project name ${{ inputs.polaris-project-name }}"
echo " Working directory ${{ inputs.polaris-working-directory }}"
echo " Config path ${{ inputs.polaris-config-path }} (Coverity ${{ inputs.polaris-coverity-config-path }})"
echo " Clean command ${{ inputs.polaris-coverity-clean-command }}"
echo " Build command ${{ inputs.polaris-coverity-build-command }}"
echo " Args ${{ inputs.polaris-coverity-args }}"
echo " Detect search depth ${{ inputs.polaris-detect-search-depth }}"
echo " Detect args ${{ inputs.polaris-detect-args }}"
echo " Assessment mode ${{ inputs.polaris-assessment-mode }}"
echo " Wait for scan ${{ inputs.wait-for-scan }}"
fi
if [ ${{ inputs.perform-sonarqube-scan }} ]; then
echo "** SONARQUBE ******************************************************************"
fi
if [ ${{ inputs.perform-docker-scan }} ]; then
echo "** DOCKER SCOUT ***************************************************************"
fi
if [ ${{ inputs.report-unit-test-coverage }} ]; then
echo "** QUALITY DASHBOARD UNIT TEST COVERAGE REPORT ********************************"
# ignored for now - report-to-atlassian-dashboard, quality-product-name, quality-sonar-app-name, quality-testing-type, quality-service-name, quality-junit-report
fi
if [ ${{ inputs.package-binaries }} ]; then
echo "** PACKAGING ******************************************************************"
if [ ${{ inputs.habitat-build }} ]; then
echo "** HABITAT BUILD **************************************************************"
echo " Publish Habitat packages ${{ inputs.publish-habitat-packages }}"
echo " Habitat package name ${{ inputs.publish-habitat-hab_package }}"
echo " Habitat package version ${{ inputs.publish-habitat-hab_version }}"
echo " Habitat package release ${{ inputs.publish-habitat-hab_release }}"
echo " Habitat package channel ${{ inputs.publish-habitat-hab_channel }}"
echo " Auth token (overrides secret) ${{ inputs.publish-habitat-hab_auth_token }}"
echo " Publish operating system ${{ inputs.publish-habitat-runner_os }}"
fi
if [ ${{ inputs.habitat-grype-scan }} ]; then
echo " Performing grype scan on published package"
fi
if [ ${{ inputs.publish-packages }} ]; then
echo " PUBLISHING PACKAGES TO ECR, BLDR, RUBYGEMS NOT YET SUPPORTED"
fi
fi
if [ ${{ inputs.generate-sbom }} ]; then
echo "** SOFTWARE BILL OF MATERIALS FILE GENERATION ****************************************"
if [ ${{ inputs.export-github-sbom }} ]; then
echo " GitHub SBOM export"
fi
if [ ${{ inputs.generate-msft-sbom }} ]; then
echo " Microsoft SBOM file"
fi
if [ ${{ inputs.license_scout }} ]; then
echo " License scout"
fi
fi
# Generate BlackDuck SBOM set to ${{ inputs.generate-blackduck-sbom }} OBSOLETE, NO EFFECT
if [ ${{ inputs.perform-blackduck-sca-scan }} ]; then
echo "** BLACKDUCK SCAN AND REPORT ***********************************************"
echo " Chef is located at https://progresssoftware.app.blackduck.com/api/project-groups/fc6da208-79a9-4c47-a14d-6cfdf26bcfd5"
echo " BlackDuck project group name ${{ inputs.blackduck-project-group-name }}"
echo " BlackDuck project name ${{ inputs.blackduck-project-name }}"
echo " Polaris BlackDuck executable ${{ inputs.polaris-blackduck-executable }}"
echo " Polaris executable detect path ${{ inputs.polaris-executable-detect-path }}"
fi
echo "** USER DEFINED FLAGS ***************************************"
if [ -n "$${{ inputs.udf1 }}" ]; then
echo " UDF1 ${{ inputs.udf1 }}"
fi
if [ -n "$${{ inputs.udf2 }}" ]; then
echo " UDF2 ${{ inputs.udf2 }}"
fi
if [ -n "$${{ inputs.udf3 }}" ]; then
echo " UDF3 ${{ inputs.udf3 }}"
fi
# echo "The job_id is: $GITHUB_JOB"
# echo ${{ secrets.GITHUB_TOKEN }} DO NOT ECHO THIS
checkout:
name: 'Checkout repository'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
scc:
name: 'Source code complexity checks'
if: ${{ inputs.perform-complexity-checks == true }}
uses: chef/common-github-actions/.github/workflows/scc.yml@main
needs: checkout
with:
outputfilename: ${{ inputs.scc-output-filename }}
language-specific-checks:
name: 'Language-specific pre-compilation steps and linting'
# TODO: make three separate flows, by language with all steps (as oposed to one file per step with language-branching in each)
# language specific tests (gosec, rubocop, linters, etc.)
# ${{ inputs.language == 'rust' && inputs.perform-language-linting == true }}
# TODO: note you cannot do a conditional on the job, only on the step if using an ENV VAR
if: inputs.perform-language-linting
runs-on: ubuntu-latest
needs: checkout
steps:
- name: echo language
run: |
echo "Build language is set to ${{ env.GA_BUILD_LANGUAGE }}"
echo "Build language passed in ${{ inputs.language }}"
- name: Rust language checks
if: inputs.language == 'rust' # env.GA_BUILD_LANGUAGE
run: echo 'crate linter'
# https://github.com/rust-lang/rust-clippy
# cargo clippy --all-targets --all-features -- -D warnings
- name: Ruby language checks
if: inputs.language == 'ruby'
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.4'
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
# generate gemfile.lock (TODO: move this below to OWASP)
- name: RuboCop Lint
if: inputs.language == 'ruby'
run: |
echo 'ruby linter'
# gem install rubocop
# rubocop --format=github --display-cop-names --extra-details --force-exclusion .
# bundle install
# - name: 'Bundler Audit'
# if: ${{ inputs.language == 'Ruby' && inputs.perform-complexity-checks == true }}
# uses: andrewmcodes/bundler-audit-action@main
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# TODO: get with Marc/Prajakta on this sequence for Ruby uses: chef/common-github-actions/.github/workflows/rubocop.yml@main
# TODO: this is also not certified, craete a copy in .github/actions - https://github.com/marketplace/actions/bundler-audit-action
# Bundler Audit Action is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.
- name: Go language checks
if: inputs.language == 'go'
uses: actions/setup-go@v5
with:
go-version: '1.24'
check-latest: true
- name: Configure git for private Go modules
if: inputs.language == 'go'
env:
GOPRIVATE: ${{ inputs.go-private-modules }}
run: git config --global url."https://${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/"
- name: Go linting and security checks
if: inputs.language == 'go'
run: echo "Running Go linting and security checks"
# TODO: THESE DO NOT RUN IN CHEF ORG - need to create copies in common-github-actions/.github/actions/
# we can download and install them manually here if needed
# ERROR ON WORKFLOW: The actions golangci/golangci-lint-action@v6, dominikh/staticcheck-action@v1, and securego/gosec@master are not allowed in chef/arch-sample-cli because all actions must be from a repository owned by your enterprise, created by GitHub, verified in the GitHub Marketplace, or match one of the patterns: chef/*, chef/.github, chef/.github/workflows/*.
# - name: Run golangci-lint
# if: env.GA_BUILD_LANGUAGE == 'go'
# uses: golangci/golangci-lint-action@v6
# with:
# version: latest
# args: --timeout=5m
# - name: Run staticcheck
# if: env.GA_BUILD_LANGUAGE == 'go'
# uses: dominikh/staticcheck-action@v1
# with:
# version: latest
# - name: Run Gosec Security Scanner
# uses: securego/gosec@master
# with:
# args: ./...
# TO GET OUTPUT AS ARTIFACT go install github.com/securego/gosec/v2/cmd/gosec@latest
# gosec ./... >> ./bin/gosec.out
# https://go.googlesource.com/vuln - govulncheck is same as BlackDuck SCA backend, redundant to add it here
language-agnostic-checks:
name: 'Language-agnostic pre-compilation steps'
if: inputs.perform-language-linting
runs-on: ubuntu-latest
needs: checkout
steps:
- name: Language agnostic checks (OWASP dep check)
run: echo "placeholder"
# - name: 'Language-agnostic pre-compilation steps (OWASP dependency check)'
# uses: dependency-check/Dependency-Check_Action@main
# TODO: Dependency Check is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation
# create a copy in common-github-actions/.github/actions/owasp-dependency-check.yml
# https://github.com/marketplace/actions/dependency-check & https://owasp.org/www-project-dependency-check/
# and flags at https://jeremylong.github.io/DependencyCheck/dependency-check-cli/arguments.html
# - name: 'OWASP dependency check'
# uses: dependency-check/Dependency-Check_Action@v4.0.0
# with:
# project: ${{ github.event.repository.name }}
# with:
# project: $REPO_NAME
# path: '.'
# format: 'JSON'
# # out: 'reports' # this is the default, no need to specify unless you wish to override it
# args: >
# --enableRetired
# --prettyPrint
# - name: Upload Test results
# uses: actions/upload-artifact@v4
# with:
# name: OWASP dependency check report
# path: ${{github.workspace}}/reports
# TODO: add flag --failOnCVSS 7
# TODO: integrate with SonarQube
# TODO: correct artifact upload names like Sonu's in sbom.yml
run-trufflehog:
name: 'Trufflehog scan'
if: ${{ inputs.perform-trufflehog-scan }}
uses: chef/common-github-actions/.github/workflows/trufflehog.yml@main
needs: checkout
with:
github-event-name: ${{ inputs.github-event-name }}
github-branch-name: ${{ inputs.github-branch-name }}
fail-trufflehog-on-secrets-found: ${{ inputs.fail-trufflehog-on-secrets-found }}
# temporarily commenting out trivy scan due to https://www.stepsecurity.io/blog/hackerbot-claw-github-actions-exploitation
# run-trivy:
# name: 'Trivy scan'
# if: ${{ inputs.perform-trivy-scan }}
# uses: chef/common-github-actions/.github/workflows/trivy.yml@main
# needs: checkout
# with:
# version: ${{ inputs.version }}
# trivy-fail-on-high: ${{ inputs.trivy-fail-on-high }}
# trivy-fail-on-critical: ${{ inputs.trivy-fail-on-critical }}
run-grype:
name: 'Grype scan'
if: ${{ inputs.perform-grype-scan }}
runs-on: ubuntu-latest
needs: checkout # TODO: fix set-application-version
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Determine severity threshold
id: severity
run: |
if [ "${{ inputs.grype-fail-on-high }}" == "true" ]; then
echo "level=high" >> $GITHUB_OUTPUT
elif [ "${{ inputs.grype-fail-on-critical }}" == "true" ]; then
echo "level=critical" >> $GITHUB_OUTPUT
else
echo "level=none" >> $GITHUB_OUTPUT
fi
- name: Install Grype and update database
run: |
curl -sSfL https://get.anchore.io/grype | sh -s -- -b /usr/local/bin
grype db update
grype version
- name: Generate Artifact Name
run: |
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
ARTIFACT_NAME=$(echo "grype-scan-${{ github.event.repository.name }}-${TIMESTAMP}" | sed 's|/|-|g')
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
- name: Run Grype scan on repo
id: scan
run: |
# Run grype with only-fixed flag and output to JSON for analysis
grype dir:. --only-fixed -o json > grype-scan.json
grype dir:. --only-fixed --only-fixed --output table >> grype-scan.log || true
echo "✅ Grype scan completed successfully"
- name: Check Grype results and fail if vulnerabilities found
if: always()
run: |
JSON_FILE="./grype-scan.json"
if [ ! -f "$JSON_FILE" ] || [ -z "$JSON_FILE" ]; then
echo "⚠️ Grype JSON output not found"
exit 0
fi
# Extract vulnerability counts using jq or grep fallback
if command -v jq &> /dev/null; then
CRITICAL_COUNT=$(jq '[.matches[]? | select(.vulnerability.severity == "Critical")] | length' "$JSON_FILE" 2>/dev/null || echo "0")
HIGH_COUNT=$(jq '[.matches[]? | select(.vulnerability.severity == "High")] | length' "$JSON_FILE" 2>/dev/null || echo "0")
else
CRITICAL_COUNT=$(grep -o '"severity":"Critical"' "$JSON_FILE" | wc -l | tr -d ' ' || echo "0")
HIGH_COUNT=$(grep -o '"severity":"High"' "$JSON_FILE" | wc -l | tr -d ' ' || echo "0")
fi
echo ""
echo "============================================"
echo "Grype Security Scan Summary"
echo "============================================"
echo "CRITICAL vulnerabilities: $CRITICAL_COUNT"
echo "HIGH vulnerabilities: $HIGH_COUNT"
echo "============================================"
VIOLATIONS=""
[ "${{ inputs.grype-fail-on-critical }}" == "true" ] && [ "$CRITICAL_COUNT" -gt 0 ] && VIOLATIONS="${VIOLATIONS}$CRITICAL_COUNT CRITICAL, "
[ "${{ inputs.grype-fail-on-high }}" == "true" ] && [ "$HIGH_COUNT" -gt 0 ] && VIOLATIONS="${VIOLATIONS}$HIGH_COUNT HIGH, "
if [ -n "$VIOLATIONS" ]; then
echo ""
echo "❌ BUILD FAILED: Found ${VIOLATIONS%, }"
exit 1
fi
echo ""
echo "✅ No policy violations found"
- name: Upload Grype scan results
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: |
grype-scan.json
grype-scan.log
# - name: Run Grype scan on repo
# uses: anchore/scan-action@v3
# with:
# path: .
# fail-build: true
# severity-cutoff: high
run-grype-image:
name: 'Grype Docker image scan'
if: ${{ inputs.perform-grype-image-scan }}
uses: chef/common-github-actions/.github/workflows/grype.yml@main
needs: checkout
secrets: inherit
with:
fail-grype-on-high: ${{ inputs.grype-image-fail-on-high }}
fail-grype-on-critical: ${{ inputs.grype-image-fail-on-critical }}
grype-image-skip-aws: ${{ inputs.grype-image-skip-aws }}
run-grype-hab-package-scan:
name: 'Grype scan Habitat packages from bldr.habitat.sh'
if: ${{ inputs.perform-grype-hab-scan == true }}
uses: chef/common-github-actions/.github/workflows/grype-hab-package-scan.yml@main
needs: checkout
secrets: inherit
with:
build_package: ${{ inputs.grype-hab-build-package }}
hab_origin: ${{ inputs.grype-hab-origin }}
hab_package: ${{ inputs.grype-hab-package }}
hab_version: ${{ inputs.grype-hab-version }}