Skip to content

Commit 9c7baf7

Browse files
authored
Merge pull request #783 from jetstack/chart-update
[VC-48429] Helm chart updates for encrypted secrets
2 parents b7cf60b + 5541608 commit 9c7baf7

12 files changed

Lines changed: 71 additions & 16 deletions

File tree

cmd/agent_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"os"
88
"os/exec"
99
"path/filepath"
10+
"strings"
1011
"testing"
1112
"time"
1213

@@ -32,6 +33,10 @@ func TestOutputModes(t *testing.T) {
3233
})
3334

3435
t.Run("machinehub", func(t *testing.T) {
36+
if strings.ToLower(os.Getenv("ARK_LIVE_TEST")) != "true" {
37+
t.Skip("set ARK_LIVE_TEST=true to run this test against the live service")
38+
return
39+
}
3540
arktesting.SkipIfNoEnv(t)
3641

3742
t.Log("This test runs against a live service and has been known to flake. If you see timeout issues it's possible that the test is flaking and it could be unrelated to your changes.")

deploy/charts/disco-agent/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ kubectl logs deployments/disco-agent --namespace "${NAMESPACE}" --follow
9191
> ```
9292
9393
This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/
94+
#### **acceptTerms** ~ `bool`
95+
> Default value:
96+
> ```yaml
97+
> false
98+
> ```
99+
100+
Must be set to indicate that you have read and accepted the CyberArk Terms of Service. If false, the helm chart will fail to install and will print a message with instructions on how to accept the TOS.
94101
#### **image.repository** ~ `string`
95102
> Default value:
96103
> ```yaml
@@ -298,10 +305,11 @@ This description will be associated with the data that the agent uploads to the
298305
#### **config.sendSecretValues** ~ `bool`
299306
> Default value:
300307
> ```yaml
301-
> false
308+
> true
302309
> ```
303310
304-
Enable sending of Secret values to CyberArk in addition to metadata. Metadata is always sent, but the actual values of Secrets are not sent by default. When enabled, Secret data is encrypted using envelope encryption using a key managed by CyberArk. Default: false (but default will change to true for a future release)
311+
Enable sending of Secret values to CyberArk in addition to metadata. Metadata is always sent, but the actual values of Secrets are not sent by default. When enabled, Secret data is encrypted using envelope encryption using a key managed by CyberArk, fetched from the Discovery and Context service.
312+
Default: true
305313
#### **authentication.secretName** ~ `string`
306314
> Default value:
307315
> ```yaml

deploy/charts/disco-agent/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{{- if not .Values.acceptTerms }}
2+
{{- fail "\n\n=================================================================\n Terms & Conditions Notice\n=================================================================\n\nBefore installing this application, you must review and accept\nthe terms and conditions available at:\nhttps://www.cyberark.com/contract-terms/\n\nTo proceed with installation, you must indicate acceptance by\nsetting:\n\n - In your values file: acceptTerms: true\n or\n - Via the Helm flag: --set acceptTerms=true\n\nBy continuing with the next command, you confirm that you have\nreviewed and accepted these terms and conditions.\n\n=================================================================\n" }}
3+
{{- end }}
14
apiVersion: apps/v1
25
kind: Deployment
36
metadata:

deploy/charts/disco-agent/values.schema.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"helm-values": {
44
"additionalProperties": false,
55
"properties": {
6+
"acceptTerms": {
7+
"$ref": "#/$defs/helm-values.acceptTerms"
8+
},
69
"affinity": {
710
"$ref": "#/$defs/helm-values.affinity"
811
},
@@ -84,6 +87,11 @@
8487
},
8588
"type": "object"
8689
},
90+
"helm-values.acceptTerms": {
91+
"default": false,
92+
"description": "Must be set to indicate that you have read and accepted the CyberArk Terms of Service. If false, the helm chart will fail to install and will print a message with instructions on how to accept the TOS.",
93+
"type": "boolean"
94+
},
8795
"helm-values.affinity": {
8896
"default": {},
8997
"type": "object"
@@ -152,8 +160,8 @@
152160
"type": "string"
153161
},
154162
"helm-values.config.sendSecretValues": {
155-
"default": false,
156-
"description": "Enable sending of Secret values to CyberArk in addition to metadata. Metadata is always sent, but the actual values of Secrets are not sent by default. When enabled, Secret data is encrypted using envelope encryption using a key managed by CyberArk. Default: false (but default will change to true for a future release)",
163+
"default": true,
164+
"description": "Enable sending of Secret values to CyberArk in addition to metadata. Metadata is always sent, but the actual values of Secrets are not sent by default. When enabled, Secret data is encrypted using envelope encryption using a key managed by CyberArk, fetched from the Discovery and Context service.\nDefault: true",
157165
"type": "boolean"
158166
},
159167
"helm-values.extraArgs": {

deploy/charts/disco-agent/values.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/
66
replicaCount: 1
77

8+
# Must be set to indicate that you have read and accepted the CyberArk Terms of Service. If false, the helm chart will fail to install and will print a message with instructions on how to accept the TOS.
9+
acceptTerms: false
10+
811
# This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/
912
image:
1013
repository: ""
@@ -157,9 +160,9 @@ config:
157160
# Enable sending of Secret values to CyberArk in addition to metadata.
158161
# Metadata is always sent, but the actual values of Secrets are not sent by default.
159162
# When enabled, Secret data is encrypted using envelope encryption using
160-
# a key managed by CyberArk.
161-
# Default: false (but default will change to true for a future release)
162-
sendSecretValues: false
163+
# a key managed by CyberArk, fetched from the Discovery and Context service.
164+
# Default: true
165+
sendSecretValues: true
163166

164167
authentication:
165168
secretName: agent-credentials

hack/ark/test-e2e.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ kubectl apply -f "${root_dir}/hack/ark/cluster-external-secret.yaml"
101101

102102
# We use a non-existent tag and omit the `--version` flag, to work around a Helm
103103
# v4 bug. See: https://github.com/helm/helm/issues/31600
104-
# TODO: shouldn't need to set config.sendSecretValues because it will default to true in future
105104
helm upgrade agent "oci://${ARK_CHART}:NON_EXISTENT_TAG@${ARK_CHART_DIGEST}" \
106105
--install \
107106
--wait \
@@ -114,7 +113,7 @@ helm upgrade agent "oci://${ARK_CHART}:NON_EXISTENT_TAG@${ARK_CHART_DIGEST}" \
114113
--set config.clusterName="e2e-test-cluster" \
115114
--set config.clusterDescription="A temporary cluster for E2E testing. Contact @wallrj-cyberark." \
116115
--set config.period=60s \
117-
--set config.sendSecretValues=true \
116+
--set acceptTerms=true \
118117
--set-json "podLabels={\"disco-agent.cyberark.cloud/test-id\": \"${RANDOM}\"}"
119118

120119
kubectl rollout status deployments/disco-agent --namespace "${NAMESPACE}"

internal/cyberark/client_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package cyberark_test
22

33
import (
44
"crypto/x509"
5+
"os"
6+
"strings"
57
"testing"
68

79
"github.com/jetstack/venafi-connection-lib/http_client"
@@ -63,6 +65,11 @@ func TestCyberArkClient_PutSnapshot_MockAPI(t *testing.T) {
6365
// go test ./internal/cyberark \
6466
// -v -count 1 -run TestCyberArkClient_PutSnapshot_RealAPI -args -testing.v 6
6567
func TestCyberArkClient_PutSnapshot_RealAPI(t *testing.T) {
68+
if strings.ToLower(os.Getenv("ARK_LIVE_TEST")) != "true" {
69+
t.Skip("set ARK_LIVE_TEST=true to run this test against the live service")
70+
return
71+
}
72+
6673
arktesting.SkipIfNoEnv(t)
6774

6875
t.Log("This test runs against a live service and has been known to flake. If you see timeout issues it's possible that the test is flaking and it could be unrelated to your changes.")

internal/cyberark/dataupload/dataupload.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,25 @@ func (c *CyberArkClient) PutSnapshot(ctx context.Context, snapshot Snapshot) err
176176
return nil
177177
}
178178

179+
const SigV4Support = "sigv4"
180+
179181
// RetrievePresignedUploadURLRequest is the JSON body sent to the inventory API to request a presigned upload URL.
180182
type RetrievePresignedUploadURLRequest struct {
181183
ClusterID string `json:"cluster_id"`
182184
Checksum string `json:"checksum_sha256"`
183185

184186
// AgentVersion is the v-prefixed version of the agent uploading the snapshot.
185-
// Note that the backend relies on this version being v-prefixed semver.
187+
// Note that some versions of the backend rely on this version being v-prefixed semver,
188+
// but that requirement was dropped in favour of the SigV4Support field below.
186189
AgentVersion string `json:"agent_version"`
187190

188191
// FileSize is the size of the data we'll upload in bytes
189192
FileSize int64 `json:"file_size"`
193+
194+
// SignatureVersion allows the agent to specify which version of AWS's signature scheme it expects for the presigned URL.
195+
// Older versions of the agent will not send this. All versions which support this field will unconditionally set it to the
196+
// value of SigV4Support, so the backend can rely on this field being set.
197+
SignatureVersion string `json:"signature_version"`
190198
}
191199

192200
func (c *CyberArkClient) retrievePresignedUploadURL(ctx context.Context, checksum string, clusterID string, fileSize int64) (string, string, error) {
@@ -196,10 +204,11 @@ func (c *CyberArkClient) retrievePresignedUploadURL(ctx context.Context, checksu
196204
}
197205

198206
request := RetrievePresignedUploadURLRequest{
199-
ClusterID: clusterID,
200-
Checksum: checksum,
201-
AgentVersion: version.PreflightVersion,
202-
FileSize: fileSize,
207+
ClusterID: clusterID,
208+
Checksum: checksum,
209+
AgentVersion: version.PreflightVersion,
210+
FileSize: fileSize,
211+
SignatureVersion: SigV4Support,
203212
}
204213

205214
encodedBody := &bytes.Buffer{}

internal/cyberark/dataupload/mock.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ func (mds *mockDataUploadServer) handleSnapshotLinks(w http.ResponseWriter, r *h
132132
return
133133
}
134134

135+
if req.SignatureVersion != SigV4Support {
136+
http.Error(w, fmt.Sprintf("post body does not set signature_version=%s", SigV4Support), http.StatusInternalServerError)
137+
return
138+
}
139+
135140
if req.AgentVersion != version.PreflightVersion {
136141
http.Error(w, fmt.Sprintf("post body contains unexpected agent version: %s", req.AgentVersion), http.StatusInternalServerError)
137142
return

internal/envelope/rsa/encryptor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ func (e *Encryptor) Encrypt(ctx context.Context, data []byte) (*envelope.Encrypt
5353
}
5454

5555
// Encrypt using RSA-OAEP-256 for key algorithm and A256GCM for content encryption
56-
// TODO: in go1.26+, consider using secret.Do to wrap this call, since it will generate an AES key
56+
// TODO: When standardised, consider using secret.Do to wrap this call, since it will generate an AES key
57+
// (see https://pkg.go.dev/runtime/secret)
5758
encrypted, err := jwe.Encrypt(
5859
data,
5960
jwe.WithKey(jwa.RSA_OAEP_256(), key.Key, jwe.WithPerRecipientHeaders(headers)),

0 commit comments

Comments
 (0)