Skip to content

Commit

Permalink
remove usage of old aws-sdk-go (v1) (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcacheux authored Feb 22, 2024
1 parent 6fe8cd1 commit 304ac08
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.21
require (
github.com/aquasecurity/go-mock-aws v0.0.0-20240109054747-49e4b5da33cb
github.com/aquasecurity/trivy v0.49.2-0.20240216090457-32a02a95dd06
github.com/aws/aws-sdk-go v1.49.21
github.com/aws/aws-sdk-go-v2 v1.24.1
github.com/aws/aws-sdk-go-v2/config v1.26.6
github.com/aws/aws-sdk-go-v2/credentials v1.16.16
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aws/aws-sdk-go v1.49.21 h1:Rl8KW6HqkwzhATwvXhyr7vD4JFUMi7oXGAw9SrxxIFY=
github.com/aws/aws-sdk-go v1.49.21/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go-v2 v1.24.1 h1:xAojnj+ktS95YZlDf0zxWBkbFtymPeDP+rvUQIH3uAU=
github.com/aws/aws-sdk-go-v2 v1.24.1/go.mod h1:LNh45Br1YAkEKaAqvmE1m8FUx6a5b/V0oAKV7of29b4=
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.4 h1:OCs21ST2LrepDfD3lwlQiOqIGp6JiEUqG84GzTDoyJs=
Expand Down
14 changes: 9 additions & 5 deletions internal/adapters/cloud/aws/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
awssdk "github.com/aws/aws-sdk-go-v2/aws"
s3api "github.com/aws/aws-sdk-go-v2/service/s3"
s3types "github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/liamg/iamgo"

"github.com/aquasecurity/trivy-aws/internal/adapters/cloud/aws"
Expand All @@ -23,6 +22,11 @@ type adapter struct {
api *s3api.Client
}

type awsError interface {
error
Code() string
}

func init() {
aws.RegisterServiceAdapter(&adapter{})
}
Expand Down Expand Up @@ -116,7 +120,7 @@ func (a *adapter) getPublicAccessBlock(bucketName *string, metadata trivyTypes.M
})
if err != nil {
// nolint
if awsError, ok := err.(awserr.Error); ok {
if awsError, ok := err.(awsError); ok {
if awsError.Code() == "NoSuchPublicAccessBlockConfiguration" {
return nil
}
Expand Down Expand Up @@ -146,7 +150,7 @@ func (a *adapter) getBucketPolicies(bucketName *string, metadata trivyTypes.Meta
bucketPolicy, err := a.api.GetBucketPolicy(a.Context(), &s3api.GetBucketPolicyInput{Bucket: bucketName})
if err != nil {
// nolint
if awsError, ok := err.(awserr.Error); ok {
if awsError, ok := err.(awsError); ok {
if awsError.Code() == "NoSuchBucketPolicy" {
return nil
}
Expand Down Expand Up @@ -189,7 +193,7 @@ func (a *adapter) getBucketEncryption(bucketName *string, metadata trivyTypes.Me
encryption, err := a.api.GetBucketEncryption(a.Context(), &s3api.GetBucketEncryptionInput{Bucket: bucketName})
if err != nil {
// nolint
if awsError, ok := err.(awserr.Error); ok {
if awsError, ok := err.(awsError); ok {
if awsError.Code() == "ServerSideEncryptionConfigurationNotFoundError" {
return bucketEncryption
}
Expand Down Expand Up @@ -225,7 +229,7 @@ func (a *adapter) getBucketVersioning(bucketName *string, metadata trivyTypes.Me
versioning, err := a.api.GetBucketVersioning(a.Context(), &s3api.GetBucketVersioningInput{Bucket: bucketName})
if err != nil {
// nolint
if awsError, ok := err.(awserr.Error); ok {
if awsError, ok := err.(awsError); ok {
if awsError.Code() == "NotImplemented" {
return bucketVersioning
}
Expand Down

0 comments on commit 304ac08

Please sign in to comment.