Skip to content

Commit c160ddd

Browse files
authored
Upgrade aws-sdk to v2 along with a few other dependencies for vulns (#5579)
1 parent 67e59f5 commit c160ddd

5 files changed

Lines changed: 35 additions & 29 deletions

File tree

common/scala/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ dependencies {
109109
exclude group: 'com.fasterxml.jackson.core'
110110
exclude group: 'com.fasterxml.jackson.dataformat'
111111
}
112-
api "com.amazonaws:aws-java-sdk-cloudfront:1.12.792" // Upgraded to remove ion-java dependency (CVE-2024-21634)
112+
api "software.amazon.awssdk:cloudfront:2.46.17" // Upgraded to remove ion-java dependency (CVE-2024-21634)
113113

114114
api ("com.azure:azure-storage-blob:12.18.0") {
115115
exclude group: "com.azure", module: "azure-core-test"
@@ -159,8 +159,8 @@ dependencies {
159159

160160
api("org.apache.commons:commons-lang3:3.18.0")
161161

162-
api("io.projectreactor.netty:reactor-netty-core:1.2.8")
163-
api("io.projectreactor.netty:reactor-netty-http:1.2.8")
162+
api("io.projectreactor.netty:reactor-netty-core:1.2.18")
163+
api("io.projectreactor.netty:reactor-netty-http:1.2.18")
164164

165165
api("io.grpc:grpc-api:${gradle.grpc.version}") {
166166
version { strictly gradle.grpc.version }

common/scala/src/main/scala/org/apache/openwhisk/core/database/s3/CloudFrontSigner.scala

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@ import java.io.ByteArrayInputStream
2020
import java.nio.charset.StandardCharsets.UTF_8
2121
import java.security.PrivateKey
2222
import java.time.Instant
23-
import java.util.Date
24-
2523
import org.apache.pekko.http.scaladsl.model.Uri
26-
import com.amazonaws.auth.PEM
27-
import com.amazonaws.services.cloudfront.CloudFrontUrlSigner
28-
import com.amazonaws.services.cloudfront.util.SignerUtils
29-
import com.amazonaws.services.cloudfront.util.SignerUtils.Protocol
24+
import software.amazon.awssdk.services.cloudfront.CloudFrontUtilities
25+
import software.amazon.awssdk.services.cloudfront.internal.auth.Pem
26+
import software.amazon.awssdk.services.cloudfront.model.CannedSignerRequest
3027

3128
import scala.concurrent.duration._
3229

@@ -37,18 +34,25 @@ case class CloudFrontConfig(domainName: String,
3734

3835
case class CloudFrontSigner(config: CloudFrontConfig) extends UrlSigner {
3936
private val privateKey = createPrivateKey(config.privateKey)
37+
private val cloudFrontUtils = CloudFrontUtilities.create();
4038

4139
override def getSignedURL(s3ObjectKey: String): Uri = {
42-
val resourcePath = SignerUtils.generateResourcePath(Protocol.https, config.domainName, s3ObjectKey)
43-
val date = Date.from(Instant.now().plusSeconds(config.timeout.toSeconds))
44-
val url = CloudFrontUrlSigner.getSignedURLWithCannedPolicy(resourcePath, config.keyPairId, privateKey, date)
45-
Uri(url)
40+
val resourceUrl = s"https://${config.domainName}/$s3ObjectKey"
41+
val date = Instant.now().plusSeconds(config.timeout.toSeconds)
42+
val cannedRequest = CannedSignerRequest
43+
.builder()
44+
.resourceUrl(resourceUrl)
45+
.privateKey(privateKey)
46+
.keyPairId(config.keyPairId)
47+
.expirationDate(date)
48+
.build()
49+
Uri(cloudFrontUtils.getSignedUrlWithCannedPolicy(cannedRequest).url())
4650
}
4751

4852
override def toString: String = s"CloudFront Signer - ${config.domainName}"
4953

5054
private def createPrivateKey(keyContent: String): PrivateKey = {
5155
val is = new ByteArrayInputStream(keyContent.getBytes(UTF_8))
52-
PEM.readPrivateKey(is)
56+
Pem.readPrivateKey(is)
5357
}
5458
}

settings.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ gradle.ext.pekko_kafka = [version : '1.1.0']
104104
gradle.ext.pekko_http = [version : '1.1.0']
105105
gradle.ext.pekko_management = [version : '1.1.1']
106106
gradle.ext.pekko_grpc = [version : '1.1.1']
107-
gradle.ext.grpc = [version : '1.75.0']
107+
gradle.ext.grpc = [version : '1.82.1']
108108

109109
gradle.ext.curator = [version : '5.7.0']
110110
gradle.ext.kube_client = [version: '4.10.3']
111-
gradle.ext.jackson = [version: '2.21.1']
111+
gradle.ext.jackson = [version: '2.21.4']
112112
gradle.ext.netty = [version : '4.1.135.Final']

tests/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ dependencies {
254254
implementation "io.fabric8:kubernetes-server-mock:${gradle.kube_client.version}"
255255
implementation "org.rogach:scallop_${gradle.scala.depVersion}:3.3.2"
256256

257-
implementation "com.amazonaws:aws-java-sdk-s3:1.12.395"
257+
implementation "software.amazon.awssdk:s3:2.46.17"
258258
implementation "com.microsoft.azure:azure-cosmos:3.7.6"
259259
implementation 'org.testcontainers:elasticsearch:1.17.6'
260260
implementation 'org.testcontainers:mongodb:1.17.1'

tests/src/test/scala/org/apache/openwhisk/core/database/s3/S3Minio.scala

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717

1818
package org.apache.openwhisk.core.database.s3
1919

20-
import java.net.ServerSocket
21-
20+
import java.net.{ServerSocket, URI}
2221
import actionContainers.ActionContainer
2322
import org.apache.pekko.actor.ActorSystem
24-
import com.amazonaws.auth.{AWSStaticCredentialsProvider, BasicAWSCredentials}
25-
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
26-
import com.amazonaws.services.s3.AmazonS3ClientBuilder
2723
import com.typesafe.config.ConfigFactory
2824
import common.{SimpleExec, StreamLogging}
2925
import org.scalatest.BeforeAndAfterAll
3026
import org.scalatest.flatspec.AnyFlatSpec
3127
import org.apache.openwhisk.common.{Logging, TransactionId}
3228
import org.apache.openwhisk.core.database.{AttachmentStore, DocumentSerializer}
29+
import software.amazon.awssdk.auth.credentials.{AwsBasicCredentials, StaticCredentialsProvider}
30+
import software.amazon.awssdk.regions.Region
31+
import software.amazon.awssdk.services.s3.S3Client
32+
import software.amazon.awssdk.services.s3.model.CreateBucketRequest
3333

3434
import scala.concurrent.duration._
3535
import scala.reflect.ClassTag
@@ -89,14 +89,16 @@ trait S3Minio extends AnyFlatSpec with BeforeAndAfterAll with StreamLogging {
8989
}
9090

9191
def createTestBucket(): Unit = {
92-
val endpoint = new EndpointConfiguration(s"http://localhost:$port", "us-west-2")
93-
val client = AmazonS3ClientBuilder.standard
94-
.withPathStyleAccessEnabled(true)
95-
.withEndpointConfiguration(endpoint)
96-
.withCredentials(new AWSStaticCredentialsProvider(new BasicAWSCredentials(accessKey, secretAccessKey)))
97-
.build
92+
val client = S3Client
93+
.builder()
94+
.forcePathStyle(true)
95+
.endpointOverride(URI.create(s"http://localhost:$port"))
96+
.region(Region.US_WEST_2)
97+
.credentialsProvider(StaticCredentialsProvider.create(AwsBasicCredentials.create(accessKey, secretAccessKey)))
98+
.build()
9899

99-
org.apache.openwhisk.utils.retry(client.createBucket(bucket), 6, Some(1.minute))
100+
org.apache.openwhisk.utils
101+
.retry(client.createBucket((b: CreateBucketRequest.Builder) => b.bucket(bucket)), 6, Some(1.minute))
100102
println(s"Created bucket $bucket")
101103
}
102104

0 commit comments

Comments
 (0)