Skip to content

Commit 91b5bb7

Browse files
Merge branch 'main' into feature/aws-publishing-support
Signed-off-by: bruce-szalwinski-he <[email protected]>
2 parents 7d5dddd + 07ded6f commit 91b5bb7

File tree

6 files changed

+126
-83
lines changed

6 files changed

+126
-83
lines changed

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
# Initializes the CodeQL tools for scanning.
3737
- name: Initialize CodeQL
38-
uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
38+
uses: github/codeql-action/init@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
3939
with:
4040
languages: go
4141
# xref: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
@@ -52,6 +52,6 @@ jobs:
5252
make install
5353
5454
- name: Perform CodeQL Analysis
55-
uses: github/codeql-action/analyze@4e94bd11f71e507f7f87df81788dff88d1dacbfb # v4.31.0
55+
uses: github/codeql-action/analyze@0499de31b99561a6d14a36a5f662c2a54f91beee # v4.31.2
5656
with:
5757
category: "/language:go"

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
4444

4545
- name: Setup QEMU
46-
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
46+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
4747

4848
- name: Setup Docker Buildx
4949
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,14 @@ Or if you are logged in you can authorize by generating an access token:
309309
310310
$ export GOOGLE_OAUTH_ACCESS_TOKEN="$(gcloud auth print-access-token)"
311311
312+
By default, SOPS uses the gRPC client to communicate with GCP KMS. You can optionally
313+
switch to the REST client by setting the ``SOPS_GCP_KMS_CLIENT_TYPE`` environment variable:
314+
315+
.. code:: sh
316+
317+
$ export SOPS_GCP_KMS_CLIENT_TYPE=rest # Use REST client
318+
$ export SOPS_GCP_KMS_CLIENT_TYPE=grpc # Use gRPC client (default)
319+
312320
Encrypting/decrypting with GCP KMS requires a KMS ResourceID. You can use the
313321
cloud console the get the ResourceID or you can create one using the gcloud
314322
sdk:

gcpkms/keysource.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ const (
2727
// SopsGoogleCredentialsOAuthTokenEnv is the environment variable used for the
2828
// GCP OAuth 2.0 Token.
2929
SopsGoogleCredentialsOAuthTokenEnv = "GOOGLE_OAUTH_ACCESS_TOKEN"
30+
// SopsGCPKMSClientTypeEnv is the environment variable used to specify the
31+
// GCP KMS client type. Valid values are "grpc" (default) and "rest".
32+
SopsGCPKMSClientTypeEnv = "SOPS_GCP_KMS_CLIENT_TYPE"
3033
// KeyTypeIdentifier is the string used to identify a GCP KMS MasterKey.
3134
KeyTypeIdentifier = "gcp_kms"
3235
)
@@ -68,6 +71,10 @@ type MasterKey struct {
6871
grpcConn *grpc.ClientConn
6972
// grpcDialOpts are the gRPC dial options used to create the gRPC connection.
7073
grpcDialOpts []grpc.DialOption
74+
// useRESTClient indicates whether to use the REST client for GCP KMS.
75+
useRESTClient bool
76+
// clientOpts are the client options used to create the GCP KMS client.
77+
clientOpts []option.ClientOption
7178
}
7279

7380
// NewMasterKeyFromResourceID creates a new MasterKey with the provided resource
@@ -126,6 +133,22 @@ func (d DialOptions) ApplyToMasterKey(key *MasterKey) {
126133
key.grpcDialOpts = d
127134
}
128135

136+
// UseRESTClient configures the MasterKey to use the REST client for GCP KMS.
137+
type UseRESTClient struct{}
138+
139+
// ApplyToMasterKey configures the MasterKey to use the REST client for GCP KMS.
140+
func (UseRESTClient) ApplyToMasterKey(key *MasterKey) {
141+
key.useRESTClient = true
142+
}
143+
144+
// ClientOptions are the client options used to create the GCP KMS client.
145+
type ClientOptions []option.ClientOption
146+
147+
// ApplyToMasterKey configures the ClientOptions on the provided key.
148+
func (c ClientOptions) ApplyToMasterKey(key *MasterKey) {
149+
key.clientOpts = c
150+
}
151+
129152
// Encrypt takes a SOPS data key, encrypts it with GCP KMS, and stores the
130153
// result in the EncryptedKey field.
131154
//
@@ -294,7 +317,19 @@ func (key *MasterKey) newKMSClient(ctx context.Context) (*kms.KeyManagementClien
294317
}
295318
}
296319

297-
client, err := kms.NewKeyManagementClient(ctx, opts...)
320+
// Add extra options.
321+
opts = append(opts, key.clientOpts...)
322+
323+
// Select client type based on inputs.
324+
clientType := strings.ToLower(os.Getenv(SopsGCPKMSClientTypeEnv))
325+
var client *kms.KeyManagementClient
326+
var err error
327+
switch {
328+
case clientType == "rest", key.useRESTClient:
329+
client, err = kms.NewKeyManagementRESTClient(ctx, opts...)
330+
default:
331+
client, err = kms.NewKeyManagementClient(ctx, opts...)
332+
}
298333
if err != nil {
299334
return nil, err
300335
}

go.mod

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,21 @@ go 1.24.0
44

55
require (
66
cloud.google.com/go/kms v1.23.2
7-
cloud.google.com/go/storage v1.57.0
7+
cloud.google.com/go/storage v1.57.1
88
filippo.io/age v1.2.1
9-
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.19.1
9+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.20.0
1010
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.0
1111
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.4.0
1212
github.com/ProtonMail/go-crypto v1.3.0
13-
github.com/aws/aws-sdk-go-v2 v1.39.4
14-
github.com/aws/aws-sdk-go-v2/config v1.31.15
15-
github.com/aws/aws-sdk-go-v2/credentials v1.18.19
16-
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.19.15
17-
github.com/aws/aws-sdk-go-v2/service/kms v1.46.2
18-
github.com/aws/aws-sdk-go-v2/service/s3 v1.88.7
19-
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.39.2
13+
github.com/aws/aws-sdk-go-v2 v1.39.6
14+
github.com/aws/aws-sdk-go-v2/config v1.31.17
15+
github.com/aws/aws-sdk-go-v2/credentials v1.18.21
16+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.4
17+
github.com/aws/aws-sdk-go-v2/service/kms v1.48.0
18+
github.com/aws/aws-sdk-go-v2/service/s3 v1.90.0
19+
github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.39.2
2020
github.com/aws/aws-sdk-go-v2/service/ssm v1.64.2
21-
github.com/aws/aws-sdk-go-v2/service/sts v1.38.9
22-
github.com/aws/smithy-go v1.23.1
21+
github.com/aws/aws-sdk-go-v2/service/sts v1.39.1
2322
github.com/blang/semver v3.5.1+incompatible
2423
github.com/fatih/color v1.18.0
2524
github.com/getsops/gopgagent v0.0.0-20241224165529-7044f28e491e
@@ -39,11 +38,11 @@ require (
3938
go.yaml.in/yaml/v3 v3.0.4
4039
golang.org/x/crypto v0.43.0
4140
golang.org/x/net v0.46.0
42-
golang.org/x/oauth2 v0.32.0
43-
golang.org/x/sys v0.37.0
41+
golang.org/x/oauth2 v0.33.0
42+
golang.org/x/sys v0.38.0
4443
golang.org/x/term v0.36.0
45-
google.golang.org/api v0.253.0
46-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251014184007-4626949a642f
44+
google.golang.org/api v0.255.0
45+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251029180050-ab9386a59fda
4746
google.golang.org/grpc v1.76.0
4847
google.golang.org/protobuf v1.36.10
4948
gopkg.in/ini.v1 v1.67.0
@@ -69,18 +68,19 @@ require (
6968
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.53.0 // indirect
7069
github.com/Microsoft/go-winio v0.6.2 // indirect
7170
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
72-
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.2 // indirect
73-
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.11 // indirect
74-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.11 // indirect
75-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.11 // indirect
71+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.3 // indirect
72+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.13 // indirect
73+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.13 // indirect
74+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.13 // indirect
7675
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 // indirect
77-
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.11 // indirect
78-
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.2 // indirect
79-
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.2 // indirect
80-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.11 // indirect
81-
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.11 // indirect
82-
github.com/aws/aws-sdk-go-v2/service/sso v1.29.8 // indirect
83-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.3 // indirect
76+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.13 // indirect
77+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.3 // indirect
78+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.4 // indirect
79+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.13 // indirect
80+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.13 // indirect
81+
github.com/aws/aws-sdk-go-v2/service/sso v1.30.1 // indirect
82+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.5 // indirect
83+
github.com/aws/smithy-go v1.23.2 // indirect
8484
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
8585
github.com/cespare/xxhash/v2 v2.3.0 // indirect
8686
github.com/cloudflare/circl v1.6.1 // indirect
@@ -122,7 +122,7 @@ require (
122122
github.com/moby/term v0.5.2 // indirect
123123
github.com/opencontainers/go-digest v1.0.0 // indirect
124124
github.com/opencontainers/image-spec v1.1.1 // indirect
125-
github.com/opencontainers/runc v1.2.6 // indirect
125+
github.com/opencontainers/runc v1.2.8 // indirect
126126
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
127127
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
128128
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect

0 commit comments

Comments
 (0)