-
Notifications
You must be signed in to change notification settings - Fork 78
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
refactor(deps): upgrade to aws-sdk-go-v2
#529
refactor(deps): upgrade to aws-sdk-go-v2
#529
Conversation
- `aws-sdk-go` has [a vuln](https://osv.dev/vulnerability/GO-2022-0646) in the v1 EncryptionClient - it's fixed in the v2 client - we don't use this functionality, but still get reported this vuln - instead add an ignore for the vuln, figured I might as well make the upgrade to v2 - confirmed that `go.mod` has latest versions (e.g. `config` [released v1.19.0](https://github.com/aws/aws-sdk-go-v2/releases/tag/release-2023-10-16) this week) - follow the [migration instructions](https://aws.github.io/aws-sdk-go-v2/docs/migrating/) - migrate all `session` usage to `config.LoadDefaultConfig` per [instructions](https://aws.github.io/aws-sdk-go-v2/docs/migrating/#configuration-loading) - this includes shared config handling, so I believe `session.SharedConfigEnable` is no longer necessary per [instructions](https://aws.github.io/aws-sdk-go-v2/docs/migrating/#migrating-from-newsessionwithoptions) - the docs on ["Speciyfing Credentials"](https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/#specifying-credentials) seem to state this as well, if I'm understanding correctly - see also `config.WithRegion` mention in the [instructions](https://aws.github.io/aws-sdk-go-v2/docs/migrating/#migrating-from-newsession-with-awsconfig-options) - migrate credential usage - [`Config.Credentials`](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws#Config) still exists, but the function is now [`Retrieve(context)`](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws#CredentialsProvider) instead of `Get` - the [`Credentials` struct](https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/aws#Credentials) otherwise looks the same, has the `AccessKeyId`, `SecretAccessKey`, and `SessionToken` that were used in v1 - STS credentials are retrieved a bit differently now [per instructions](https://aws.github.io/aws-sdk-go-v2/docs/migrating/#aws-security-token-service-credentials) - use a `config` instead of a `session` to create a client, then use `NewAssumeRoleProvider` instead of `NewCredentials - NOTE: I used `context.Background()` for all of the contexts that are now required - it may make more sense for context to be passed into these functions, but that would be a breaking change and require downstream changes in Argo projects, so I left that out for now and just went with `Background` as a default Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
- this was just straight up missing from the migration guide's imports - found it myself: https://pkg.go.dev/github.com/aws/aws-sdk-go-v2/service/sts Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
- more idiomatic Go, less memory use, and makes it easier to replace with an argument later Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
@agilgur5 can you rebase? |
Aw dang, another conflict with dependabot. Fixed conflicts now if we could get this in before the next conflict 😅 |
There's an |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
3rd+ merge conflict fixed now 😕 @terrytangyuan @crenshaw-dev could either of you merge this? it will conflict with dependabot about every other day per above |
Partial fix for argoproj/argo-workflows#12031, Vulnerabilities
aws-sdk-go
v1 is only used frompkg
for WorkflowsMotivation
aws-sdk-go
has a vuln in the v1 EncryptionClientModifications
follow the migration instructions
session
usage toconfig.LoadDefaultConfig
per instructionssession.SharedConfigEnable
is no longer necessary per instructionsconfig.WithRegion
mention in the instructionsConfig.Credentials
still exists, but the function is nowRetrieve(context)
instead ofGet
Credentials
struct otherwise looks the same, has theAccessKeyId
,SecretAccessKey
, andSessionToken
that were used in v1config
instead of asession
to create a client, then useNewAssumeRoleProvider
instead of `NewCredentialsNOTE: I used
context.Background()
for all of the contexts that are now requiredBackground
as a defaultVerification
go.mod
has latest versions (e.g.config
released v1.19.0 this week)make build
andmake test
pass successfully. Did not test this live however as that needs to be done downstream