Skip to content

Commit 65ce85c

Browse files
committed
fix: add permissions
1 parent bbd956c commit 65ce85c

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

build-and-deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ WEBTOP_IMAGE=$(cat helm/wrongsecrets-ctf-party/values.yaml | yq '.virtualdesktop
1818
WEBTOP_TAG=$(cat helm/wrongsecrets-ctf-party/values.yaml | yq '.virtualdesktop.tag')
1919
echo "doing workaround for selaed secrets"
2020
helm repo add sealed-secrets https://bitnami-labs.github.io/sealed-secrets
21-
helm install ws-sealedsecrets sealed-secrets/sealed-secrets -n kube-system
21+
helm install ws-sealedsecrets sealed-secrets/sealed-secrets --namespace kube-system
2222
echo "Pulling in required images to actually run $WRONGSECRETS_IMAGE:$WRONGSECRETS_TAG & $WEBTOP_IMAGE:$WEBTOP_TAG."
2323
echo "If you see an authentication failure: pull them manually by the following 2 commands"
2424
echo "'docker pull $WRONGSECRETS_IMAGE:$WRONGSECRETS_TAG'"

helm/wrongsecrets-ctf-party/templates/wrongsecrets-balancer/role.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ rules:
4444
- apiGroups: ['']
4545
resources: ['endpoints']
4646
verbs: [ 'get', 'list']
47+
- apiGroups: ['bitnami.com']
48+
resources: ['sealedsecrets']
49+
verbs: ['get', 'create', 'list', 'delete', 'patch', 'watch', 'update']

wrongsecrets-balancer/src/kubernetes.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ const getJuiceShopInstanceForTeamname = async (teamname) => {
157157
() => k8sAppsApi.readNamespacedDeployment({name: deploymentName, namespace: namespace}),
158158
`Check deployment for team ${teamname}`
159159
);
160-
if (!res || !res.body) {
160+
if (!res) {
161161
logger.info(`No deployment found for team ${teamname}`);
162162
return undefined;
163163
}
164164

165-
const deployment = res.body;
165+
const deployment = res;
166166

167167
if (
168168
Object.prototype.hasOwnProperty.call(deployment, 'metadata') &&
@@ -199,7 +199,7 @@ const createConfigmapForTeam = async (team) => {
199199
},
200200
};
201201
return k8sCoreApi.createNamespacedConfigMap({namespace: 't-' + team, body: configmap}).catch((error) => {
202-
throw new Error(error.response.body.message);
202+
throw new Error(error.response.message);
203203
});
204204
};
205205

@@ -217,7 +217,7 @@ const createSecretsfileForTeam = async (team) => {
217217
},
218218
};
219219
return k8sCoreApi.createNamespacedSecret({namespace: 't-' + team, body: secret}).catch((error) => {
220-
throw new Error(error.response.body.message);
220+
throw new Error(error.response.message);
221221
});
222222
};
223223

@@ -239,7 +239,7 @@ const createChallenge33SecretForTeam = async (team) => {
239239
},
240240
};
241241
return k8sCoreApi.createNamespacedSecret({namespace: 't-' + team, body: secret}).catch((error) => {
242-
throw new Error(error.response.body.message);
242+
throw new Error(error.response.message);
243243
});
244244
};
245245

@@ -314,7 +314,7 @@ const getSealedSecretsPublicKey = async () => {
314314
{name: 'sealed-secrets-key',
315315
namespace: 'kube-system'}
316316
);
317-
return response.body.data['tls.crt'];
317+
return response.data['tls.crt'];
318318
} catch (error) {
319319
logger.error('Failed to get Sealed Secrets public key:', error.body || error);
320320
throw new Error(`Failed to get public key: ${error.message}`);
@@ -1862,7 +1862,7 @@ const deleteNamespaceForTeam = async (team) => {
18621862
const deletePodForTeam = async (team) => {
18631863
const res = await k8sCoreApi.listNamespacedPod({namespace: `t-${team}`, pretty: true, allowWatchBookmarks: true, _continue: undefined, fieldSelector: undefined, labelSelector: `app=wrongsecrets,team=${team},deployment-context=${get('deploymentContext')}`});
18641864

1865-
const pods = res.body.items;
1865+
const pods = res.items;
18661866

18671867
if (pods.length !== 1) {
18681868
throw new Error(`Unexpected number of pods ${pods.length}`);
@@ -1876,7 +1876,7 @@ const deletePodForTeam = async (team) => {
18761876
const deleteDesktopPodForTeam = async (team) => {
18771877
const res = await k8sCoreApi.listNamespacedPod({namespace: `t-${team}`, pretty: true, allowWatchBookmarks: true, _continue: undefined, fieldSelector: undefined, labelSelector: `app=virtualdesktop,team=${team},deployment-context=${get('deploymentContext')}`});
18781878

1879-
const pods = res.body.items;
1879+
const pods = res.items;
18801880

18811881
if (pods.length !== 1) {
18821882
throw new Error(`Unexpected number of pods ${pods.length}`);

0 commit comments

Comments
 (0)