Skip to content

Commit c4dfed3

Browse files
authored
Merge pull request #476 from snyk/feat/add_ssl_certs
[RUN-848] Feat/add ssl certs
2 parents 5f54557 + aa1db2d commit c4dfed3

File tree

7 files changed

+42
-1
lines changed

7 files changed

+42
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ Finally, create the secret in Kubernetes by running the following command:
5858
kubectl create secret generic snyk-monitor -n snyk-monitor --from-file=./dockercfg.json --from-literal=integrationId=abcd1234-abcd-1234-abcd-1234abcd1234
5959
```
6060

61+
4. If your private registry requires installing certificates (*.crt, *.cert, *.key only) please put them in a folder and create the following ConfigMap:
62+
```shell
63+
kubectl create configmap snyk-monitor-certs -n snyk-monitor --from-file=<path_to_certs_folder>
64+
```
65+
6166
## Installation from YAML files ##
6267

6368
The `kubernetes-monitor` can run in one of two modes: constrained to a single namespace, or with access to the whole cluster.

snyk-monitor-deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ spec:
3030
mountPath: "/srv/app/.docker"
3131
- name: temporary-storage
3232
mountPath: "/var/tmp"
33+
- name: ssl-certs
34+
mountPath: "/srv/app/certs"
3335
env:
3436
- name: SNYK_INTEGRATION_ID
3537
valueFrom:
@@ -101,4 +103,8 @@ spec:
101103
- name: temporary-storage
102104
emptyDir:
103105
sizeLimit: 50Gi
106+
- name: ssl-certs
107+
configMap:
108+
name: snyk-monitor-certs
109+
optional: true
104110
serviceAccountName: snyk-monitor

snyk-monitor/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ Finally, create the secret in Kubernetes by running the following command:
5050
kubectl create secret generic snyk-monitor -n snyk-monitor --from-file=./dockercfg.json --from-literal=integrationId=abcd1234-abcd-1234-abcd-1234abcd1234
5151
```
5252

53+
4. If your private registry requires installing certificates (*.crt, *.cert, *.key only) please put them in a folder and create the following ConfigMap:
54+
```shell
55+
kubectl create configmap snyk-monitor-certs -n snyk-monitor --from-file=<path_to_certs_folder>
56+
```
57+
5358
## Installation from Helm repo ##
5459

5560
Add Snyk's Helm repo:

snyk-monitor/templates/deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ spec:
3232
mountPath: "/srv/app/.docker"
3333
- name: temporary-storage
3434
mountPath: "/var/tmp"
35+
- name: ssl-certs
36+
mountPath: "/srv/app/certs"
3537
env:
3638
- name: SNYK_INTEGRATION_ID
3739
valueFrom:
@@ -79,3 +81,7 @@ spec:
7981
- name: temporary-storage
8082
emptyDir:
8183
sizeLimit: {{ .Values.temporaryStorageSize }}
84+
- name: ssl-certs
85+
configMap:
86+
name: {{ .Values.certsConfigMap }}
87+
optional: true

snyk-monitor/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# The secrets should be created externally, before applying this Helm chart.
66
# The currently used keys within the secret are: "dockercfg.json", "integrationId".
77
monitorSecrets: snyk-monitor
8+
certsConfigMap: snyk-monitor-certs
89

910
# One of: Cluster, Namespaced
1011
# Cluster - creates a ClusterRole and ClusterRoleBinding with the ServiceAccount

src/scanner/images/skopeo.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ export async function pull(
3838
): Promise<void> {
3939
const creds = await credentials.getSourceCredentials(image);
4040
const credentialsParameters = getCredentialParameters(creds);
41+
const certificatesParameters = getCertificatesParameters();
4142

4243
const args: Array<processWrapper.IProcessArgument> = [];
4344
args.push({body: 'copy', sanitise: false});
4445
args.push(...credentialsParameters);
46+
args.push(...certificatesParameters);
4547
args.push({body: prefixRespository(image, SkopeoRepositoryType.ImageRegistry), sanitise: false});
4648
args.push({body: prefixRespository(destination, SkopeoRepositoryType.DockerArchive), sanitise: false});
4749

@@ -80,3 +82,10 @@ export function getCredentialParameters(credentials: string | undefined): Array<
8082
}
8183
return credentialsParameters;
8284
}
85+
86+
export function getCertificatesParameters(): Array<processWrapper.IProcessArgument> {
87+
const certificatesParameters: Array<processWrapper.IProcessArgument> = [];
88+
certificatesParameters.push({body: '--src-cert-dir', sanitise: true});
89+
certificatesParameters.push({body: '/srv/app/certs', sanitise: true});
90+
return certificatesParameters;
91+
}

test/unit/scanner/skopeo.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@ tap.test('getCredentialParameters()', async (t) => {
1717
credentialParametersForSomeCredentials,
1818
[
1919
{body: '--src-creds', sanitise: true},
20-
{body: someCredentials, sanitise: true}
20+
{body: someCredentials, sanitise: true},
2121
],
2222
'returns Skopeo\'s args for source credentials',
2323
);
24+
const certificatesParameters = skopeo.getCertificatesParameters();
25+
t.same(
26+
certificatesParameters,
27+
[
28+
{body: '--src-cert-dir', sanitise: true},
29+
{body: '/srv/app/certs', sanitise: true},
30+
],
31+
'returns Skopeo\'s certificate args',
32+
);
2433
});

0 commit comments

Comments
 (0)