Skip to content

Commit e1edc05

Browse files
authored
Merge pull request #1056 from mozilla/develop
v3.7.3
2 parents 86f500d + 1fb588e commit e1edc05

20 files changed

Lines changed: 1348 additions & 296 deletions

File tree

.circleci/config.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,22 @@ jobs:
1818
resource_class: large
1919
steps:
2020
- checkout
21-
- setup_remote_docker
21+
- setup_remote_docker:
22+
version: 20.10.11
2223
- run:
2324
name: Build containers
2425
command: |
2526
docker build -t mozilla/sops .
2627
docker tag mozilla/sops "mozilla/sops:$CIRCLE_SHA1"
28+
- run:
29+
name: Build containers (alpine)
30+
command: |
31+
# Just to ensure the container can be built.
32+
docker build -f Dockerfile.alpine -t mozilla/sops:alpine .
2733
2834
push:
29-
machine: true
35+
machine:
36+
image: ubuntu-2004:202111-02
3037
resource_class: large
3138
steps:
3239
- checkout

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
3535
- name: Set RELEASE_NUMBER
3636
run: echo "RELEASE_NUMBER=$(echo $RELEASE_VERSION | cut -c2-)" >> $GITHUB_ENV
37+
- name: Build linux amd64 binary
38+
run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -mod vendor -o dist/sops-${{ env.RELEASE_VERSION }}.linux.amd64 go.mozilla.org/sops/v3/cmd/sops && cp dist/sops-${{ env.RELEASE_VERSION }}.linux.amd64 dist/sops-${{ env.RELEASE_VERSION }}.linux
3739
- name: Build linux arm64 binary
3840
run: GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -mod vendor -o dist/sops-${{ env.RELEASE_VERSION }}.linux.arm64 go.mozilla.org/sops/v3/cmd/sops
3941
- name: Build darwin amd64 binary
@@ -44,8 +46,6 @@ jobs:
4446
run: GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -mod vendor -o dist/sops-${{ env.RELEASE_VERSION }}.darwin.arm64 go.mozilla.org/sops/v3/cmd/sops
4547
- name: Build windows binary
4648
run: GOOS=windows CGO_ENABLED=0 go build -mod vendor -o dist/sops-${{ env.RELEASE_VERSION }}.exe go.mozilla.org/sops/v3/cmd/sops
47-
- name: Copy already built linux binary
48-
run: cp tmppkg/usr/local/bin/sops dist/sops-${{ env.RELEASE_VERSION }}.linux && cp tmppkg/usr/local/bin/sops dist/sops-${{ env.RELEASE_VERSION }}.linux.amd64
4949
- name: Create release
5050
uses: "mozilla/action-automatic-releases@latest"
5151
with:

CHANGELOG.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
Changelog
22
=========
33

4+
3.7.3
5+
-----
6+
Changes:
7+
8+
* Upgrade dependencies (#1024, #1045)
9+
* Build alpine container in CI (#1018, #1032, #1025)
10+
* keyservice: accept KeyServiceServer in LocalClient (#1035)
11+
* Add support for GCP Service Account within `GOOGLE_CREDENTIALS` (#953)
12+
13+
Bug fixes:
14+
15+
* Upload the correct binary for the linux amd64 build (#1026)
16+
* Fix bug when specifying multiple age recipients (#966)
17+
* Allow for empty yaml maps (#908)
18+
* Limit AWS role names to 64 characters (#1037)
19+
420
3.7.2
521
-----
622
Changes:

Dockerfile.alpine

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
FROM golang:1.12-alpine3.10 AS builder
21
FROM golang:1.17-alpine3.15 AS builder
32

43
RUN apk --no-cache add make

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ download-index:
113113
bash make_download_page.sh
114114

115115
mock:
116-
go get github.com/vektra/mockery/.../
116+
go install github.com/vektra/mockery/.../
117117
mockery -dir vendor/github.com/aws/aws-sdk-go/service/kms/kmsiface/ -name KMSAPI -output kms/mocks
118118

119119
.PHONY: all test generate clean vendor functional-tests mock

age/keys.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# created: 2020-07-18T03:16:47-07:00
22
# public key: age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw
33
AGE-SECRET-KEY-1NJT5YCS2LWU4V4QAJQ6R4JNU7LXPDX602DZ9NUFANVU5GDTGUWCQ5T59M6
4+
# created: 2021-12-12T01:39:30+01:00
5+
# public key: age1tmaae3ld5vpevmsh5yacsauzx8jetg300mpvc4ugp5zr5l6ssq9sla97ep
6+
AGE-SECRET-KEY-1T0Z66WSXS6RMNCPSL7P2E8N4Q7SUD8VMG9ND27S08JL7Y2XAU9EQECHDS7

age/keysource.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func MasterKeysFromRecipients(commaSeparatedRecipients string) ([]*MasterKey, er
184184
var keys []*MasterKey
185185

186186
for _, recipient := range recipients {
187-
key, err := MasterKeyFromRecipient(recipient)
187+
key, err := masterKeyFromRecipient(recipient)
188188

189189
if err != nil {
190190
return nil, err
@@ -196,8 +196,8 @@ func MasterKeysFromRecipients(commaSeparatedRecipients string) ([]*MasterKey, er
196196
return keys, nil
197197
}
198198

199-
// MasterKeyFromRecipient takes a Bech32-encoded public key and returns a new MasterKey.
200-
func MasterKeyFromRecipient(recipient string) (*MasterKey, error) {
199+
// masterKeyFromRecipient takes a Bech32-encoded public key and returns a new MasterKey.
200+
func masterKeyFromRecipient(recipient string) (*MasterKey, error) {
201201
recipient = strings.TrimSpace(recipient)
202202
parsedRecipient, err := parseRecipient(recipient)
203203

age/keysource_test.go

Lines changed: 75 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,76 +21,131 @@ func TestMasterKeysFromRecipientsEmpty(t *testing.T) {
2121
assert.Equal(recipients, make([]*MasterKey, 0))
2222
}
2323

24-
func TestMasterKeyFromRecipientWithLeadingAndTrailingSpaces(t *testing.T) {
24+
func TestMasterKeyFromRecipientWithLeadingAndTrailingSpacesSingle(t *testing.T) {
2525
assert := assert.New(t)
2626

27-
key, err := MasterKeyFromRecipient(" age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw ")
27+
commaSeparatedRecipients := " age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw "
28+
keys, err := MasterKeysFromRecipients(commaSeparatedRecipients)
2829

2930
assert.NoError(err)
3031

31-
assert.Equal(key.Recipient, "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw")
32+
assert.Equal(len(keys), 1)
33+
assert.Equal(keys[0].Recipient, "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw")
3234
}
3335

34-
func TestAge(t *testing.T) {
36+
func TestMasterKeyFromRecipientWithLeadingAndTrailingSpacesMultiple(t *testing.T) {
3537
assert := assert.New(t)
3638

37-
key, err := MasterKeyFromRecipient("age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw")
39+
commaSeparatedRecipients := " age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw , age1tmaae3ld5vpevmsh5yacsauzx8jetg300mpvc4ugp5zr5l6ssq9sla97ep "
40+
keys, err := MasterKeysFromRecipients(commaSeparatedRecipients)
3841

3942
assert.NoError(err)
40-
assert.Equal("age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw", key.ToString())
4143

42-
dataKey := []byte("abcdefghijklmnopqrstuvwxyz123456")
44+
assert.Equal(len(keys), 2)
45+
assert.Equal(keys[0].Recipient, "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw")
46+
assert.Equal(keys[1].Recipient, "age1tmaae3ld5vpevmsh5yacsauzx8jetg300mpvc4ugp5zr5l6ssq9sla97ep")
47+
}
48+
49+
func TestMasterKeysFromRecipientsWithSingle(t *testing.T) {
50+
assert := assert.New(t)
51+
52+
commaSeparatedRecipients := "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw"
53+
keys, err := MasterKeysFromRecipients(commaSeparatedRecipients)
4354

44-
err = key.Encrypt(dataKey)
4555
assert.NoError(err)
4656

47-
_, filename, _, _ := runtime.Caller(0)
48-
err = os.Setenv(SopsAgeKeyFileEnv, path.Join(path.Dir(filename), "keys.txt"))
57+
assert.Equal(len(keys), 1)
58+
assert.Equal(keys[0].Recipient, "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw")
59+
}
60+
61+
func TestMasterKeysFromRecipientsWithMultiple(t *testing.T) {
62+
assert := assert.New(t)
63+
64+
commaSeparatedRecipients := "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw,age1tmaae3ld5vpevmsh5yacsauzx8jetg300mpvc4ugp5zr5l6ssq9sla97ep"
65+
keys, err := MasterKeysFromRecipients(commaSeparatedRecipients)
66+
4967
assert.NoError(err)
5068

51-
decryptedKey, err := key.Decrypt()
69+
assert.Equal(len(keys), 2)
70+
assert.Equal(keys[0].Recipient, "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw")
71+
assert.Equal(keys[1].Recipient, "age1tmaae3ld5vpevmsh5yacsauzx8jetg300mpvc4ugp5zr5l6ssq9sla97ep")
72+
}
73+
74+
func TestAge(t *testing.T) {
75+
assert := assert.New(t)
76+
77+
commaSeparatedRecipients := "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw,age1tmaae3ld5vpevmsh5yacsauzx8jetg300mpvc4ugp5zr5l6ssq9sla97ep"
78+
keys, err := MasterKeysFromRecipients(commaSeparatedRecipients)
79+
5280
assert.NoError(err)
53-
assert.Equal(dataKey, decryptedKey)
81+
82+
assert.Equal(len(keys), 2)
83+
assert.Equal(keys[0].Recipient, "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw")
84+
assert.Equal(keys[1].Recipient, "age1tmaae3ld5vpevmsh5yacsauzx8jetg300mpvc4ugp5zr5l6ssq9sla97ep")
85+
86+
dataKey := []byte("abcdefghijklmnopqrstuvwxyz123456")
87+
88+
for _, key := range keys {
89+
err = key.Encrypt(dataKey)
90+
assert.NoError(err)
91+
92+
_, filename, _, _ := runtime.Caller(0)
93+
err = os.Setenv("SOPS_AGE_KEY_FILE", path.Join(path.Dir(filename), "keys.txt"))
94+
assert.NoError(err)
95+
96+
decryptedKey, err := key.Decrypt()
97+
assert.NoError(err)
98+
assert.Equal(dataKey, decryptedKey)
99+
}
100+
54101
}
55102

56103
func TestAgeDotEnv(t *testing.T) {
57104
assert := assert.New(t)
58105

59-
key, err := MasterKeyFromRecipient("age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw")
106+
commaSeparatedRecipients := "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw,age1tmaae3ld5vpevmsh5yacsauzx8jetg300mpvc4ugp5zr5l6ssq9sla97ep"
107+
keys, err := MasterKeysFromRecipients(commaSeparatedRecipients)
60108

61109
assert.NoError(err)
62-
assert.Equal("age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw", key.ToString())
110+
111+
assert.Equal(len(keys), 2)
112+
assert.Equal(keys[0].Recipient, "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw")
113+
assert.Equal(keys[1].Recipient, "age1tmaae3ld5vpevmsh5yacsauzx8jetg300mpvc4ugp5zr5l6ssq9sla97ep")
63114

64115
dotenv := `IMAGE_PREFIX=repo/service-
65116
APPLICATION_KEY=K6pfAWuUVND9Fz5SC7jmA6pfAWuUVND9Fz5SC7jmA
66117
KEY_ID=003683d721f2ae683d721f2a1
67118
DOMAIN=files.127.0.0.1.nip.io`
68119
dataKey := []byte(dotenv)
69120

70-
err = key.Encrypt(dataKey)
121+
err = keys[0].Encrypt(dataKey)
71122
assert.NoError(err)
72123

73124
_, filename, _, _ := runtime.Caller(0)
74125
err = os.Setenv(SopsAgeKeyFileEnv, path.Join(path.Dir(filename), "keys.txt"))
75126
defer os.Unsetenv(SopsAgeKeyFileEnv)
76127
assert.NoError(err)
77128

78-
decryptedKey, err := key.Decrypt()
129+
decryptedKey, err := keys[0].Decrypt()
79130
assert.NoError(err)
80131
assert.Equal(dataKey, decryptedKey)
81132
}
82133

83134
func TestAgeEnv(t *testing.T) {
84135
assert := assert.New(t)
85136

86-
key, err := MasterKeyFromRecipient("age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw")
137+
commaSeparatedRecipients := "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw,age1tmaae3ld5vpevmsh5yacsauzx8jetg300mpvc4ugp5zr5l6ssq9sla97ep"
138+
keys, err := MasterKeysFromRecipients(commaSeparatedRecipients)
87139

88140
assert.NoError(err)
89-
assert.Equal("age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw", key.ToString())
141+
142+
assert.Equal(len(keys), 2)
143+
assert.Equal(keys[0].Recipient, "age1yt3tfqlfrwdwx0z0ynwplcr6qxcxfaqycuprpmy89nr83ltx74tqdpszlw")
144+
assert.Equal(keys[1].Recipient, "age1tmaae3ld5vpevmsh5yacsauzx8jetg300mpvc4ugp5zr5l6ssq9sla97ep")
90145

91146
dataKey := []byte("abcdefghijklmnopqrstuvwxyz123456")
92147

93-
err = key.Encrypt(dataKey)
148+
err = keys[0].Encrypt(dataKey)
94149
assert.NoError(err)
95150

96151
_, filename, _, _ := runtime.Caller(0)
@@ -100,7 +155,7 @@ func TestAgeEnv(t *testing.T) {
100155
defer os.Unsetenv(SopsAgeKeyEnv)
101156
assert.NoError(err)
102157

103-
decryptedKey, err := key.Decrypt()
158+
decryptedKey, err := keys[0].Decrypt()
104159
assert.NoError(err)
105160
assert.Equal(dataKey, decryptedKey)
106161
}

cmd/sops/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,14 @@ func main() {
442442
group = append(group, k)
443443
}
444444
for _, recipient := range ageRecipients {
445-
k, err := age.MasterKeyFromRecipient(recipient)
445+
keys, err := age.MasterKeysFromRecipients(recipient)
446446
if err != nil {
447447
log.WithError(err).Error("Failed to add key")
448448
continue
449449
}
450-
group = append(group, k)
450+
for _, key := range keys {
451+
group = append(group, key)
452+
}
451453
}
452454
return groups.Add(groups.AddOpts{
453455
InputPath: c.String("file"),

config/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,13 @@ func getKeyGroupsFromCreationRule(cRule *creationRule, kmsEncryptionContext map[
153153
for _, group := range cRule.KeyGroups {
154154
var keyGroup sops.KeyGroup
155155
for _, k := range group.Age {
156-
key, err := age.MasterKeyFromRecipient(k)
156+
keys, err := age.MasterKeysFromRecipients(k)
157157
if err != nil {
158158
return nil, err
159159
}
160-
keyGroup = append(keyGroup, key)
160+
for _, key := range keys {
161+
keyGroup = append(keyGroup, key)
162+
}
161163
}
162164
for _, k := range group.PGP {
163165
keyGroup = append(keyGroup, pgp.NewMasterKeyFromFingerprint(k))

0 commit comments

Comments
 (0)