forked from opensearch-project/security
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
817 lines (731 loc) · 28.5 KB
/
build.gradle
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
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
import com.diffplug.gradle.spotless.JavaExtension
import org.opensearch.gradle.test.RestIntegTestTask
import groovy.json.JsonBuilder
buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
// 2.0.0-rc1-SNAPSHOT -> 2.0.0.0-rc1-SNAPSHOT
version_tokens = opensearch_version.tokenize('-')
opensearch_build = version_tokens[0] + '.0'
common_utils_version = System.getProperty("common_utils.version", '3.0.0.0-SNAPSHOT')
kafka_version = '3.5.1'
apache_cxf_version = '4.0.2'
open_saml_version = '4.3.0'
one_login_java_saml = '2.9.0'
jjwt_version = '0.11.5'
guava_version = '32.1.2-jre'
jaxb_version = '2.3.8'
if (buildVersionQualifier) {
opensearch_build += "-${buildVersionQualifier}"
}
if (isSnapshot) {
opensearch_build += "-SNAPSHOT"
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/" }
maven { url "https://build.shibboleth.net/nexus/content/groups/public" }
maven { url "https://build.shibboleth.net/nexus/content/repositories/releases" }
}
dependencies {
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
}
}
plugins {
id 'java'
id 'idea'
id 'jacoco'
id 'maven-publish'
id 'com.diffplug.spotless' version '6.21.0'
id 'checkstyle'
id 'com.netflix.nebula.ospackage' version "11.4.0"
id "org.gradle.test-retry" version "1.5.4"
id 'eclipse'
id "com.github.spotbugs" version "5.1.3"
id "com.google.osdetector" version "1.7.3"
}
allprojects {
group = "org.opensearch"
version = opensearch_build
}
apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.pluginzip'
apply plugin: 'opensearch.rest-test'
apply plugin: 'opensearch.testclusters'
apply from: 'gradle/formatting.gradle'
licenseFile = rootProject.file('LICENSE.txt')
noticeFile = rootProject.file('NOTICE.txt')
spotbugs {
includeFilter = file('spotbugs-include.xml')
}
spotbugsTest {
enabled = false
}
java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11
licenseHeaders.enabled = true
// The following check that have never be enabled in security
dependencyLicenses.enabled = false
thirdPartyAudit.enabled = false
loggerUsageCheck.enabled = false
forbiddenApisMain.enabled = false
forbiddenApisTest.enabled = false
filepermissions.enabled = false
forbiddenPatterns.enabled = false
testingConventions.enabled = false
jarHell.enabled = true
tasks.whenTaskAdded {task ->
if(task.name.contains("forbiddenApisIntegrationTest")) {
task.enabled = false
}
}
def splitTestConfig = [
ciSecurityIntegrationTest: [
description: "Runs integration tests from all classes.",
filters: [
includeTestsMatching: [
"org.opensearch.security.*Integ*"
],
excludeTestsMatching: [
"org.opensearch.security.sanity.tests.*"
]
]
],
crossClusterTest: [
description: "Runs cross-cluster tests.",
filters: [
includeTestsMatching: [
"org.opensearch.security.ccstest.*"
]
]
],
dlicDlsflsTest: [
description: "Runs Document- and Field-Level Security tests.",
filters: [
includeTestsMatching: [
"org.opensearch.security.dlic.dlsfls.*"
]
]
],
dlicRestApiTest: [
description: "Runs REST Management API tests.",
filters: [
includeTestsMatching: [
"org.opensearch.security.dlic.rest.*"
]
]
],
indicesTest: [
description: "Runs indices tests from all classes.",
filters: [
includeTestsMatching: [
"org.opensearch.security.*indices*"
],
excludeTestsMatching: [
"org.opensearch.security.sanity.tests.*"
]
]
],
opensslCITest: [
description: "Runs portion of SSL tests related to OpenSSL. Explained in https://github.com/opensearch-project/security/pull/2301",
include: '**/OpenSSL*.class'
],
sslTest: [
description: "Runs most of the SSL tests.",
filters: [
includeTestsMatching: [
"org.opensearch.security.ssl.*"
],
excludeTestsMatching: [
"org.opensearch.security.ssl.OpenSSL*"
]
]
]
] as ConfigObject
List<String> taskNames = splitTestConfig.keySet() as List
task listTasksAsJSON {
// We are using `doLast` to explicitly specify when we
// want this action to be started. Without it the output
// is not shown at all or can be mixed with other outputs.
doLast {
System.out.println(new JsonBuilder(["citest"] + taskNames))
}
}
test {
include '**/*.class'
filter {
excludeTestsMatching "org.opensearch.security.sanity.tests.*"
}
maxParallelForks = 8
jvmArgs += "-Xmx3072m"
if (JavaVersion.current() > JavaVersion.VERSION_1_8) {
jvmArgs += "--add-opens=java.base/java.io=ALL-UNNAMED"
}
retry {
failOnPassedAfterRetry = false
maxRetries = 5
}
jacoco {
excludes = [
"com.sun.jndi.dns.*",
"com.sun.security.sasl.gsskerb.*",
"java.sql.*",
"javax.script.*",
"org.jcp.xml.dsig.internal.dom.*",
"sun.nio.cs.ext.*",
"sun.security.ec.*",
"sun.security.jgss.*",
"sun.security.pkcs11.*",
"sun.security.smartcardio.*",
"sun.util.resources.provider.*"
]
}
}
task copyExtraTestResources(dependsOn: testClasses) {
copy {
from 'src/test/resources'
into 'build/testrun/test/src/test/resources'
}
taskNames.each { testName ->
copy {
from 'src/test/resources'
into "build/testrun/${testName}/src/test/resources"
}
}
copy {
from 'src/test/resources'
into 'build/testrun/citest/src/test/resources'
}
}
def setCommonTestConfig(Test task) {
task.maxParallelForks = 8
task.jvmArgs += "-Xmx3072m"
if (JavaVersion.current() > JavaVersion.VERSION_1_8) {
task.jvmArgs += "--add-opens=java.base/java.io=ALL-UNNAMED"
}
task.retry {
failOnPassedAfterRetry = false
maxRetries = 5
}
task.jacoco {
excludes = [
"com.sun.jndi.dns.*",
"com.sun.security.sasl.gsskerb.*",
"java.sql.*",
"javax.script.*",
"org.jcp.xml.dsig.internal.dom.*",
"sun.nio.cs.ext.*",
"sun.security.ec.*",
"sun.security.jgss.*",
"sun.security.pkcs11.*",
"sun.security.smartcardio.*",
"sun.util.resources.provider.*"
]
}
task.dependsOn copyExtraTestResources
task.finalizedBy jacocoTestReport
}
task citest(type: Test) {
group = "Github Actions tests"
description = "Runs the test suite on classes not covered by rest of the task in this group."
include '**/*.class'
filter {
excludeTestsMatching "org.opensearch.security.sanity.tests.*"
excludeTestsMatching "org.opensearch.security.ssl.OpenSSL*"
splitTestConfig.each { entry ->
entry.value.filters.each{ test ->
if (test.key == "includeTestsMatching") {
test.value.each{
excludeTestsMatching "${it}"
}
} else if (test.key == "includeTest") {
test.value.each{
excludeTest "${it}"
}
}
}
}
}
setCommonTestConfig(it)
}
splitTestConfig.each{ testName, testCfg ->
task "${testName}"(type: Test) {
group = testCfg.group ?: "Github Actions tests"
description = testCfg.description
include testCfg.include ?: '**/*.class'
filter {
testCfg.filters.each{ filter, values ->
values.each{ value ->
"${filter}" "${value}"
}
}
}
setCommonTestConfig(it)
}
}
tasks.test.dependsOn(copyExtraTestResources)
jacoco {
reportsDirectory = file("$buildDir/reports/jacoco")
}
jacocoTestReport {
getExecutionData().setFrom(fileTree(buildDir).include("/jacoco/*.exec"))
reports {
xml.required = true
}
}
checkstyle {
toolVersion "10.3.3"
configDirectory.set(rootProject.file("checkstyle/"))
}
opensearchplugin {
name 'opensearch-security'
description 'Provide access control related features for OpenSearch'
classname 'org.opensearch.security.OpenSearchSecurityPlugin'
}
// This requires an additional Jar not published as part of build-tools
loggerUsageCheck.enabled = false
// No need to validate pom, as we do not upload to maven/sonatype
tasks.matching {it.path in [":validateMavenPom", ":validateNebulaPom", ":validatePluginZipPom"]}.all { task ->
task.dependsOn ':generatePomFileForNebulaPublication', ':generatePomFileForPluginZipPublication', ':generatePomFileForMavenPublication'
}
publishing {
publications {
pluginZip(MavenPublication) { publication ->
pom {
name = "opensearch-security"
description = "Provide access control related features for OpenSearch"
groupId = "org.opensearch.plugin"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
name = "OpenSearch"
url = "https://github.com/opensearch-project/security"
}
}
}
}
}
repositories {
maven {
name = "Snapshots" // optional target repository name
url = "https://aws.oss.sonatype.org/content/repositories/snapshots"
credentials {
username "$System.env.SONATYPE_USERNAME"
password "$System.env.SONATYPE_PASSWORD"
}
}
}
}
repositories {
mavenLocal()
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://d1nvenhzbhpy0q.cloudfront.net/snapshots/lucene/" }
maven { url "https://build.shibboleth.net/nexus/content/repositories/releases" }
}
tasks.withType(Checkstyle) {
showViolations true
reports {
ignoreFailures = false
}
}
tasks.withType(JavaCompile) {
configure(options) {
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:removal' << '-Werror'
}
}
tasks.test.finalizedBy(jacocoTestReport) // report is always generated after tests run
allprojects {
tasks.withType(Javadoc).all { enabled = false }
}
bundlePlugin {
from('plugin-security.policy')
from('config') {
into 'config'
}
from('tools') {
into 'tools'
}
}
configurations {
all {
resolutionStrategy {
force 'commons-codec:commons-codec:1.16.0'
force 'org.slf4j:slf4j-api:1.7.36'
force 'org.scala-lang:scala-library:2.13.11'
force "com.fasterxml.jackson:jackson-bom:${versions.jackson}"
force "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
force "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${versions.jackson}"
force "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
force "io.netty:netty-buffer:${versions.netty}"
force "io.netty:netty-common:${versions.netty}"
force "io.netty:netty-handler:${versions.netty}"
force "io.netty:netty-transport:${versions.netty}"
force "io.netty:netty-transport-native-unix-common:${versions.netty}"
force "org.apache.bcel:bcel:6.7.0" // This line should be removed once Spotbugs is upgraded to 4.7.4
force "com.github.luben:zstd-jni:${versions.zstd}"
force "org.xerial.snappy:snappy-java:1.1.10.3"
force "com.google.guava:guava:${guava_version}"
}
}
integrationTestImplementation.extendsFrom implementation
integrationTestRuntimeOnly.extendsFrom runtimeOnly
}
//create source set 'integrationTest'
//add classes from the main source set to the compilation and runtime classpaths of the integrationTest
sourceSets {
integrationTest {
java {
srcDir file ('src/integrationTest/java')
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
}
resources {
srcDir file('src/integrationTest/resources')
}
processIntegrationTestResources {
duplicatesStrategy(DuplicatesStrategy.INCLUDE)
}
}
}
//add new task that runs integration tests
task integrationTest(type: Test) {
description = 'Run integration tests.'
group = 'verification'
systemProperty "java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager"
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
retry {
failOnPassedAfterRetry = false
maxRetries = 2
maxFailures = 10
}
//run the integrationTest task after the test task
shouldRunAfter test
}
//run the integrationTest task before the check task
check.dependsOn integrationTest
dependencies {
implementation "org.opensearch.plugin:transport-netty4-client:${opensearch_version}"
implementation "org.opensearch.client:opensearch-rest-high-level-client:${opensearch_version}"
implementation "org.apache.httpcomponents.client5:httpclient5-cache:${versions.httpclient5}"
implementation "org.apache.httpcomponents:httpclient:${versions.httpclient}"
implementation "org.apache.httpcomponents:httpcore:${versions.httpcore}"
implementation "org.apache.httpcomponents:httpasyncclient:${versions.httpasyncclient}"
implementation "com.google.guava:guava:${guava_version}"
implementation 'org.greenrobot:eventbus-java:3.3.1'
implementation 'commons-cli:commons-cli:1.5.0'
implementation "org.bouncycastle:bcprov-jdk15to18:${versions.bouncycastle}"
implementation 'org.ldaptive:ldaptive:1.2.3'
//JWT
implementation "io.jsonwebtoken:jjwt-api:${jjwt_version}"
implementation "io.jsonwebtoken:jjwt-impl:${jjwt_version}"
implementation "io.jsonwebtoken:jjwt-jackson:${jjwt_version}"
// JSON flattener
implementation ("com.github.wnameless.json:json-base:2.4.2") {
exclude group: "org.glassfish", module: "jakarta.json"
exclude group: "com.google.code.gson", module: "gson"
exclude group: "org.json", module: "json"
}
implementation 'com.github.wnameless.json:json-flattener:0.16.4'
// JSON patch
implementation 'com.flipkart.zjsonpatch:zjsonpatch:0.4.14'
implementation 'org.apache.commons:commons-collections4:4.4'
//Password generation
implementation 'org.passay:passay:1.6.3'
implementation "org.apache.kafka:kafka-clients:${kafka_version}"
runtimeOnly 'net.minidev:accessors-smart:2.5.0'
implementation("org.apache.cxf:cxf-rt-rs-security-jose:${apache_cxf_version}") {
exclude(group: 'jakarta.activation', module: 'jakarta.activation-api')
}
runtimeOnly "org.apache.cxf:cxf-core:${apache_cxf_version}"
implementation "org.apache.cxf:cxf-rt-rs-json-basic:${apache_cxf_version}"
runtimeOnly "org.apache.cxf:cxf-rt-security:${apache_cxf_version}"
runtimeOnly 'com.sun.activation:jakarta.activation:1.2.2'
runtimeOnly 'com.eclipsesource.minimal-json:minimal-json:0.9.5'
runtimeOnly 'commons-codec:commons-codec:1.16.0'
runtimeOnly 'org.cryptacular:cryptacular:1.2.6'
runtimeOnly 'com.google.errorprone:error_prone_annotations:2.21.1'
runtimeOnly 'com.sun.istack:istack-commons-runtime:4.2.0'
runtimeOnly 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
runtimeOnly 'org.ow2.asm:asm:9.5'
testImplementation 'org.apache.camel:camel-xmlsecurity:3.21.0'
//OpenSAML
implementation 'net.shibboleth.utilities:java-support:8.4.0'
implementation "com.onelogin:java-saml:${one_login_java_saml}"
implementation "com.onelogin:java-saml-core:${one_login_java_saml}"
implementation "org.opensaml:opensaml-core:${open_saml_version}"
implementation "org.opensaml:opensaml-security-impl:${open_saml_version}"
implementation "org.opensaml:opensaml-security-api:${open_saml_version}"
implementation "org.opensaml:opensaml-xmlsec-api:${open_saml_version}"
implementation "org.opensaml:opensaml-xmlsec-impl:${open_saml_version}"
implementation "org.opensaml:opensaml-saml-api:${open_saml_version}"
implementation ("org.opensaml:opensaml-saml-impl:${open_saml_version}") {
exclude(group: 'org.apache.velocity', module: 'velocity')
}
implementation "org.opensaml:opensaml-messaging-api:${open_saml_version}"
runtimeOnly "org.opensaml:opensaml-profile-api:${open_saml_version}"
runtimeOnly "org.opensaml:opensaml-soap-api:${open_saml_version}"
runtimeOnly "org.opensaml:opensaml-soap-impl:${open_saml_version}"
implementation "org.opensaml:opensaml-storage-api:${open_saml_version}"
implementation "com.nulab-inc:zxcvbn:1.8.0"
runtimeOnly 'com.google.guava:failureaccess:1.0.1'
runtimeOnly 'org.apache.commons:commons-text:1.10.0'
runtimeOnly "org.glassfish.jaxb:jaxb-runtime:${jaxb_version}"
runtimeOnly 'com.google.j2objc:j2objc-annotations:2.8'
runtimeOnly 'com.google.code.findbugs:jsr305:3.0.2'
runtimeOnly 'org.lz4:lz4-java:1.8.0'
runtimeOnly 'io.dropwizard.metrics:metrics-core:4.2.19'
runtimeOnly 'org.slf4j:slf4j-api:1.7.36'
runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:${versions.log4j}"
runtimeOnly 'org.xerial.snappy:snappy-java:1.1.10.3'
runtimeOnly 'org.codehaus.woodstox:stax2-api:4.2.1'
runtimeOnly "org.glassfish.jaxb:txw2:${jaxb_version}"
runtimeOnly 'com.fasterxml.woodstox:woodstox-core:6.5.1'
runtimeOnly 'org.apache.ws.xmlschema:xmlschema-core:2.3.0'
runtimeOnly 'org.apache.santuario:xmlsec:2.3.3'
runtimeOnly "com.github.luben:zstd-jni:${versions.zstd}"
runtimeOnly 'org.checkerframework:checker-qual:3.36.0'
runtimeOnly "org.bouncycastle:bcpkix-jdk15to18:${versions.bouncycastle}"
runtimeOnly 'org.scala-lang.modules:scala-java8-compat_3:1.0.2'
testImplementation "org.opensaml:opensaml-messaging-impl:${open_saml_version}"
implementation "org.apache.commons:commons-lang3:${versions.commonslang}"
testImplementation "org.opensearch:common-utils:${common_utils_version}"
testImplementation "org.opensearch.plugin:reindex-client:${opensearch_version}"
testImplementation "org.opensearch:opensearch-ssl-config:${opensearch_version}"
testImplementation "org.opensearch.plugin:percolator-client:${opensearch_version}"
testImplementation "org.opensearch.plugin:lang-mustache-client:${opensearch_version}"
testImplementation "org.opensearch.plugin:parent-join-client:${opensearch_version}"
testImplementation "org.opensearch.plugin:aggs-matrix-stats-client:${opensearch_version}"
testImplementation "org.apache.logging.log4j:log4j-core:${versions.log4j}"
testImplementation 'javax.servlet:servlet-api:2.5'
testImplementation 'com.unboundid:unboundid-ldapsdk:4.0.14'
testImplementation 'com.github.stephenc.jcip:jcip-annotations:1.0-1'
testImplementation 'com.unboundid:unboundid-ldapsdk:4.0.14'
testImplementation 'javax.servlet:servlet-api:2.5'
testImplementation 'org.apache.httpcomponents:fluent-hc:4.5.14'
testImplementation "org.apache.httpcomponents.client5:httpclient5-fluent:${versions.httpclient5}"
testImplementation "org.apache.kafka:kafka_2.13:${kafka_version}"
testImplementation "org.apache.kafka:kafka-group-coordinator:${kafka_version}"
testImplementation "org.apache.kafka:kafka_2.13:${kafka_version}:test"
testImplementation "org.apache.kafka:kafka-clients:${kafka_version}:test"
testImplementation 'org.springframework.kafka:spring-kafka-test:2.9.11'
testImplementation 'org.springframework:spring-beans:5.3.20'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
// Only osx-x86_64, osx-aarch_64, linux-x86_64, linux-aarch_64, windows-x86_64 are available
if (osdetector.classifier in ["osx-x86_64", "osx-aarch_64", "linux-x86_64", "linux-aarch_64", "windows-x86_64"]) {
testImplementation "io.netty:netty-tcnative-classes:2.0.54.Final"
testImplementation "io.netty:netty-tcnative-boringssl-static:2.0.54.Final:${osdetector.classifier}"
}
// JUnit build requirement
testCompileOnly 'org.apiguardian:apiguardian-api:1.1.2'
// Kafka test execution
testRuntimeOnly 'org.springframework.retry:spring-retry:1.3.4'
testRuntimeOnly ('org.springframework:spring-core:5.3.29') {
exclude(group:'org.springframework', module: 'spring-jcl' )
}
testRuntimeOnly 'org.scala-lang:scala-library:2.13.11'
testRuntimeOnly 'com.yammer.metrics:metrics-core:2.2.0'
testRuntimeOnly 'com.typesafe.scala-logging:scala-logging_3:3.9.5'
testRuntimeOnly 'org.apache.zookeeper:zookeeper:3.7.1'
testRuntimeOnly "org.apache.kafka:kafka-metadata:${kafka_version}"
testRuntimeOnly "org.apache.kafka:kafka-storage:${kafka_version}"
implementation "com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}"
implementation "com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}"
compileOnly "org.opensearch:opensearch:${opensearch_version}"
//integration test framework:
integrationTestImplementation('com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.8.1') {
exclude(group: 'junit', module: 'junit')
}
integrationTestImplementation 'junit:junit:4.13.2'
integrationTestImplementation "org.opensearch.plugin:reindex-client:${opensearch_version}"
integrationTestImplementation "org.opensearch.plugin:percolator-client:${opensearch_version}"
integrationTestImplementation 'commons-io:commons-io:2.13.0'
integrationTestImplementation "org.apache.logging.log4j:log4j-core:${versions.log4j}"
integrationTestImplementation "org.apache.logging.log4j:log4j-jul:${versions.log4j}"
integrationTestImplementation 'org.hamcrest:hamcrest:2.2'
integrationTestImplementation "org.bouncycastle:bcpkix-jdk15to18:${versions.bouncycastle}"
integrationTestImplementation "org.bouncycastle:bcutil-jdk15to18:${versions.bouncycastle}"
integrationTestImplementation('org.awaitility:awaitility:4.2.0') {
exclude(group: 'org.hamcrest', module: 'hamcrest')
}
integrationTestImplementation 'com.unboundid:unboundid-ldapsdk:4.0.14'
//Checkstyle
checkstyle 'com.puppycrawl.tools:checkstyle:10.12.1'
//spotless
implementation('com.google.googlejavaformat:google-java-format:1.17.0') {
exclude group: 'com.google.guava'
}
}
jar {
libsDirName = '.'
into '', {
from 'NOTICE.txt', "THIRD-PARTY.txt", "LICENSE"
}
processResources {
exclude("KEYS")
}
}
tasks.register('testsJar', Jar) {
archiveClassifier = 'tests'
from(sourceSets.test.output)
}
testsJar {
libsDirName = '.'
}
task bundleSecurityAdminStandalone(dependsOn: jar, type: Zip) {
archiveClassifier = 'securityadmin-standalone'
from(configurations.runtimeClasspath) {
into 'deps/'
}
from(project.jar) {
into 'deps/'
}
from('tools') {
into 'tools/'
}
from('config') {
into 'deps/securityconfig'
}
}
task bundleSecurityAdminStandaloneTarGz(dependsOn: jar, type: Tar) {
archiveClassifier = 'securityadmin-standalone'
archiveExtension = 'tar.gz'
compression = Compression.GZIP
from(configurations.runtimeClasspath) {
into 'deps/'
}
from(project.jar) {
into 'deps/'
}
from('tools') {
into 'tools/'
}
from('config') {
into 'deps/securityconfig'
}
}
buildRpm {
arch = 'NOARCH'
addParentDirs = false
archiveFileName = "${packageName}-${version}.rpm"
}
buildDeb {
arch = 'all'
archiveFileName = "${packageName}-${version}.deb"
}
publishing {
publications {
maven(MavenPublication) {
from(components.java)
artifact(testsJar)
}
}
}
task integTestRemote(type: RestIntegTestTask) {
systemProperty "tests.security.manager", "false"
systemProperty "user", System.getProperty("user")
systemProperty "password", System.getProperty("password")
systemProperty "https", System.getProperty("https")
systemProperty "security.enabled", "true"
filter {
setIncludePatterns("org.opensearch.security.sanity.tests.*IT")
}
}
integTestRemote.enabled = System.getProperty("tests.rest.cluster") != null
// should be updated appropriately, when we add integTests in future
integTest.enabled = false
// This is afterEvaluate because the bundlePlugin ZIP task is updated afterEvaluate and changes the ZIP name to match the plugin name
afterEvaluate {
ospackage {
packageName = "${name}"
release = isSnapshot ? "0.1" : '1'
version = "${project.version}" - "-SNAPSHOT"
into '/usr/share/opensearch/plugins'
from(zipTree(bundlePlugin.archivePath)) {
into opensearchplugin.name
}
user 'root'
permissionGroup 'root'
fileMode 0644
dirMode 0755
requires('opensearch', versions.opensearch, EQUAL)
packager = 'Amazon'
vendor = 'Amazon'
os = 'LINUX'
prefix '/usr'
license 'ASL-2.0'
maintainer 'OpenSearch <[email protected]>'
url 'https://opensearch.org/downloads.html'
summary '''
Security plugin for OpenSearch.
Reference documentation can be found at https://opensearch.org/docs/latest/.
'''.stripIndent().replace('\n', ' ').trim()
}
buildRpm {
arch = 'NOARCH'
dependsOn 'assemble'
finalizedBy 'renameRpm'
task renameRpm(type: Copy) {
from("$buildDir/distributions")
into("$buildDir/distributions")
rename "$archiveFileName", "${packageName}-${version}.rpm"
doLast { delete file("$buildDir/distributions/$archiveFileName") }
}
}
buildDeb {
arch = 'all'
dependsOn 'assemble'
finalizedBy 'renameDeb'
task renameDeb(type: Copy) {
from("$buildDir/distributions")
into("$buildDir/distributions")
rename "$archiveFileName", "${packageName}-${version}.deb"
doLast { delete file("$buildDir/distributions/$archiveFileName") }
}
}
task buildPackages(type: GradleBuild) {
tasks = ['build', 'buildRpm', 'buildDeb']
}
}
// updateVersion: Task to auto increment to the next development iteration
task updateVersion {
onlyIf { System.getProperty('newVersion') }
doLast {
ext.newVersion = System.getProperty('newVersion')
println "Setting version to ${newVersion}."
// String tokenization to support -SNAPSHOT
ant.replaceregexp(match: opensearch_version.tokenize('-')[0], replace: newVersion.tokenize('-')[0], flags:'g', byline:true) {
fileset(dir: projectDir) {
// Include the required files that needs to be updated with new Version
include(name: "bwc-test/build.gradle")
include(name: ".github/workflows/plugin_install.yml")
}
}
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
}
}