-
Notifications
You must be signed in to change notification settings - Fork 25.2k
/
Copy pathbuild.gradle
190 lines (172 loc) · 9.81 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
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
apply plugin: 'elasticsearch.internal-cluster-test'
apply plugin: 'elasticsearch.internal-java-rest-test'
apply plugin: 'elasticsearch.internal-cluster-test'
esplugin {
description = 'The EC2 discovery plugin allows to use AWS API for the unicast discovery mechanism.'
classname ='org.elasticsearch.discovery.ec2.Ec2DiscoveryPlugin'
}
dependencies {
implementation "software.amazon.awssdk:annotations:${versions.awsv2sdk}"
implementation "software.amazon.awssdk:apache-client:${versions.awsv2sdk}"
implementation "software.amazon.awssdk:auth:${versions.awsv2sdk}"
implementation "software.amazon.awssdk:aws-core:${versions.awsv2sdk}"
implementation "software.amazon.awssdk:ec2:${versions.awsv2sdk}"
implementation "software.amazon.awssdk:endpoints-spi:${versions.awsv2sdk}"
implementation "software.amazon.awssdk:http-client-spi:${versions.awsv2sdk}"
implementation "software.amazon.awssdk:identity-spi:${versions.awsv2sdk}"
implementation "software.amazon.awssdk:imds:${versions.awsv2sdk}"
implementation "software.amazon.awssdk:retries-spi:${versions.awsv2sdk}"
implementation "software.amazon.awssdk:sdk-core:${versions.awsv2sdk}"
implementation "software.amazon.awssdk:utils:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:aws-query-protocol:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:checksums-spi:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:checksums:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:http-auth-aws:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:http-auth-spi:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:http-auth:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:json-utils:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:metrics-spi:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:profiles:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:protocol-core:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:regions:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:retries:${versions.awsv2sdk}"
runtimeOnly "software.amazon.awssdk:third-party-jackson-core:${versions.awsv2sdk}"
implementation "org.apache.httpcomponents:httpclient:${versions.httpclient}"
runtimeOnly "commons-codec:commons-codec:${versions.commonscodec}"
runtimeOnly "commons-logging:commons-logging:${versions.commonslogging}"
runtimeOnly "joda-time:joda-time:2.10.10"
runtimeOnly "org.apache.httpcomponents:httpcore:${versions.httpcore}"
runtimeOnly "org.apache.logging.log4j:log4j-1.2-api:${versions.log4j}"
runtimeOnly "org.slf4j:slf4j-nop:${versions.slf4j}"
// runtimeOnly("org.apache.logging.log4j:log4j-slf4j-impl:${versions.log4j}") https://github.com/elastic/elasticsearch/issues/93714
runtimeOnly "org.slf4j:slf4j-api:${versions.slf4j}"
runtimeOnly "org.reactivestreams:reactive-streams:${versions.reactive_streams}"
javaRestTestImplementation project(':plugins:discovery-ec2')
javaRestTestImplementation project(':test:fixtures:aws-fixture-utils')
javaRestTestImplementation project(':test:fixtures:aws-ec2-fixture')
javaRestTestImplementation project(':test:fixtures:ec2-imds-fixture')
testImplementation project(':test:fixtures:aws-fixture-utils')
testImplementation project(':test:fixtures:ec2-imds-fixture')
internalClusterTestImplementation project(':test:fixtures:ec2-imds-fixture')
}
tasks.named("dependencyLicenses").configure {
mapping from: 'annotations', to: 'aws-sdk-2'
mapping from: 'apache-client', to: 'aws-sdk-2'
mapping from: 'auth', to: 'aws-sdk-2'
mapping from: 'aws-core', to: 'aws-sdk-2'
mapping from: 'aws-query-protocol', to: 'aws-sdk-2'
mapping from: 'checksums', to: 'aws-sdk-2'
mapping from: 'checksums-spi', to: 'aws-sdk-2'
mapping from: 'ec2', to: 'aws-sdk-2'
mapping from: 'endpoints-spi', to: 'aws-sdk-2'
mapping from: 'http-auth', to: 'aws-sdk-2'
mapping from: 'http-auth-aws', to: 'aws-sdk-2'
mapping from: 'http-auth-spi', to: 'aws-sdk-2'
mapping from: 'http-client-spi', to: 'aws-sdk-2'
mapping from: 'identity-spi', to: 'aws-sdk-2'
mapping from: 'imds', to: 'aws-sdk-2'
mapping from: 'json-utils', to: 'aws-sdk-2'
mapping from: 'metrics-spi', to: 'aws-sdk-2'
mapping from: 'profiles', to: 'aws-sdk-2'
mapping from: 'protocol-core', to: 'aws-sdk-2'
mapping from: 'regions', to: 'aws-sdk-2'
mapping from: 'retries', to: 'aws-sdk-2'
mapping from: 'retries-spi', to: 'aws-sdk-2'
mapping from: 'sdk-core', to: 'aws-sdk-2'
mapping from: 'third-party-jackson-core', to: 'aws-sdk-2'
mapping from: 'utils', to: 'aws-sdk-2'
}
esplugin.bundleSpec.from('config/discovery-ec2') {
into 'config'
}
tasks.register("writeTestJavaPolicy") {
boolean inFips = buildParams.inFipsJvm
inputs.property("inFipsJvm", inFips)
final File javaPolicy = new File(layout.buildDirectory.asFile.get(), "tmp/java.policy")
outputs.file(javaPolicy)
doLast {
if (inFips) {
javaPolicy.write(
[
"grant {",
"permission java.security.SecurityPermission \"putProviderProperty.BCFIPS\";",
"permission java.security.SecurityPermission \"putProviderProperty.BCJSSE\";",
"permission java.lang.RuntimePermission \"getProtectionDomain\";",
"permission java.util.PropertyPermission \"java.runtime.name\", \"read\";",
"permission org.bouncycastle.crypto.CryptoServicesPermission \"tlsAlgorithmsEnabled\";",
"permission java.lang.RuntimePermission \"accessClassInPackage.sun.security.internal.spec\";",
"permission java.lang.RuntimePermission \"accessDeclaredMembers\";",
"permission java.util.PropertyPermission \"intellij.debug.agent\", \"read\";",
"permission java.util.PropertyPermission \"intellij.debug.agent\", \"write\";",
"permission org.bouncycastle.crypto.CryptoServicesPermission \"exportSecretKey\";",
"permission org.bouncycastle.crypto.CryptoServicesPermission \"exportPrivateKey\";",
"permission java.io.FilePermission \"\${javax.net.ssl.trustStore}\", \"read\";",
"permission java.security.SecurityPermission \"getProperty.jdk.tls.disabledAlgorithms\";",
"permission java.security.SecurityPermission \"getProperty.jdk.certpath.disabledAlgorithms\";",
"permission java.security.SecurityPermission \"getProperty.keystore.type.compat\";",
"permission java.security.SecurityPermission \"getProperty.org.bouncycastle.ec.max_f2m_field_size\";",
"permission java.util.PropertyPermission \"aws.ec2MetadataServiceEndpoint\", \"write\";",
"permission java.util.PropertyPermission \"http.proxyHost\", \"read\";",
"permission java.util.PropertyPermission \"aws.region\", \"read\";",
"};"
].join("\n")
)
} else {
javaPolicy.write(
[
"grant {",
"permission java.util.PropertyPermission \"aws.ec2MetadataServiceEndpoint\", \"write\";",
"permission java.util.PropertyPermission \"http.proxyHost\", \"read\";",
"permission java.util.PropertyPermission \"aws.region\", \"read\";",
"};"
].join("\n"))
}
}
}
tasks.withType(Test).configureEach {
dependsOn "writeTestJavaPolicy"
// this is needed for insecure plugins, remove if possible!
systemProperty 'tests.artifact', project.name
// this is needed to manipulate aws.ec2MetadataServiceEndpoint system property
// it is better rather disable security manager at all with `systemProperty 'tests.security.manager', 'false'`
if (buildParams.inFipsJvm){
nonInputProperties.systemProperty 'java.security.policy', "=file://${layout.buildDirectory.asFile.get()}/tmp/java.policy"
} else {
nonInputProperties.systemProperty 'java.security.policy', "file://${layout.buildDirectory.asFile.get()}/tmp/java.policy"
}
systemProperty 'aws.region', 'es-test-region'
}
tasks.named("thirdPartyAudit").configure {
ignoreMissingClasses(
// classes are missing
'javax.servlet.ServletContextEvent',
'javax.servlet.ServletContextListener',
'org.apache.avalon.framework.logger.Logger',
'org.apache.log.Hierarchy',
'org.apache.log.Logger',
'javax.jms.Message',
// eventstream not used by the sync client
'software.amazon.eventstream.HeaderValue',
'software.amazon.eventstream.Message',
'software.amazon.eventstream.MessageDecoder',
// crt?
'software.amazon.awssdk.crt.auth.credentials.Credentials',
'software.amazon.awssdk.crt.auth.signing.AwsSigner',
'software.amazon.awssdk.crt.auth.signing.AwsSigningConfig',
'software.amazon.awssdk.crt.auth.signing.AwsSigningConfig$AwsSignatureType',
'software.amazon.awssdk.crt.auth.signing.AwsSigningConfig$AwsSignedBodyHeaderType',
'software.amazon.awssdk.crt.auth.signing.AwsSigningConfig$AwsSigningAlgorithm',
'software.amazon.awssdk.crt.auth.signing.AwsSigningResult',
'software.amazon.awssdk.crt.http.HttpHeader',
'software.amazon.awssdk.crt.http.HttpRequest',
'software.amazon.awssdk.crt.http.HttpRequestBodyStream',
)
}