forked from priyanks-synopsys/Hello_Java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
322 lines (303 loc) · 11.9 KB
/
.gitlab-ci.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
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
include:
- project: synopsys/synopsys-template
ref: v1.1.0
file: templates/synopsys-template.yml
stages:
- build
- test
- security
- deploy
variables:
SCAN_BRANCHES: "/^(main|master|develop|stage|release)$/"
cache:
paths:
- .m2/repository/
- target/
image: maven:3-eclipse-temurin-17
build:
stage: build
script: mvn -B compile
test:
stage: test
script: mvn -B test
deploy:
stage: deploy
only:
variables:
- $CI_COMMIT_BRANCH =~ $SCAN_BRANCHES
script: mvn -B install
.bd-sig-template:
stage: security
variables:
BRIDGE_BLACKDUCK_URL: $BLACKDUCK_URL
BRIDGE_BLACKDUCK_TOKEN: $BLACKDUCK_API_TOKEN
DETECT_PROJECT_NAME: $CI_PROJECT_NAME
rules:
- if: ($CI_COMMIT_BRANCH =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
variables:
BRIDGE_BLACKDUCK_SCAN_FULL: 'true'
BRIDGE_BLACKDUCK_SCAN_FAILURE_SEVERITIES: 'BLOCKER'
DETECT_PROJECT_VERSION_NAME: $CI_COMMIT_BRANCH
DETECT_CODE_LOCATION_NAME: $CI_PROJECT_NAME-$CI_COMMIT_BRANCH
- if: ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE == 'merge_request_event')
variables:
BRIDGE_BLACKDUCK_SCAN_FULL: 'false'
BRIDGE_BLACKDUCK_AUTOMATION_PRCOMMENT: 'true'
BRIDGE_GITLAB_USER_TOKEN: $GITLAB_USER_TOKEN
DETECT_PROJECT_VERSION_NAME: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
DETECT_CODE_LOCATION_NAME: $CI_PROJECT_NAME-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
before_script:
- apt-get -qq update && apt-get install -y unzip
extends: .run-synopsys-tools
#artifacts:
# name: "bridge-logs"
# when: always
# paths:
# - .bridge/
# expire_in: 30 days
.bd-bridge-cli:
stage: security
variables:
BRIDGE_BLACKDUCK_URL: $BLACKDUCK_URL
BRIDGE_BLACKDUCK_TOKEN: $BLACKDUCK_API_TOKEN
DETECT_PROJECT_NAME: $CI_PROJECT_NAME
rules:
- if: ($CI_COMMIT_BRANCH =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
variables:
BRIDGE_BLACKDUCK_SCAN_FULL: 'true'
BRIDGE_BLACKDUCK_SCAN_FAILURE_SEVERITIES: 'BLOCKER'
DETECT_PROJECT_VERSION_NAME: $CI_COMMIT_BRANCH
DETECT_CODE_LOCATION_NAME: $CI_PROJECT_NAME-$CI_COMMIT_BRANCH
- if: ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE == 'merge_request_event')
variables:
BRIDGE_BLACKDUCK_SCAN_FULL: 'false'
BRIDGE_BLACKDUCK_AUTOMATION_PRCOMMENT: 'true'
BRIDGE_GITLAB_USER_TOKEN: $GITLAB_USER_TOKEN
BRIDGE_GITLAB_REPOSITORY_NAME: $CI_MERGE_REQUEST_PROJECT_ID
BRIDGE_GITLAB_REPOSITORY_BRANCH_NAME: $CI_COMMIT_BRANCH
BRIDGE_GITLAB_REPOSITORY_PULL_NUMBER: $CI_MERGE_REQUEST_IID
DETECT_PROJECT_VERSION_NAME: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
DETECT_CODE_LOCATION_NAME: $CI_PROJECT_NAME-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
before_script:
- apt-get -qq update && apt-get install -y unzip
script:
- curl -fLsS -o bridge.zip $BRIDGECLI_LINUX64 && unzip -qo -d /tmp bridge.zip && rm -f bridge.zip
- /tmp/synopsys-bridge --verbose --stage blackduck
#artifacts:
# name: "bridge-logs"
# when: always
# paths:
# - .bridge/
# expire_in: 30 days
.bd-detect-cli:
stage: security
rules:
- if: ($CI_COMMIT_BRANCH =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
variables:
DETECT_PROJECT_NAME: $CI_PROJECT_NAME
DETECT_PROJECT_VERSION_NAME: $CI_COMMIT_BRANCH
DETECT_CODE_LOCATION_NAME: $CI_PROJECT_NAME-$CI_COMMIT_BRANCH
script:
- env | sort
- curl -fLsS -o /tmp/detect8.sh https://detect.synopsys.com/detect8.sh && chmod +x /tmp/detect8.sh
- /tmp/detect8.sh --detect.policy.check.fail.on.severities=BLOCKER
#artifacts:
# name: "blackduck-logs"
# when: always
# paths:
# - /root/blackduck/runs
# expire_in: 30 days
.cnc-sig-template:
stage: security
variables:
BRIDGE_COVERITY_CONNECT_URL: $COVERITY_URL
BRIDGE_COVERITY_CONNECT_USER_NAME: $COV_USER
BRIDGE_COVERITY_CONNECT_USER_PASSWORD: $COVERITY_PASSPHRASE
BRIDGE_COVERITY_CONNECT_PROJECT_NAME: $CI_PROJECT_NAME
rules:
- if: ($CI_COMMIT_BRANCH =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
variables:
BRIDGE_COVERITY_CONNECT_STREAM_NAME: $CI_PROJECT_NAME-$CI_COMMIT_BRANCH
BRIDGE_COVERITY_CONNECT_POLICY_VIEW: 'Outstanding Issues'
- if: ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE == 'merge_request_event')
variables:
BRIDGE_COVERITY_CONNECT_STREAM_NAME: $CI_PROJECT_NAME-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
BRIDGE_COVERITY_AUTOMATION_PRCOMMENT: 'true'
BRIDGE_GITLAB_USER_TOKEN: $GITLAB_USER_TOKEN
before_script:
- apt-get -qq update && apt-get install -y unzip
extends: .run-synopsys-tools
#artifacts:
# name: "bridge-logs"
# when: always
# paths:
# - .bridge/
# expire_in: 30 days
.cnc-bridge-cli:
stage: security
variables:
BRIDGE_COVERITY_CONNECT_URL: $COVERITY_URL
BRIDGE_COVERITY_CONNECT_USER_NAME: $COV_USER
BRIDGE_COVERITY_CONNECT_USER_PASSWORD: $COVERITY_PASSPHRASE
BRIDGE_COVERITY_CONNECT_PROJECT_NAME: $CI_PROJECT_NAME
rules:
- if: ($CI_COMMIT_BRANCH =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
variables:
BRIDGE_COVERITY_CONNECT_STREAM_NAME: $CI_PROJECT_NAME-$CI_COMMIT_BRANCH
BRIDGE_COVERITY_CONNECT_POLICY_VIEW: 'Outstanding Issues'
- if: ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE == 'merge_request_event')
variables:
BRIDGE_COVERITY_CONNECT_STREAM_NAME: $CI_PROJECT_NAME-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
BRIDGE_COVERITY_AUTOMATION_PRCOMMENT: 'true'
BRIDGE_GITLAB_USER_TOKEN: $GITLAB_USER_TOKEN
BRIDGE_GITLAB_REPOSITORY_NAME: $CI_MERGE_REQUEST_PROJECT_ID
BRIDGE_GITLAB_REPOSITORY_BRANCH_NAME: $CI_COMMIT_BRANCH
BRIDGE_GITLAB_REPOSITORY_PULL_NUMBER: $CI_MERGE_REQUEST_IID
before_script:
- apt-get -qq update && apt-get install -y unzip
script:
- curl -fLsS -o bridge.zip $BRIDGECLI_LINUX64 && unzip -qo -d /tmp bridge.zip && rm -f bridge.zip
- /tmp/synopsys-bridge --verbose --stage connect
#artifacts:
# name: "bridge-logs"
# when: always
# paths:
# - .bridge/
# expire_in: 30 days
.cnc-thin-client:
stage: security
rules:
- if: ($CI_COMMIT_BRANCH =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
variables:
COVERITY_PROJECT: $CI_PROJECT_NAME
COVERITY_STREAM: $CI_PROJECT_NAME-$CI_COMMIT_BRANCH
script:
- curl -fLsS $COVERITY_URL/api/v2/scans/downloads/$COVERITY_THIN_CLIENT | tar -C /tmp -xzf -
- export COVERITY_CLI_CLOUD_ANALYSIS_ASYNC=false
- /tmp/bin/coverity scan -o analyze.location=connect -o commit.connect.url=$COVERITY_URL
-o commit.connect.project=$COVERITY_PROJECT -o commit.connect.stream=$COVERITY_STREAM
#artifacts:
# name: "coverity-logs"
# when: always
# paths:
# - idir/
# expire_in: 30 days
.coverity-cli:
stage: security
rules:
- if: ($CI_COMMIT_BRANCH =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
variables:
COVERITY_PROJECT: $CI_PROJECT_NAME
COVERITY_STREAM: $CI_PROJECT_NAME-$CI_COMMIT_BRANCH
script:
- curl -fLsS --user $COV_USER:$COVERITY_PASSPHRASE $COVERITY_URL/downloadFile.htm?fn=$COVERITY_TOOLKIT.tar.gz | tar -C /tmp -xzf -
- curl -fLsS --user $COV_USER:$COVERITY_PASSPHRASE -o /tmp/$COVERITY_TOOLKIT/bin/license.dat $COVERITY_URL/downloadFile.htm?fn=license.dat
- /tmp/$COVERITY_TOOLKIT/bin/coverity scan -o commit.connect.url=$COVERITY_URL
-o commit.connect.project=$COVERITY_PROJECT -o commit.connect.stream=$COVERITY_STREAM
#artifacts:
# name: "coverity-logs"
# when: always
# paths:
# - idir/build-log.txt
# expire_in: 30 days
.coverity-bac:
stage: security
rules:
- if: ($CI_COMMIT_BRANCH =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
variables:
COVERITY_PROJECT: $CI_PROJECT_NAME
COVERITY_STREAM: $CI_PROJECT_NAME-$CI_COMMIT_BRANCH
script:
- curl -fLsS --user $COV_USER:$COVERITY_PASSPHRASE $COVERITY_URL/downloadFile.htm?fn=$COVERITY_TOOLKIT.tar.gz | tar -C /tmp -xzf -
- curl -fLsS --user $COV_USER:$COVERITY_PASSPHRASE -o /tmp/$COVERITY_TOOLKIT/bin/license.dat $COVERITY_URL/downloadFile.htm?fn=license.dat
- export PATH=$PATH:/tmp/$COVERITY_TOOLKIT/bin
- cov-configure --java
- cov-configure --javascript
- cov-build --dir idir --fs-capture-search $CI_PROJECT_DIR mvn -B -DskipTests package
- cov-analyze --dir idir --ticker-mode none --strip-path $CI_PROJECT_DIR --webapp-security
- cov-commit-defects --dir idir --ticker-mode none --url $COVERITY_URL --stream $COVERITY_STREAM --scm git
--description $CI_PIPELINE_URL --target $CI_RUNNER_EXECUTABLE_ARCH --version $CI_COMMIT_SHORT_SHA
#artifacts:
# name: "coverity-logs"
# when: always
# paths:
# - idir/build-log.txt
# expire_in: 30 days
.coverity-incr:
stage: security
only:
refs:
- merge_requests
variables:
- $CI_MERGE_REQUEST_TARGET_BRANCH_NAME =~ $SCAN_BRANCHES
variables:
COV_STREAM: $CI_PROJECT_NAME-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
script:
- curl -fLsS --user $COV_USER:$COVERITY_PASSPHRASE $COVERITY_URL/downloadFile.htm?fn=$COVERITY_TOOLKIT.tar.gz | tar -C /tmp -xzf -
- curl -fLsS --user $COV_USER:$COVERITY_PASSPHRASE -o /tmp/$COVERITY_TOOLKIT/bin/license.dat $COVERITY_URL/downloadFile.htm?fn=license.dat
- export PATH=$PATH:/tmp/$COVERITY_TOOLKIT/bin
- export CHANGE_SET=$(git --no-pager diff origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME --name-only)
- cov-run-desktop --dir idir --url $COVERITY_URL --stream $COV_STREAM --build mvn -B -DskipTests package
- cov-run-desktop --dir idir --url $COVERITY_URL --stream $COV_STREAM --present-in-reference false
--ignore-uncapturable-inputs true --exit1-if-defects true $CHANGE_SET
#artifacts:
# name: "coverity-logs"
# when: always
# paths:
# - idir/build-log.txt
# expire_in: 30 days
coverity-on-polaris:
stage: security
rules:
- if: ($CI_COMMIT_BRANCH =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
script:
- apt-get -qq update && apt-get install -y unzip
- curl -fLOsS $POLARIS_SERVER_URL/api/tools/polaris_cli-linux64.zip
- unzip -d /tmp -jo polaris_cli-linux64.zip && rm -f polaris_cli-linux64.zip
- /tmp/polaris --co project.name=chuckaude-$CI_PROJECT_NAME analyze -w
#artifacts:
# name: "polaris-cli-logs"
# when: always
# paths:
# - .synopsys/
# expire_in: 30 days
.polaris-sig-template:
stage: security
rules:
- if: ($CI_COMMIT_BRANCH =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
variables:
BRIDGE_POLARIS_SERVERURL: $POLARIS_SERVERURL
BRIDGE_POLARIS_ACCESSTOKEN: $POLARIS_ACCESSTOKEN
BRIDGE_POLARIS_APPLICATION_NAME: "chuckaude-$CI_PROJECT_NAME"
BRIDGE_POLARIS_PROJECT_NAME: "chuckaude-$CI_PROJECT_NAME"
BRIDGE_POLARIS_ASSESSMENT_TYPES: 'SAST,SCA'
before_script:
- apt-get -qq update && apt-get install -y unzip
extends: .run-synopsys-tools
#artifacts:
# name: "bridge-logs"
# when: always
# paths:
# - .bridge/
# expire_in: 30 days
.polaris-bridge-cli:
stage: security
rules:
- if: ($CI_COMMIT_BRANCH =~ $SCAN_BRANCHES && $CI_PIPELINE_SOURCE != 'merge_request_event')
variables:
BRIDGE_POLARIS_SERVERURL: $POLARIS_SERVERURL
BRIDGE_POLARIS_ACCESSTOKEN: $POLARIS_ACCESSTOKEN
BRIDGE_POLARIS_APPLICATION_NAME: "chuckaude-$CI_PROJECT_NAME"
BRIDGE_POLARIS_PROJECT_NAME: "chuckaude-$CI_PROJECT_NAME"
BRIDGE_POLARIS_ASSESSMENT_TYPES: 'SAST,SCA'
before_script:
- apt-get -qq update && apt-get install -y unzip
script:
- curl -fLsS -o bridge.zip $BRIDGECLI_LINUX64 && unzip -qo -d /tmp bridge.zip && rm -f bridge.zip
- /tmp/synopsys-bridge --verbose --stage polaris
#artifacts:
# name: "bridge-logs"
# when: always
# paths:
# - .bridge/
# expire_in: 30 days