Skip to content

Commit d85d6d3

Browse files
authored
Merge branch 'main' into fix/yaml-inline-comment-roundtrip
2 parents eddc3ca + b4107fe commit d85d6d3

10 files changed

Lines changed: 238 additions & 180 deletions

File tree

.github/workflows/cli.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
matrix:
2020
os: [linux, darwin, windows]
2121
arch: [amd64, arm64]
22-
go-version: ['1.24', '1.25', '1.26']
22+
go-version: ['1.25', '1.26']
2323
exclude:
2424
- os: windows
2525
arch: arm64
@@ -69,14 +69,14 @@ jobs:
6969

7070
- name: Upload artifact for ${{ matrix.os }}
7171
if: matrix.os != 'windows'
72-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
72+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
7373
with:
7474
name: sops-${{ matrix.go-version }}-${{ matrix.os }}-${{ matrix.arch }}-${{ github.sha }}
7575
path: sops-${{ matrix.go-version }}-${{ matrix.os }}-${{ matrix.arch }}-${{ github.sha }}
7676

7777
- name: Upload artifact for ${{ matrix.os }}
7878
if: matrix.os == 'windows'
79-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
79+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
8080
with:
8181
name: sops-${{ matrix.go-version }}-${{ matrix.os }}-${{ github.sha }}
8282
path: sops-${{ matrix.go-version }}-${{ matrix.os }}-${{ github.sha }}

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ jobs:
5252
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
5353

5454
- name: Login to GitHub Container Registry
55-
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
55+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
5656
with:
5757
registry: ghcr.io
5858
username: ${{ github.actor }}
5959
password: ${{ secrets.GITHUB_TOKEN }}
6060

6161
- name: Login to Quay.io
62-
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4.0.0
62+
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
6363
with:
6464
registry: quay.io
6565
username: ${{ secrets.QUAY_BOT_USERNAME }}

README.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ For the adventurous, unstable features are available in the `main` branch, which
3030
$ cd $GOPATH/src/github.com/getsops/sops/
3131
$ make install
3232
33-
(requires Go >= 1.19)
33+
(requires Go >= 1.25)
3434

3535
If you don't have Go installed, set it up with:
3636

@@ -325,6 +325,20 @@ switch to the REST client by setting the ``SOPS_GCP_KMS_CLIENT_TYPE`` environmen
325325
$ export SOPS_GCP_KMS_CLIENT_TYPE=rest # Use REST client
326326
$ export SOPS_GCP_KMS_CLIENT_TYPE=grpc # Use gRPC client (default)
327327
328+
For sovereign cloud environments that expose a GCP-compatible KMS API at a
329+
non-standard endpoint (e.g. S3NS/Thales TPC: ``cloudkms.s3nsapis.fr``),
330+
you can override the endpoint or the universe domain:
331+
332+
.. code:: sh
333+
334+
# Override the KMS endpoint directly
335+
$ export SOPS_GCP_KMS_ENDPOINT=cloudkms.example.com:443
336+
337+
# Or derive the endpoint from the universe domain (cloudkms.<domain>:443)
338+
$ export SOPS_GCP_KMS_UNIVERSE_DOMAIN=example.com
339+
340+
.. note:: ``SOPS_GCP_KMS_ENDPOINT`` takes precedence over ``SOPS_GCP_KMS_UNIVERSE_DOMAIN`` if both are set.
341+
328342
Encrypting/decrypting with GCP KMS requires a KMS ResourceID. You can use the
329343
cloud console the get the ResourceID or you can create one using the gcloud
330344
sdk:
@@ -412,12 +426,16 @@ from the commandline:
412426
$ az keyvault create --name $keyvault_name --resource-group sops-rg --location westeurope
413427
$ az keyvault key create --name sops-key --vault-name $keyvault_name --protection software --ops encrypt decrypt
414428
$ az keyvault set-policy --name $keyvault_name --resource-group sops-rg --spn $AZURE_CLIENT_ID \
415-
--key-permissions encrypt decrypt
429+
--key-permissions get encrypt decrypt
416430
# Read the key id:
417431
$ az keyvault key show --name sops-key --vault-name $keyvault_name --query key.kid
418432
419433
https://sops.vault.azure.net/keys/sops-key/some-string
420434
435+
.. note::
436+
437+
The ``get`` key permission is required when the key version is ommited (for example if the URL ends with a trailing slash). In that case SOPS calls the Azure Key Vault API to resolve the latest key version, which requires the ``get`` permission. If you specifty an explicit key version in the URL you can omit ``get``, but this means you will need to update your configuration every time the key is rotated.
438+
421439
Now you can encrypt a file using::
422440
423441
$ sops encrypt --azure-kv https://sops.vault.azure.net/keys/sops-key/some-string test.yaml > test.enc.yaml

age/encrypted_keys.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ package age
1414
import (
1515
"bufio"
1616
"bytes"
17+
"crypto/sha256"
18+
"encoding/base64"
1719
"errors"
1820
"fmt"
1921
"io"
@@ -124,6 +126,8 @@ func unwrapIdentities(location string, reader io.Reader) (ParsedIdentities, erro
124126
if len(contents) == privateKeySizeLimit {
125127
return nil, fmt.Errorf("failed to read '%s': file too long", location)
126128
}
129+
contentsHash := sha256.Sum256(contents)
130+
cacheKey := fmt.Sprintf("SopsAge%s", base64.StdEncoding.EncodeToString(contentsHash[:30]))
127131
IncorrectPassphrase := func() {
128132
conn, err := gpgagent.NewConn()
129133
if err != nil {
@@ -134,7 +138,7 @@ func unwrapIdentities(location string, reader io.Reader) (ParsedIdentities, erro
134138
log.Errorf("failed to close connection with gpg-agent: %s", err)
135139
}
136140
}(conn)
137-
err = conn.RemoveFromCache(location)
141+
err = conn.RemoveFromCache(cacheKey)
138142
if err != nil {
139143
log.Warnf("gpg-agent remove cache request errored: %s", err)
140144
return
@@ -154,8 +158,7 @@ func unwrapIdentities(location string, reader io.Reader) (ParsedIdentities, erro
154158
}(conn)
155159

156160
req := gpgagent.PassphraseRequest{
157-
// TODO is the cachekey good enough?
158-
CacheKey: location,
161+
CacheKey: cacheKey,
159162
Prompt: "Passphrase",
160163
Desc: fmt.Sprintf("Enter passphrase for identity '%s':", location),
161164
}

gcpkms/keysource.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ const (
3030
// SopsGCPKMSClientTypeEnv is the environment variable used to specify the
3131
// GCP KMS client type. Valid values are "grpc" (default) and "rest".
3232
SopsGCPKMSClientTypeEnv = "SOPS_GCP_KMS_CLIENT_TYPE"
33+
// SopsGCPKMSEndpointEnv overrides the GCP KMS endpoint URL. Useful for
34+
// sovereign cloud environments that expose a GCP-compatible KMS API at a
35+
// non-standard endpoint (e.g. S3NS/Thales TPC: cloudkms.s3nsapis.fr).
36+
SopsGCPKMSEndpointEnv = "SOPS_GCP_KMS_ENDPOINT"
37+
// SopsGCPKMSUniverseDomainEnv sets the universe domain for the GCP KMS
38+
// client, which derives the endpoint as cloudkms.{UNIVERSE_DOMAIN}:443.
39+
// Example: "s3nsapis.fr" for S3NS/Thales TPC.
40+
SopsGCPKMSUniverseDomainEnv = "SOPS_GCP_KMS_UNIVERSE_DOMAIN"
3341
// KeyTypeIdentifier is the string used to identify a GCP KMS MasterKey.
3442
KeyTypeIdentifier = "gcp_kms"
3543
)
@@ -320,6 +328,12 @@ func (key *MasterKey) newKMSClient(ctx context.Context) (*kms.KeyManagementClien
320328
// Add extra options.
321329
opts = append(opts, key.clientOpts...)
322330

331+
if endpoint := os.Getenv(SopsGCPKMSEndpointEnv); endpoint != "" {
332+
opts = append(opts, option.WithEndpoint(endpoint))
333+
} else if ud := os.Getenv(SopsGCPKMSUniverseDomainEnv); ud != "" {
334+
opts = append(opts, option.WithUniverseDomain(ud))
335+
}
336+
323337
// Select client type based on inputs.
324338
clientType := strings.ToLower(os.Getenv(SopsGCPKMSClientTypeEnv))
325339
var client *kms.KeyManagementClient

gcpkms/keysource_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,32 @@ func TestMasterKey_createCloudKMSService_withoutCredentials(t *testing.T) {
189189
assert.ErrorContains(t, err, "credentials: could not find default credentials")
190190
}
191191

192+
func TestMasterKey_createCloudKMSService_withEndpointEnv(t *testing.T) {
193+
t.Setenv(SopsGCPKMSEndpointEnv, "cloudkms.example.com:443")
194+
t.Setenv(SopsGoogleCredentialsOAuthTokenEnv, "token")
195+
196+
masterKey := MasterKey{
197+
ResourceID: testResourceID,
198+
}
199+
200+
client, err := masterKey.newKMSClient(context.Background())
201+
assert.NoError(t, err)
202+
assert.Contains(t, client.Connection().Target(), "cloudkms.example.com")
203+
}
204+
205+
func TestMasterKey_createCloudKMSService_withUniverseDomainEnv(t *testing.T) {
206+
t.Setenv(SopsGCPKMSUniverseDomainEnv, "example.com")
207+
t.Setenv(SopsGoogleCredentialsOAuthTokenEnv, "token")
208+
209+
masterKey := MasterKey{
210+
ResourceID: testResourceID,
211+
}
212+
213+
client, err := masterKey.newKMSClient(context.Background())
214+
assert.NoError(t, err)
215+
assert.Contains(t, client.Connection().Target(), "cloudkms.example.com")
216+
}
217+
192218
func newGRPCServer(port string) *grpc.ClientConn {
193219
serv := grpc.NewServer()
194220
kmspb.RegisterKeyManagementServiceServer(serv, &mockKeyManagement)

go.mod

Lines changed: 53 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
module github.com/getsops/sops/v3
22

3-
go 1.24.0
3+
go 1.25.0
44

55
require (
6-
cloud.google.com/go/kms v1.26.0
7-
cloud.google.com/go/storage v1.60.0
6+
cloud.google.com/go/kms v1.29.0
7+
cloud.google.com/go/storage v1.62.1
88
filippo.io/age v1.3.1
99
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.0
1010
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.13.1
1111
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.4.0
12-
github.com/ProtonMail/go-crypto v1.3.0
13-
github.com/aws/aws-sdk-go-v2 v1.41.1
14-
github.com/aws/aws-sdk-go-v2/config v1.32.9
15-
github.com/aws/aws-sdk-go-v2/credentials v1.19.9
16-
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.22.2
17-
github.com/aws/aws-sdk-go-v2/service/kms v1.50.0
18-
github.com/aws/aws-sdk-go-v2/service/s3 v1.96.0
19-
github.com/aws/aws-sdk-go-v2/service/sts v1.41.6
12+
github.com/ProtonMail/go-crypto v1.4.1
13+
github.com/aws/aws-sdk-go-v2 v1.41.5
14+
github.com/aws/aws-sdk-go-v2/config v1.32.15
15+
github.com/aws/aws-sdk-go-v2/credentials v1.19.14
16+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.22.14
17+
github.com/aws/aws-sdk-go-v2/service/kms v1.50.4
18+
github.com/aws/aws-sdk-go-v2/service/s3 v1.99.0
19+
github.com/aws/aws-sdk-go-v2/service/sts v1.41.10
2020
github.com/blang/semver v3.5.1+incompatible
21-
github.com/fatih/color v1.18.0
21+
github.com/fatih/color v1.19.0
2222
github.com/getsops/gopgagent v0.0.0-20241224165529-7044f28e491e
2323
github.com/google/go-cmp v0.7.0
2424
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
2525
github.com/goware/prefixer v0.0.0-20160118172347-395022866408
2626
github.com/hashicorp/go-cleanhttp v0.5.2
27-
github.com/hashicorp/vault/api v1.22.0
28-
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.187
29-
github.com/lib/pq v1.11.2
27+
github.com/hashicorp/vault/api v1.23.0
28+
github.com/huaweicloud/huaweicloud-sdk-go-v3 v0.1.192
29+
github.com/lib/pq v1.12.3
3030
github.com/mitchellh/go-homedir v1.1.0
3131
github.com/mitchellh/go-wordwrap v1.0.1
3232
github.com/ory/dockertest/v3 v3.12.0
@@ -35,26 +35,26 @@ require (
3535
github.com/stretchr/testify v1.11.1
3636
github.com/urfave/cli v1.22.17
3737
go.yaml.in/yaml/v3 v3.0.4
38-
golang.org/x/crypto v0.48.0
39-
golang.org/x/net v0.50.0
40-
golang.org/x/oauth2 v0.35.0
41-
golang.org/x/sys v0.41.0
42-
golang.org/x/term v0.40.0
43-
google.golang.org/api v0.267.0
44-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260203192932-546029d2fa20
45-
google.golang.org/grpc v1.79.3
38+
golang.org/x/crypto v0.49.0
39+
golang.org/x/net v0.52.0
40+
golang.org/x/oauth2 v0.36.0
41+
golang.org/x/sys v0.43.0
42+
golang.org/x/term v0.41.0
43+
google.golang.org/api v0.274.0
44+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260401024825-9d38bb4040a9
45+
google.golang.org/grpc v1.80.0
4646
google.golang.org/protobuf v1.36.11
4747
gopkg.in/ini.v1 v1.67.1
4848
)
4949

5050
require (
5151
cel.dev/expr v0.25.1 // indirect
5252
cloud.google.com/go v0.123.0 // indirect
53-
cloud.google.com/go/auth v0.18.1 // indirect
53+
cloud.google.com/go/auth v0.19.0 // indirect
5454
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
5555
cloud.google.com/go/compute/metadata v0.9.0 // indirect
56-
cloud.google.com/go/iam v1.5.3 // indirect
57-
cloud.google.com/go/longrunning v0.8.0 // indirect
56+
cloud.google.com/go/iam v1.7.0 // indirect
57+
cloud.google.com/go/longrunning v0.9.0 // indirect
5858
cloud.google.com/go/monitoring v1.24.3 // indirect
5959
dario.cat/mergo v1.0.1 // indirect
6060
filippo.io/edwards25519 v1.1.1 // indirect
@@ -63,25 +63,24 @@ require (
6363
github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.2.0 // indirect
6464
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
6565
github.com/AzureAD/microsoft-authentication-library-for-go v1.6.0 // indirect
66-
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.30.0 // indirect
66+
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.31.0 // indirect
6767
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.55.0 // indirect
6868
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.55.0 // indirect
6969
github.com/Microsoft/go-winio v0.6.2 // indirect
7070
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
71-
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.4 // indirect
72-
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.17 // indirect
73-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.17 // indirect
74-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.17 // indirect
75-
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 // indirect
76-
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.17 // indirect
77-
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.4 // indirect
78-
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.8 // indirect
79-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.17 // indirect
80-
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.17 // indirect
81-
github.com/aws/aws-sdk-go-v2/service/signin v1.0.5 // indirect
82-
github.com/aws/aws-sdk-go-v2/service/sso v1.30.10 // indirect
83-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.14 // indirect
84-
github.com/aws/smithy-go v1.24.0 // indirect
71+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.8 // indirect
72+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.21 // indirect
73+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.21 // indirect
74+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.21 // indirect
75+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.22 // indirect
76+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.7 // indirect
77+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.9.13 // indirect
78+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.21 // indirect
79+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.19.21 // indirect
80+
github.com/aws/aws-sdk-go-v2/service/signin v1.0.9 // indirect
81+
github.com/aws/aws-sdk-go-v2/service/sso v1.30.15 // indirect
82+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.19 // indirect
83+
github.com/aws/smithy-go v1.24.2 // indirect
8584
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
8685
github.com/cespare/xxhash/v2 v2.3.0 // indirect
8786
github.com/cloudflare/circl v1.6.3 // indirect
@@ -98,16 +97,16 @@ require (
9897
github.com/envoyproxy/go-control-plane/envoy v1.36.0 // indirect
9998
github.com/envoyproxy/protoc-gen-validate v1.3.0 // indirect
10099
github.com/felixge/httpsnoop v1.0.4 // indirect
101-
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
100+
github.com/go-jose/go-jose/v4 v4.1.4 // indirect
102101
github.com/go-logr/logr v1.4.3 // indirect
103102
github.com/go-logr/stdr v1.2.2 // indirect
104103
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
105104
github.com/goccy/go-yaml v1.9.8 // indirect
106105
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
107106
github.com/google/s2a-go v0.1.9 // indirect
108107
github.com/google/uuid v1.6.0 // indirect
109-
github.com/googleapis/enterprise-certificate-proxy v0.3.11 // indirect
110-
github.com/googleapis/gax-go/v2 v2.17.0 // indirect
108+
github.com/googleapis/enterprise-certificate-proxy v0.3.14 // indirect
109+
github.com/googleapis/gax-go/v2 v2.21.0 // indirect
111110
github.com/hashicorp/errwrap v1.1.0 // indirect
112111
github.com/hashicorp/go-multierror v1.1.1 // indirect
113112
github.com/hashicorp/go-retryablehttp v0.7.8 // indirect
@@ -146,16 +145,16 @@ require (
146145
go.opentelemetry.io/contrib/detectors/gcp v1.39.0 // indirect
147146
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 // indirect
148147
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
149-
go.opentelemetry.io/otel v1.40.0 // indirect
150-
go.opentelemetry.io/otel/metric v1.40.0 // indirect
151-
go.opentelemetry.io/otel/sdk v1.40.0 // indirect
152-
go.opentelemetry.io/otel/sdk/metric v1.40.0 // indirect
153-
go.opentelemetry.io/otel/trace v1.40.0 // indirect
154-
golang.org/x/sync v0.19.0 // indirect
155-
golang.org/x/text v0.34.0 // indirect
156-
golang.org/x/time v0.14.0 // indirect
148+
go.opentelemetry.io/otel v1.43.0 // indirect
149+
go.opentelemetry.io/otel/metric v1.43.0 // indirect
150+
go.opentelemetry.io/otel/sdk v1.43.0 // indirect
151+
go.opentelemetry.io/otel/sdk/metric v1.43.0 // indirect
152+
go.opentelemetry.io/otel/trace v1.43.0 // indirect
153+
golang.org/x/sync v0.20.0 // indirect
154+
golang.org/x/text v0.35.0 // indirect
155+
golang.org/x/time v0.15.0 // indirect
157156
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
158-
google.golang.org/genproto v0.0.0-20260128011058-8636f8732409 // indirect
159-
google.golang.org/genproto/googleapis/api v0.0.0-20260203192932-546029d2fa20 // indirect
157+
google.golang.org/genproto v0.0.0-20260319201613-d00831a3d3e7 // indirect
158+
google.golang.org/genproto/googleapis/api v0.0.0-20260401024825-9d38bb4040a9 // indirect
160159
gopkg.in/yaml.v3 v3.0.1 // indirect
161160
)

0 commit comments

Comments
 (0)