Aws-sdk-go: If aws_secret_access_key is /\d{40}/, it becomes IntegerType

Created on 3 Nov 2018  Â·  4Comments  Â·  Source: aws/aws-sdk-go

Please fill out the sections below to help us address your issue.

Version of AWS SDK for Go?

  • v1.15.68

Version of Go (go version)?

  • go version go1.11.1 darwin/amd64

What issue did you see?

Steps to reproduce

~/.aws/credentials

[default]
aws_access_key_id = AKIAIOSFODNN7EXAMPLE
aws_secret_access_key = 0123456789012345678901234567890123456789
  add_config 'secrets.patterns' "${opt_quote}${aws}(SECRET|secret|Secret)?_?(ACCESS|access|Access)?_?(KEY|key|Key)${opt_quote}${connect}${opt_quote}[A-Za-z0-9/\+=]{40}${opt_quote}"

reproduce.go

package main

import (
    "fmt"

    "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/credentials"
    "github.com/aws/aws-sdk-go/aws/session"
    "github.com/aws/aws-sdk-go/service/ec2"
)

const (
    region = "ap-northeast-1"
)

func errPanic(err error) {
    if err != nil {
        panic(err)
    }
}

func main() {
    profiles := []string{""}
    for _, profile := range profiles {
        cred := credentials.NewSharedCredentials("", profile)

        sess, err := session.NewSession(&aws.Config{
            Credentials: cred,
            Region:      aws.String(region),
        })
        errPanic(err)  // Panic!!

        svc := ec2.New(sess)
        _, err = svc.DescribeInstances(nil)
        errPanic(err)
    }
}
$ go run reproduce.go
panic: SharedConfigLoadError: failed to load config file, /Users/ngsw/.aws/credentials
caused by: strconv.ParseInt: parsing "0123456789012345678901234567890123456789": value out of range

goroutine 1 [running]:
main.errPanic(...)
        /Users/ngsw/REPO/GO_Dropbox/ec2Tmp.go:16
main.main()
        /Users/ngsw/REPO/GO_Dropbox/ec2Tmp.go:30 +0x2b6
exit status 2
bug

All 4 comments

🤔.oO(but maybe no one is in trouble……)

Hello @ngsw, thank you for reaching out to us and reporting this. I've went ahead and created a PR, #2255, that addresses this. I don't think we should be limiting this check to just a specific key. Please let me know if you have any additional issues.

@xibz thank you :-)

@ngsw - We just merged #2255 in. If you have any additional issues, please let us know!

Was this page helpful?
0 / 5 - 0 ratings