File tree 7 files changed +28
-25
lines changed
7 files changed +28
-25
lines changed Original file line number Diff line number Diff line change 1
1
FROM amazonlinux:2
2
2
3
- COPY secure- exec-linux-amd64 /usr/local/bin/secure- exec
3
+ COPY ./bin/ exec-with-secrets- linux-amd64 /usr/local/bin/exec-with-secrets
4
4
5
- CMD secure- exec
5
+ CMD exec-with-secrets
Original file line number Diff line number Diff line change 1
- module github.com/s12v/secure- exec
1
+ module github.com/s12v/exec-with-secrets
2
2
3
- require github.com/aws/aws-sdk-go-v2 v0.7 .0
3
+ require github.com/aws/aws-sdk-go-v2 v0.8 .0
Original file line number Diff line number Diff line change 1
- github.com/aws/aws-sdk-go-v2 v0.7 .0 h1:a5xRI/tBmUFKuAA0SOyEY2P1YhQb+jVOEI9P/7KfrP0 =
2
- github.com/aws/aws-sdk-go-v2 v0.7 .0 /go.mod h1:17MaCZ9g0q5BIMxwzRQeiv8M3c8+W7iuBnlWAEprcxE =
1
+ github.com/aws/aws-sdk-go-v2 v0.8 .0 h1:IyCzxvwRVe2ehXfi7YMsVxaVU6JvaH58ZO7uPFS3HlY =
2
+ github.com/aws/aws-sdk-go-v2 v0.8 .0 /go.mod h1:sa1GePZ/LfBGI4dSq30f6uR4Tthll8axxtEPvlpXZ8U =
3
3
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c =
4
4
github.com/davecgh/go-spew v1.1.1 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
5
5
github.com/go-sql-driver/mysql v1.4.0 /go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w =
6
6
github.com/golang/protobuf v1.2.0 /go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U =
7
- github.com/gucumber/gucumber v0.0.0-20180127021336-7d5c79e832a2 /go.mod h1:YbdHRK9ViqwGMS0rtRY+1I6faHvVyyurKPIPwifihxI =
8
7
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM =
9
8
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af /go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k =
10
9
github.com/pkg/errors v0.8.0 /go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0 =
11
10
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM =
12
11
github.com/pmezard/go-difflib v1.0.0 /go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4 =
13
- github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 /go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg =
14
12
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w =
15
13
github.com/stretchr/testify v1.2.2 /go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs =
16
14
golang.org/x/net v0.0.0-20180724234803-3673e40ba225 /go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4 =
Original file line number Diff line number Diff line change @@ -2,23 +2,22 @@ package main
2
2
3
3
import (
4
4
"fmt"
5
- "github.com/s12v/secure-exec/provider"
6
- _ "github.com/s12v/secure-exec/provider/awskms"
7
- _ "github.com/s12v/secure-exec/provider/awssecretsmanager"
8
- _ "github.com/s12v/secure-exec/provider/awssecretsmanager"
9
- _ "github.com/s12v/secure-exec/provider/awsssm"
5
+ "github.com/s12v/exec-with-secrets/provider"
6
+ _ "github.com/s12v/exec-with-secrets/provider/awskms"
7
+ _ "github.com/s12v/exec-with-secrets/provider/awssecretsmanager"
8
+ _ "github.com/s12v/exec-with-secrets/provider/awsssm"
10
9
"os"
11
10
"syscall"
12
11
)
13
12
14
13
func main () {
15
14
if len (os .Args ) < 2 {
16
- fmt .Println ("Usage: secure- exec program [args]" )
15
+ fmt .Println ("Usage: exec-with-secrets program [args]" )
17
16
os .Exit (0 )
18
17
}
19
18
20
19
env := provider .Populate (os .Environ ())
21
- syscall .Exec (os .Args [1 ], os .Args [1 :], env );
20
+ syscall .Exec (os .Args [1 ], os .Args [1 :], env )
22
21
23
22
fmt .Printf ("Unable to start %v" , os .Args [1 ])
24
23
os .Exit (1 )
Original file line number Diff line number Diff line change 3
3
package awskms
4
4
5
5
import (
6
+ "context"
6
7
"encoding/base64"
7
8
"errors"
8
9
"fmt"
9
10
"github.com/aws/aws-sdk-go-v2/aws/external"
10
11
"github.com/aws/aws-sdk-go-v2/service/kms"
11
- "github.com/s12v/secure- exec/provider"
12
+ "github.com/s12v/exec-with-secrets /provider"
12
13
"strings"
13
14
)
14
15
@@ -18,7 +19,7 @@ type KmsProvider struct {
18
19
19
20
const prefix = "{aws-kms}"
20
21
21
- var decrypt func (awsKmsClient * kms.KMS , input * kms.DecryptInput ) (* kms.DecryptOutput , error )
22
+ var decrypt func (awsKmsClient * kms.KMS , input * kms.DecryptInput ) (* kms.DecryptOutput , error )
22
23
23
24
func init () {
24
25
cfg , err := external .LoadDefaultAWSConfig ()
@@ -30,8 +31,9 @@ func init() {
30
31
provider .Register (& KmsProvider {kms .New (cfg )})
31
32
}
32
33
33
- func awsDecrypt (awsKmsClient * kms.KMS , input * kms.DecryptInput ) (* kms.DecryptOutput , error ) {
34
- if resp , err := awsKmsClient .DecryptRequest (input ).Send (); err != nil {
34
+ func awsDecrypt (awsKmsClient * kms.KMS , input * kms.DecryptInput ) (* kms.DecryptOutput , error ) {
35
+ ctx := context .Background ()
36
+ if resp , err := awsKmsClient .DecryptRequest (input ).Send (ctx ); err != nil {
35
37
return nil , errors .New (fmt .Sprintf ("KMS error: %v" , err ))
36
38
} else {
37
39
return resp , nil
Original file line number Diff line number Diff line change 3
3
package awssecretsmanager
4
4
5
5
import (
6
+ "context"
6
7
"encoding/json"
7
8
"errors"
8
9
"fmt"
9
10
"github.com/aws/aws-sdk-go-v2/aws"
10
11
"github.com/aws/aws-sdk-go-v2/aws/external"
11
12
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
12
- "github.com/s12v/secure- exec/provider"
13
+ "github.com/s12v/exec-with-secrets /provider"
13
14
"regexp"
14
15
"strings"
15
16
)
@@ -39,7 +40,8 @@ func init() {
39
40
func awsFetch (
40
41
awsClient * secretsmanager.SecretsManager ,
41
42
input * secretsmanager.GetSecretValueInput ) (* secretsmanager.GetSecretValueOutput , error ) {
42
- if resp , err := awsClient .GetSecretValueRequest (input ).Send (); err != nil {
43
+ ctx := context .Background ()
44
+ if resp , err := awsClient .GetSecretValueRequest (input ).Send (ctx ); err != nil {
43
45
return nil , errors .New (fmt .Sprintf ("AWS SecretsManager error: %v" , err ))
44
46
} else {
45
47
return resp , nil
@@ -60,7 +62,7 @@ func (p *SecretsManagerProvider) Decode(val string) (string, error) {
60
62
}
61
63
62
64
func (p * SecretsManagerProvider ) decodeJson (val string , property string ) (string , error ) {
63
- name := val [:len (val )- len (property ) - 2 ]
65
+ name := val [:len (val )- len (property )- 2 ]
64
66
jsobj , err := p .fetchString (name )
65
67
if err != nil {
66
68
return "" , err
Original file line number Diff line number Diff line change 3
3
package awsssm
4
4
5
5
import (
6
+ "context"
6
7
"errors"
7
8
"fmt"
8
9
"github.com/aws/aws-sdk-go-v2/aws/external"
9
10
"github.com/aws/aws-sdk-go-v2/service/ssm"
10
- "github.com/s12v/secure- exec/provider"
11
+ "github.com/s12v/exec-with-secrets /provider"
11
12
"strings"
12
13
)
13
14
@@ -17,7 +18,7 @@ type SsmProvider struct {
17
18
18
19
const prefix = "{aws-ssm}"
19
20
20
- var fetch func (awsSsmClient * ssm.SSM , input * ssm.GetParameterInput ) (* ssm.GetParameterOutput , error )
21
+ var fetch func (awsSsmClient * ssm.SSM , input * ssm.GetParameterInput ) (* ssm.GetParameterOutput , error )
21
22
22
23
func init () {
23
24
cfg , err := external .LoadDefaultAWSConfig ()
@@ -30,7 +31,8 @@ func init() {
30
31
}
31
32
32
33
func awsFetch (awsSsmClient * ssm.SSM , input * ssm.GetParameterInput ) (* ssm.GetParameterOutput , error ) {
33
- if resp , err := awsSsmClient .GetParameterRequest (input ).Send (); err != nil {
34
+ ctx := context .Background ()
35
+ if resp , err := awsSsmClient .GetParameterRequest (input ).Send (ctx ); err != nil {
34
36
return nil , errors .New (fmt .Sprintf ("SSM error: %v" , err ))
35
37
} else {
36
38
return resp , nil
You can’t perform that action at this time.
0 commit comments