-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbuild.gradle
More file actions
465 lines (390 loc) · 17 KB
/
build.gradle
File metadata and controls
465 lines (390 loc) · 17 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
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
buildscript {
repositories {
mavenCentral()
}
dependencies {
constraints {
classpath('org.apache.commons:commons-lang3:[3.18.0,)') {
because 'CVE-2025-48924 is fixed in org.apache.commons:commons-lang3:3.18.0 and higher'
}
}
}
}
plugins {
alias libs.plugins.spotless
alias libs.plugins.dockerCompose
alias libs.plugins.sonar
id "jacoco-report-aggregation"
alias libs.plugins.spotbugs
}
apply plugin: "java"
apply plugin: "application"
apply plugin: "idea"
ext {
terraformEnvironment = project.properties["terraformEnvironment"] ?: "localstack"
awsCredentialsEnvironment = terraformEnvironment == "localstack" ? [
AWS_ACCESS_KEY_ID: "mockaccesskey",
AWS_SECRET_ACCESS_KEY: "mocksecretkey",
] : [:]
noXray = {
exclude group: "com.amazonaws", module: "aws-xray-recorder-sdk-bom"
exclude group: "com.amazonaws", module: "aws-xray-recorder-sdk-core"
exclude group: "com.amazonaws", module: "aws-xray-recorder-sdk-aws-sdk-core"
exclude group: "com.amazonaws", module: "aws-xray-recorder-sdk-aws-sdk-instrumentor"
exclude group: "com.amazonaws", module: "aws-xray-recorder-sdk-aws-sdk-v2"
exclude group: "com.amazonaws", module: "aws-xray-recorder-sdk-aws-sdk-v2-instrumentor"
}
}
subprojects {
task allDeps(type: DependencyReportTask) {}
buildscript {
dependencies {
constraints {
// Netty constraints
classpath('io.netty:netty-codec-http:[4.1.129.Final,)') {
because 'CVE-2025-67735 is fixed in io.netty:netty-codec-http:4.1.129.Final and higher'
}
classpath('io.netty:netty-common:[4.1.118.Final,4.2)') {
because 'CVE-2025-25193 is fixed in io.netty:netty-common:4.1.118.Final and higher'
}
classpath('io.netty:netty-handler:[4.1.118.Final,)') {
because 'CVE-2025-24970 is fixed in io.netty:netty-handler:4.1.118.Final and higher'
}
classpath('io.netty:netty-codec-http2:[4.1.129.Final,4.2.0)') {
because 'CVE-2025-67735 is fixed in io.netty:netty-codec-http2:4.1.129.Final and higher'
}
classpath('io.netty:netty-codec:[4.1.125.Final,4.2.0)') {
because 'CVE-2025-58057 is fixed in io.netty:netty-codec:4.1.125.Final and higher'
}
// Apache Commons constraints
classpath('commons-beanutils:commons-beanutils:[1.11.0,)') {
because 'CVE-2025-48734 is fixed in commons-beanutils:commons-beanutils:1.11.0 and higher'
}
classpath('org.apache.commons:commons-lang3:[3.18.0,)') {
because 'CVE-2025-48924 is fixed in org.apache.commons:commons-lang3:3.18.0 and higher'
}
// Other constraints
classpath('com.google.protobuf:protobuf-java:[3.25.5,)') {
because 'CVE-2024-7254 is fixed in 3.25.5 and above'
}
}
}
}
apply plugin: "com.github.spotbugs"
apply plugin: "java"
ext {
isDevDeployBuild = project.hasProperty("devDeployBuild") ? project.getProperty("devDeployBuild").toBoolean() : false
}
spotbugs {
ignoreFailures = false
showStackTraces = true
effort = Effort.valueOf('MAX')
reportLevel = Confidence.valueOf('HIGH')
excludeFilter = file("$rootProject.projectDir/spotbugsExclude.xml")
}
configurations.all {
exclude group: 'org.apache.tika', module: 'tika-parser-pdf-module'
exclude group: 'org.apache.commons', module: 'commons-io'
}
// Check dependencies using:
//
// ./gradlew :frontend-api:dependencyInsight --dependency guava --configuration testRuntimeClasspath
// ./gradlew :frontend-api:dependencyInsight --dependency guava --configuration runtimeClasspath
//
dependencies {
// Unneeded constraints should be removed once no longer required
// https://discuss.gradle.org/t/dependency-version-constraints-for-all-configurations/34161/3
constraints {
configurations.configureEach { conf ->
if (!conf.canBeConsumed && !conf.canBeResolved) {
// Netty constraints
add(conf.name, 'io.netty:netty-codec-http:[4.1.129.Final,)') {
because 'CVE-2025-67735 is fixed in io.netty:netty-codec-http:4.1.129.Final and higher'
}
add(conf.name, 'io.netty:netty-common:[4.1.118.Final,4.2)') {
because 'CVE-2025-25193 is fixed in io.netty:netty-common:4.1.118.Final and higher'
}
add(conf.name, 'io.netty:netty-handler:[4.1.118.Final,)') {
because 'CVE-2025-24970 is fixed in io.netty:netty-handler:4.1.118.Final and higher'
}
add(conf.name, 'io.netty:netty-codec-http2:[4.1.129.Final,4.2.0)') {
because 'CVE-2025-67735 is fixed in io.netty:netty-codec-http2:4.1.129.Final and higher'
}
add(conf.name, 'io.netty:netty-codec:[4.1.125.Final,4.2.0)') {
because 'CVE-2025-58057 is fixed in io.netty:netty-codec:4.1.125.Final and higher'
}
// Jetty constraints
add(conf.name, 'org.eclipse.jetty.http2:jetty-http2-common:[12.0.25,12.1.0)') {
because 'CVE-2025-5115 is fixed in org.eclipse.jetty.http2:jetty-http2-common:12.0.25 and higher'
}
add(conf.name, 'org.eclipse.jetty:jetty-server:[12.0.32,)') {
because 'CVE-2026-1605 is fixed in org.eclipse.jetty:jetty-server:12.0.32 and higher'
}
add(conf.name, 'org.eclipse.jetty:jetty-http:[12.0.33,12.1.0)') {
because 'CVE-2026-2332 is fixed in org.eclipse.jetty:jetty-http:12.0.33'
}
// Jackson constraints
add(conf.name, 'com.fasterxml.jackson.core:jackson-databind:[2.12.7.1,)') {
because 'CVE-2022-42003 is fixed in 2.12.7.1 and above'
}
add(conf.name, 'com.fasterxml.jackson.core:jackson-core:[2.21.1,)') {
because 'GHSA-72hv-8253-57qq is fixed in com.fasterxml.jackson.core:jackson-core:2.21.1 and higher'
}
// Apache Commons constraints
add(conf.name, 'commons-beanutils:commons-beanutils:[1.11.0,)') {
because 'CVE-2025-48734 is fixed in commons-beanutils:commons-beanutils:1.11.0 and higher'
}
add(conf.name, 'org.apache.commons:commons-lang3:[3.18.0,)') {
because 'CVE-2025-48924 is fixed in org.apache.commons:commons-lang3:3.18.0 and higher'
}
add(conf.name, 'commons-io:commons-io:[2.21.0,)') {
because 'CVE-2021-29425 is fixed in commons-io:commons-io:2.21.0 and higher'
}
// Other constraints
add(conf.name, 'com.google.protobuf:protobuf-java:[3.25.5,)') {
because 'CVE-2024-7254 is fixed in 3.25.5 and above'
}
add(conf.name, 'org.apache.logging.log4j:log4j-core:[2.25.4,3.0.0)') {
because 'CVE-2026-34480 is fixed in 2.25.4 and higher'
}
}
}
}
constraints {
spotbugs('org.apache.logging.log4j:log4j-core:[2.25.4,3.0.0)') {
because 'CVE-2026-34480 is fixed in 2.25.4 and higher'
}
}
spotbugs libs.spotbugs
spotbugsPlugins "software.amazon.lambda.snapstart:aws-lambda-snapstart-java-rules:0.2.1"
}
}
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation" << "-Werror"
}
tasks.withType(AbstractArchiveTask) {
// Ensure that the jar / zip files are reproducible
includeEmptyDirs = false
preserveFileTimestamps = false
reproducibleFileOrder = true
}
}
}
spotless {
java {
target "**/*.java"
googleJavaFormat("1.18.0").aosp()
importOrder "", "javax", "java", "\\#"
}
groovyGradle {
target "**/*.gradle"
greclipse().configFile("tools/spotless-gradle.properties")
}
}
dockerCompose {
buildBeforeUp = true
forceRecreate = false
if (System.getProperty("os.arch") == "aarch64") {
useComposeFiles = [
"docker-compose.yml",
"docker-compose.arm64.yml"
]
}
startedServices = [
'aws',
'dynamodb',
'redis'
]
def logDir = new File(project.buildDir, "logs")
if (!logDir.exists()) {
println("creating logs folder...")
logDir.mkdir()
}
captureContainersOutput = false
captureContainersOutputToFile = new File('logs', 'docker-compose-gradle.log')
projectName = rootProject.rootDir.name
}
compileJava.dependsOn "spotlessApply"
clean.dependsOn "composeDown"
abstract class Terraform extends DefaultTask {
Terraform() {
group = "terraform"
}
@Input
abstract MapProperty<String, String> getEnvironmentVars()
@InputDirectory
abstract DirectoryProperty getTerraformDirectory()
@Input
abstract Property<String> getEnvironmentName()
@Internal
Object terraformOutputs
@TaskAction
void apply() {
def tfEnvironment = [
"TF_DATA_DIR": "${project.buildDir}/terraform/${environmentName.get()}-${terraformDirectory.get().asFile.name}",
"TF_IN_AUTOMATION": "1"
] + environmentVars.get()
logger.lifecycle("Running Terraform Initialise...")
project.exec {
executable "terraform"
workingDir terraformDirectory.asFile
environment tfEnvironment
args "init", "-backend-config=${environmentName.get()}.hcl"
}
logger.lifecycle("Applying ${terraformDirectory.getAsFile().get().name} Terraform (run gradle with --info to see output)...")
project.exec {
logging.captureStandardOutput(LogLevel.INFO)
executable "terraform"
workingDir terraformDirectory.asFile
environment tfEnvironment
args "apply", "-auto-approve", "-var-file=${environmentName.get()}.tfvars"
}
logger.lifecycle("Getting Terraform Outputs!")
new ByteArrayOutputStream().withStream { os ->
project.exec {
standardOutput os
executable "terraform"
workingDir terraformDirectory.asFile
environment tfEnvironment
args "output", "-json"
}
this.terraformOutputs = new groovy.json.JsonSlurper().parse(os.toByteArray())
}
logger.lifecycle("Terraform Complete!")
}
protected Object outputs() {
return this.terraformOutputs
}
}
task sharedTerraform (type: Terraform) {
terraformDirectory = layout.projectDirectory.dir("ci/terraform/shared")
environmentName = terraformEnvironment
environmentVars = awsCredentialsEnvironment
if (terraformEnvironment == "localstack") {
dependsOn "composeUp"
}
}
task oidcTerraform (type: Terraform) {
terraformDirectory = layout.projectDirectory.dir("ci/terraform/oidc")
environmentName = project.properties["terraformEnvironment"] ?: "localstack"
environmentVars = awsCredentialsEnvironment
doLast {
def json = outputs()
allprojects.findAll {it.name == "integration-tests"}.first().tasks.getByName("test") {
environment "API_GATEWAY_ID", json.api_gateway_root_id.value
environment "EXTERNAL_TOKEN_SIGNING_KEY_ALIAS", json.id_token_signing_key_alias.value
environment "OIDC_API_BASE_URL", json.base_url.value
environment "API_KEY", json.frontend_api_key.value
environment "FRONTEND_API_GATEWAY_ID", json.frontend_api_gateway_root_id.value
environment "FRONTEND_API_KEY", json.frontend_api_key.value
environment "EVENTS_SNS_TOPIC_ARN", json.events_sns_topic_arn.value
environment "EMAIL_QUEUE_URL", json.email_queue.value
environment "EXPERIAN_PHONE_CHECK_QUEUE_URL", json.experian_phone_check_queue.value
}
allprojects.findAll {it.name == "account-management-integration-tests"}.first().tasks.getByName("test") {
environment "EVENTS_SNS_TOPIC_ARN", json.events_sns_topic_arn.value
}
}
dependsOn ":client-registry-api:buildZip"
dependsOn ":frontend-api:buildZip"
dependsOn ":oidc-api:buildZip"
dependsOn ":ipv-api:buildZip"
dependsOn ":doc-checking-app-api:buildZip"
dependsOn "sharedTerraform"
}
task acctMgmtTerraform (type: Terraform) {
terraformDirectory = layout.projectDirectory.dir("ci/terraform/account-management")
environmentName = project.properties["terraformEnvironment"] ?: "localstack"
environmentVars = awsCredentialsEnvironment
doLast {
def json = outputs()
allprojects.findAll {it.name == "account-management-integration-tests"}.first().tasks.getByName("test") {
environment "API_GATEWAY_ID", json.api_gateway_root_id.value
environment "OIDC_API_BASE_URL", json.base_url.value
environment "EMAIL_QUEUE_URL", json.email_queue.value
}
}
dependsOn ":account-management-api:buildZip"
dependsOn "auditTerraform"
}
task utilsTerraform (type: Terraform) {
terraformDirectory = layout.projectDirectory.dir("ci/terraform/utils")
environmentName = project.properties["terraformEnvironment"] ?: "localstack"
environmentVars = awsCredentialsEnvironment
dependsOn ":utils:buildZip"
dependsOn "oidcTerraform"
}
String jacocoBuildReportPath = "reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml"
sonar {
properties {
property "sonar.projectKey", "govuk-one-login_authentication-api"
property "sonar.organization", "govuk-one-login"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.coverage.exclusions", "**/shared-test/**,**/orchestration-shared-test/**,**/orchestration-shared-test/**"
property "sonar.coverage.jacoco.xmlReportPaths", "$project.buildDir/$jacocoBuildReportPath"
}
}
subprojects {
sonar {
properties {
property 'sonar.coverage.jacoco.xmlReportPaths', "$projectDir.parentFile.path/build/$jacocoBuildReportPath"
}
}
}
reporting {
reports {
testCodeCoverageReport(JacocoCoverageReport) {
testSuiteName = "test"
}
}
}
dependencies {
jacocoAggregation subprojects
constraints {
spotbugs('org.apache.logging.log4j:log4j-core:[2.25.4,)') {
because 'CVE-2026-34480 is fixed in 2.25.4 and higher'
}
}
}
jacocoTestReport {
reports {
xml.required = true
}
dependsOn "test"
}
task searchForDependency {
group = 'Custom'
description = 'Find all projects that have a dependency'
doLast {
def targetGroup = project.hasProperty('targetGroup') ? project.property('targetGroup') : null
def targetName = project.hasProperty('targetName') ? project.property('targetName') : null
def minVersion = project.hasProperty('minVersion') ? project.property('minVersion') : null
def parsedMinVersion = VersionNumber.parse(minVersion)
println "searching for ${targetGroup}:${targetName} < ${minVersion}\n"
def foundProjects = new LinkedHashSet<String>()
allprojects {project ->
project.configurations.each { config ->
if (config.canBeResolved) {
def resolvedDependencies = config.resolvedConfiguration.lenientConfiguration.allModuleDependencies
resolvedDependencies.each { dep ->
if (dep.moduleGroup == targetGroup && dep.moduleName == targetName) {
def parsedResolvedVersion = VersionNumber.parse(dep.getModuleVersion())
def isLower = parsedResolvedVersion < parsedMinVersion
def versionString = isLower
? "Version: \u001B[31m${dep.getModuleVersion()}\u001B[0m ⚠️"
: "Version: \u001B[32m${dep.getModuleVersion()}\u001B[0m ✅"
foundProjects.add(project.path + ":" + config.name +". " + versionString)
}
}
}
}
}
foundProjects.each { projectName ->
println "${projectName}"
}
}
}