From 1e88b8497940d4b8ecefab527a792f05dd2fe96c Mon Sep 17 00:00:00 2001 From: Angelika Schneider Date: Thu, 17 Oct 2024 14:18:10 +0200 Subject: [PATCH] Fix compliance view (#223) * Add env variables subsection * Ensure targets is always an array to prevent TypeError * Add env variables subsection * Ensure targets is always an array to prevent TypeError * npm audit fix * Update node version --- Dockerfile | 2 +- README.md | 11 ++++++++ package-lock.json | 28 +++++++++++-------- src/lib/api/orchestrator.ts | 6 ++-- .../(app)/cloud/[id]/compliance/+layout.ts | 2 +- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7460575..b34dd8c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:alpine AS build +FROM node:18-alpine AS build WORKDIR /app COPY package*.json ./ diff --git a/README.md b/README.md index 5c91169..fcab088 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,14 @@ npm run build You can preview the production build with `npm run preview`. > To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. + +## Environment variables +The following environment variables can be set to configure the UI. The values are all default values. + +``` +PUBLIC_OAUTH_AUTHORITY=http://localhost:8080 +PUBLIC_OAUTH_CLIENT_ID=dashboard +PUBLIC_OAUTH_REDIRECT_URI=http://localhost:5173/callback +PUBLIC_OAUTH_SCOPE=profile email +PUBLIC_CLOUDITOR_URL=http://localhost:8080 +``` \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 23989a2..8521f75 100644 --- a/package-lock.json +++ b/package-lock.json @@ -652,10 +652,11 @@ } }, "node_modules/@polka/url": { - "version": "1.0.0-next.24", - "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.24.tgz", - "integrity": "sha512-2LuNTFBIO0m7kKIQvvPHN6UE63VjpmL9rnEEaOOaiSPbZK+zUOYIzBAWcED+3XYzhYsd/0mD57VdxAEqqV52CQ==", - "dev": true + "version": "1.0.0-next.28", + "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.28.tgz", + "integrity": "sha512-8LduaNlMZGwdZ6qWrKlfa+2M4gahzFkprZiAt2TF8uS0qQgBizKXpXURqvTJ4WtmupWxaLqjRb2UCTe72mu+Aw==", + "dev": true, + "license": "MIT" }, "node_modules/@popperjs/core": { "version": "2.11.8", @@ -1064,9 +1065,9 @@ } }, "node_modules/@sveltejs/kit": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.6.3.tgz", - "integrity": "sha512-baIAnmfMqAISrPtTC/22w6ay5kTEIQ/vq9bctiaQgRIoLCPBNhb6LEidTuWQS7OzPYCDBMuMX1t/fMvi4r3q/g==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.7.1.tgz", + "integrity": "sha512-TBVnkwgYQT3EafGQK6Eyh5FlLEBlRhCmqPTwcdOs+QdnyUc3eCAxRWtXlFxIWtmk6pqv11zdng8qTpThdTogew==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -1081,7 +1082,7 @@ "mrmime": "^2.0.0", "sade": "^1.8.1", "set-cookie-parser": "^2.6.0", - "sirv": "^2.0.4", + "sirv": "^3.0.0", "tiny-glob": "^0.2.9" }, "bin": { @@ -3256,6 +3257,7 @@ "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.0.tgz", "integrity": "sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" } @@ -4047,17 +4049,18 @@ } }, "node_modules/sirv": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz", - "integrity": "sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.0.tgz", + "integrity": "sha512-BPwJGUeDaDCHihkORDchNyyTvWFhcusy1XMmhEVTQTwGeybFbp8YEmB+njbPnth1FibULBSBVwCQni25XlCUDg==", "dev": true, + "license": "MIT", "dependencies": { "@polka/url": "^1.0.0-next.24", "mrmime": "^2.0.0", "totalist": "^3.0.0" }, "engines": { - "node": ">= 10" + "node": ">=18" } }, "node_modules/slash": { @@ -4506,6 +4509,7 @@ "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } diff --git a/src/lib/api/orchestrator.ts b/src/lib/api/orchestrator.ts index 3565cf7..13d98ad 100644 --- a/src/lib/api/orchestrator.ts +++ b/src/lib/api/orchestrator.ts @@ -143,7 +143,7 @@ export interface ListCertificationTargetsResponse { } export interface ListAuditScopesResponse { - auditScope: AuditScope[]; + auditScopes: AuditScope[]; } export interface ListControlsInScopeResponse { @@ -481,7 +481,7 @@ export async function listAuditScopes( fetch = window.fetch ): Promise { const apiUrl = clouditorize(`/v1/orchestrator/certification_targets/${serviceId}/audit_scopes`); - + return fetch(apiUrl, { method: 'GET', headers: { @@ -491,7 +491,7 @@ export async function listAuditScopes( .then(throwError) .then((res) => res.json()) .then((response: ListAuditScopesResponse) => { - return response.auditScope; + return response.auditScopes; }); } diff --git a/src/routes/(app)/cloud/[id]/compliance/+layout.ts b/src/routes/(app)/cloud/[id]/compliance/+layout.ts index 49d35c6..cd44f62 100644 --- a/src/routes/(app)/cloud/[id]/compliance/+layout.ts +++ b/src/routes/(app)/cloud/[id]/compliance/+layout.ts @@ -8,7 +8,7 @@ export const load = (async ({ fetch, params, parent }) => { throw error(405, 'Required parameter missing'); } - const targets = await listAuditScopes(params.id, fetch); + const targets = await listAuditScopes(params.id, fetch) || [];; const data = await parent(); const leftOverCatalogs = data.catalogs.filter((c) => {