forked from fortify/IWA-DotNet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
330 lines (312 loc) · 10.4 KB
/
azure-pipelines.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
323
324
325
326
327
328
329
330
# Example Continuous Delivery Pipeline with Fortify on Premise (SCA/SSC) and/or Fortify on Demand (FOD) support
trigger:
batch: true
branches:
include:
- main
- features/*
- releases/*
exclude:
- experimental/*
paths:
exclude:
- InsecureProductService/
- InsecurePaymentService/
- InsecureShippingService/
- README.md
- bin/*
- lib/*
- etc/*
- media/*
pr:
branches:
include:
- main
paths:
exclude:
- InsecureProductService/
- InsecurePaymentService/
- InsecureShippingService/
- README.md
- bin/*
- lib/*
- etc/*
- media/*
variables:
#
# In order for the Pipeline to execute successfully you should create the following variables in the Pipeline UI (or uncomment and hard-code here)
#
# ADOBaseURL: 'Your Azure DevOps Base URL'
# ADOPAT: 'Your Azure DevOps Personal Access Token'
# ADOProject: 'IWA.NET'
# AppUrl: 'URL of deployed application'
# AzureDBServer: 'Hostname of database server'
# AzureDBName: 'Database Name'
# AzureDBUser: 'Database User Login'
# AzureDBPassword: ' Database Password'
# FoDApplicationName: 'IWA.NET'
# FoDBaseUrl: 'https://api.emea.fortify.com'
# FoDBugTrackerVersion: '4.2'
# FoDClientId: 'Your FoD API Client Id'
# FoDClientSecret: 'You FoD API Client Secret'
# FoDParentRelease: 'main'
# FoDReleaseId: 'Your FOD Release Id'
# FoDUsername: 'You FoD username'
# FoDTenant: 'Your FoD tenant'
# ScanCentralCtrlUrl: 'Your ScanCentral Controller URL'
# ScanCentralClientToken: 'Your ScanCentral Client Token'
# ScanCentralNotificationEmail: 'Your Email Address'
# ScanCentralDASTApiUrl: 'Your ScanCentral DAST API URL'
# ScanCentralDASTCICDAuthToken: 'Your ScanCentral DAST CICD Authentication Token'
# ScanCentralDASTCICDIdentifier: 'Your ScanCentral DAST CICD Identifier'
# SSCUrl: 'Your SSC URL'
# SSCApplicationName: 'IWA.NET'
# SSCApplicationVersion: 'Your SSC application version'
# SSCAuthToken: 'Your SSC CI Authentication Token'
# ScanCentralVersion: 'The version of ScanCentral being used'
solution: '**/*.sln'
vsDevCmd: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat' # location of visual studio VsDevCmd batch file on Agent
buildConfiguration: 'Debug'
publishProfile: 'iwanet - Web Deploy'
fortifyUploadDir: 'fod' # directory to be created containing all dependencies uploaded to FOD for static analysis
FoDConnection: 'FODAzureDevOps' # the name of Fortify on Demand service connection configured in Project Settings
SSCConnection: 'SSCAzureDevOps' # the name of the Fortify SSC "generic" connection configured in Project Settings
ScanCentralLogsDir: 'C:\Users\VssAdministrator\AppData\Local\Fortify\scancentral-$(ScanCentralVersion)\log' # where ScanCentral logs will be written to
# get the source branch name
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/features/') }}:
branchName: $[ replace(variables['Build.SourceBranch'], 'refs/heads/', '') ]
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/releases/') }}:
branchName: $[ replace(variables['Build.SourceBranch'], 'refs/heads/', '') ]
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
branchName: $[ replace(variables['System.PullRequest.TargetBranch'], 'refs/heads/', '') ]
${{ if eq(variables['Build.SourceBranch'], 'refs/heads/main') }}:
branchName: 'main'
isPR: $[startsWith(variables['Build.SourceBranch'], 'refs/pull/')]
isMaster: $[eq(variables['Build.SourceBranch'], 'refs/heads/main')]
stages:
#
# Build and Unit Test the application components
#
- stage: BuildAndUnitTest
displayName: 'Build and Unit Test'
pool:
# use Azure DevOps provided agent
vmImage: 'ubuntu-latest'
jobs:
# Build web application component
- job: Web
steps:
- task: UseDotNet@2
inputs:
version: '6.x'
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
command: 'build'
configuration: $(buildConfiguration)
projects: '$(solution)'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(build.artifactStagingDirectory)'
artifact: 'InsecureWebApp-Web'
publishLocation: 'pipeline'
#
# Static Application Security Testing with ScanCentral SAST (on premise)
#
- stage: ScanCentral_SAST
displayName: 'ScanCentral SAST'
condition: eq(variables['UseScanCentralSAST'], 'true')
dependsOn: BuildAndUnitTest
pool:
# use Azure DevOps provided agent
vmImage: 'windows-2022'
# or uncomment to use a local Agent pool named 'Fortify' with Fortify software installed
# name: Fortify
jobs:
- job: UploadAndScan
displayName: 'Upload and Scan'
steps:
- task: UseDotNet@2
inputs:
version: '6.0.202'
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
command: 'build'
configuration: $(buildConfiguration)
projects: '$(solution)'
- task: BatchScript@1
displayName: 'Set Visual Studio environment'
inputs:
filename: "$(vsDevCmd)"
modifyEnvironment: true
- task: FortifyScanCentralSAST@7
inputs:
scanCentralCtrlUrl: '$(ScanCentralCtrlUrl)'
scanCentralClientToken: '$(ScanCentralClientToken)'
sscUrl: '$(SSCUrl)'
sscCiToken: '$(SSCAuthToken)'
uploadToSSC: true
applicationName: '$(SSCApplicationName)'
applicationVersion: '$(SSCApplicationVersion)'
buildTool: 'msbuild'
buildFile: 'IWA.NET.sln'
email: '$(ScanCentralNotificationEmail)'
block: true
outputFile: 'IWA.NET.fpr'
logFile: 'IWA.NET.log'
overwrite: true
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.SourcesDirectory)/IWA.NET.fpr'
artifact: 'Fortify Results (FPR)'
publishLocation: 'pipeline'
#
# Static Application Security Testing with Fortify on Demand
#
- stage: FoD_SAST
displayName: 'FoD SAST'
condition: eq(variables['UseFoD'], 'true')
dependsOn: BuildAndUnitTest
pool:
# use Azure DevOps provided agent
vmImage: 'windows-2022'
# or uncomment to use a local Agent pool named 'Fortify'
#name: Fortify
jobs:
- job: UploadAndScan
displayName: "Upload and Scan"
steps:
- task: UseDotNet@2
displayName: 'Set DotNet environment'
inputs:
version: '6.0.202'
- task: DotNetCoreCLI@2
inputs:
command: build
projects: '$(solution)'
configuration: '$(buildConfiguration)'
- task: JavaToolInstaller@0
inputs:
versionSpec: "11"
jdkArchitectureOption: x64
jdkSourceOption: PreInstalled
- task: BatchScript@1
displayName: 'Set Visual Studio environment'
inputs:
filename: "$(vsDevCmd)"
modifyEnvironment: true
- task: FortifyOnDemandStatic@8
# Carry out a Fortify on Demand static assessment
inputs:
FortifyProjects: '.'
FodConnection: '$(FoDConnection)'
ReleaseOptions: '0'
ReleaseId: $(FoDReleaseId)
EntitlementSelection: '1'
EntitlementPreference: '1'
OverrideScanSettings: '2'
InProgressScanActionType: '2'
RemediationScanPreference: '2'
BuildType: 'msbuild'
BuildFile: 'IWA.NET.sln'
PolicyFailAction: '0'
PollingInterval: 5
#
# Deploy the application
#
- stage: DeployToAzure
condition: eq(variables.isMaster, true)
#condition: always()
dependsOn:
- BuildAndUnitTest
- ScanCentral_SAST
- FoD_SAST
displayName: 'Deploy to Azure'
pool:
# use Azure DevOps provided agent
vmImage: 'windows-2019'
# use local Agent pool named 'Fortify'
#name: Fortify
jobs:
- job: DownloadAndDeploy
displayName: 'Download and Deploy'
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'InsecureWebApp-DB'
itemPattern: '**/*'
targetPath: '$(Pipeline.Workspace)'
- task: SqlAzureDacpacDeployment@1
inputs:
azureSubscription: 'iwa-arm'
AuthenticationType: 'connectionString'
ConnectionString: 'Data Source=tcp:$(AzureDBServer),1433;Initial Catalog=$(AzureDBName);User Id=$(AzureDBUser);Password=$(AzureDBPassword)'
deployType: 'SqlTask'
SqlFile: '$(Pipeline.Workspace)/InsecureWebApp.sql'
IpDetectionMethod: 'AutoDetect'
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'InsecureWebApp-Web'
itemPattern: '**/*'
targetPath: '$(Pipeline.Workspace)'
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'iwa-arm'
appType: 'webApp'
WebAppName: 'iwanet'
packageForLinux: '$(Pipeline.Workspace)/InsecureWebApp.zip'
#JSONFiles: 'appsettings.json'
#
# Dynamic Application Security Testing with ScanCentral DAST (on-premise)
#
- stage: ScanCentral_DAST
displayName: 'ScanCentral DAST'
condition: eq(variables['UseScanCentralDAST'], 'true')
dependsOn: DeployToAzure
pool:
# use Azure DevOps provided agent
vmImage: 'windows-2019'
# use local Agent pool named 'Fortify'
#name: Fortify
jobs:
- job: RunScan
displayName: 'Run Scan'
steps:
- task: FortifyScanCentralDAST@7
inputs:
scanCentralDastApiUrl: '$(ScanCentralDASTApiUrl)'
scanCentralCiCdToken: '$(ScanCentralDASTCICDIdentifier)'
sscCiToken: '$(ScanCentralDASTCICDAuthToken)'
#
# Dynamic Application Security Testing with Fortify on Demand
#
- stage: FoD_DAST
displayName: 'FoD DAST'
# renamed from UseFOD because we have not tested FOD DAST currently
condition: eq(variables['UseFODXXX'], 'true')
dependsOn: DeployToAzure
pool:
# use Azure DevOps provided agent
vmImage: 'windows-2019'
# use local Agent pool named 'Fortify'
#name: Fortify
jobs:
- job: RunScan
displayName: 'Run Scan'
steps:
- task: FortifyOnDemandDynamic@7
# renamed from UseFOD because we have not tested FOD DAST currently
condition: eq(variables['UseFODXXX'], 'true')
inputs:
APIUrl: '${FoDBaseUrl}'
ReleaseId: '${branchName}'
APIAuthenticationType: '1'
APIKey: '${FoDClientId}'
APISecret: '${FoDClientSecret}'
EntitlementPreference: '2'
PurchaseEntitlements: false
PreferRemediation: false