-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: sqs md5 checksum validation #1544
base: main
Are you sure you want to change the base?
Conversation
A new generated diff is ready to view. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
A new generated diff is ready to view. |
This comment has been minimized.
This comment has been minimized.
A new generated diff is ready to view. |
aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/profile/AwsProfile.kt
Outdated
Show resolved
Hide resolved
...-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/ClientConfigIntegration.kt
Outdated
Show resolved
Hide resolved
...-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/ClientConfigIntegration.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/SqsMd5ChecksumValidationIntegration.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/SqsMd5ChecksumValidationIntegration.kt
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
...t/kotlin/aws/sdk/kotlin/codegen/customization/sqs/SqsMd5ChecksumValidationIntegrationTest.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/internal/FinalizeSqsConfig.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/internal/SQSSetting.kt
Outdated
Show resolved
Hide resolved
A new generated diff is ready to view. |
This comment has been minimized.
This comment has been minimized.
A new generated diff is ready to view. |
This comment has been minimized.
This comment has been minimized.
A new generated diff is ready to view. |
This comment has been minimized.
This comment has been minimized.
...-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/ClientConfigIntegration.kt
Outdated
Show resolved
Hide resolved
...en/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/SqsModelUtils.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/SqsMd5ChecksumValidationIntegration.kt
Outdated
Show resolved
Hide resolved
...t/kotlin/aws/sdk/kotlin/codegen/customization/sqs/SqsMd5ChecksumValidationIntegrationTest.kt
Outdated
Show resolved
Hide resolved
aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/profile/AwsProfile.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/SqsMd5ChecksumValidationIntegration.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt
Outdated
Show resolved
Hide resolved
// Test MD5 availability | ||
try { | ||
"MD5".encodeToByteArray().md5() | ||
} catch (e: Exception) { | ||
logger.error { "MD5 checksums are not available (likely due to FIPS mode). Checksum validation will be disabled." } | ||
return | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correctness: This will log an error on every operation invocation when MD5 is not available, which is not what we want. Instead, we should log an error just once. One possible way to achieve this is to determine MD5 availability in the companion object:
companion object {
private val isMd5Available = asyncLazy {
try {
"MD5".encodeToByteArray().md5()
true
} catch (e: NoSuchAlgorithmException) {
coroutineContext.error(e) { "MD5 checksums are not available (likely due to FIPS mode). Checksum validation will be disabled." }
false
}
}
}
And then to read the value in the hook:
override fun readAfterExecution(context: ResponseInterceptorContext<Any, Any, HttpRequest?, HttpResponse?>) {
if (validationEnabled == ValidationEnabled.NEVER || !isMd5Available.get()) return
...
The asyncLazy
will ensure the value is only ever calculated once, including the emission of the error message.
services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/internal/ValidationConfig.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/internal/ValidationConfig.kt
Outdated
Show resolved
Hide resolved
aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/profile/AwsProfile.kt
Outdated
Show resolved
Hide resolved
aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/profile/AwsProfile.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/SqsMd5ChecksumValidationIntegration.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/SqsMd5ChecksumValidationIntegration.kt
Outdated
Show resolved
Hide resolved
.../main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/SqsMd5ChecksumValidationIntegration.kt
Show resolved
Hide resolved
A new generated diff is ready to view. |
A new generated diff is ready to view. |
A new generated diff is ready to view. |
This comment has been minimized.
This comment has been minimized.
A new generated diff is ready to view. |
This comment has been minimized.
This comment has been minimized.
A new generated diff is ready to view. |
This comment has been minimized.
This comment has been minimized.
.../main/kotlin/aws/sdk/kotlin/codegen/customization/sqs/SqsMd5ChecksumValidationIntegration.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt
Outdated
Show resolved
Hide resolved
services/sqs/common/src/aws.sdk.kotlin.services.sqs/SqsMd5ChecksumValidationInterceptor.kt
Show resolved
Hide resolved
|
A new generated diff is ready to view. |
Affected ArtifactsSignificantly increased in size
Changed in size
|
Issue #
Description of changes
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.