Skip to content

Commit 1cb855b

Browse files
committed
WIP
1 parent 1df167c commit 1cb855b

File tree

4 files changed

+894
-6
lines changed

4 files changed

+894
-6
lines changed

src/lib/components/errors/ErrorMessage.svelte

+38-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
error,
77
workloadType,
88
instances,
9+
teamSlug,
10+
workloadName,
11+
environment,
912
docURL
1013
}: {
1114
workloadType: 'App' | 'Job';
15+
teamSlug: string;
16+
workloadName: string;
17+
environment: string;
1218
instances?: {
1319
name: string;
1420
status: { message: string };
@@ -33,6 +39,11 @@
3339
name: string;
3440
detail: string;
3541
}
42+
| {
43+
__typename: 'WorkloadStatusVulnerable';
44+
riskScore: number;
45+
critical: number;
46+
}
3647
))
3748
| { __typename: "non-exhaustive; don't match this" };
3849
docURL: (path: string) => string;
@@ -55,7 +66,8 @@
5566
WorkloadStatusSynchronizationFailing: 'Rollout Failed - Synchronization Error',
5667
WorkloadStatusDeprecatedRegistry: 'Deprecated Image Registry',
5768
WorkloadStatusNoRunningInstances: 'No Running Instances',
58-
WorkloadStatusFailedRun: 'Job Failed'
69+
WorkloadStatusFailedRun: 'Job Failed',
70+
WorkloadStatusVulnerable: 'High Risk: Vulnerabilities Detected'
5971
};
6072
</script>
6173

@@ -139,6 +151,31 @@
139151
<BodyLong>
140152
Check logs if available. If you're unable to resolve the issue, contact the Nais team.
141153
</BodyLong>
154+
{:else if error.__typename === 'WorkloadStatusVulnerable'}
155+
<BodyLong>
156+
{#if error.riskScore > 100}
157+
<strong>Risk Score:</strong>
158+
{error.riskScore} (Exceeds threshold of 100)<br />
159+
{/if}
160+
{#if error.critical > 0}
161+
<strong>Critical Vulnerabilities:</strong>
162+
{error.critical}
163+
{/if}
164+
</BodyLong>
165+
<BodyLong>
166+
Workloads are flagged as vulnerable if their dependencies have a high risk score or
167+
critical vulnerabilities.
168+
</BodyLong>
169+
<BodyLong>
170+
Review detailed vulnerability information in the <a
171+
href="/team/{teamSlug}/{environment}/{workloadType === 'Job'
172+
? 'job'
173+
: 'app'}/{workloadName}/vulnerability-report">Vulnerability Report</a
174+
>, and update affected dependencies to their latest patched versions.
175+
</BodyLong>
176+
<BodyLong>
177+
Ignoring these vulnerabilities can expose your application to potential security breaches.
178+
</BodyLong>
142179
{/if}
143180
</div>
144181
</Alert>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<script module>
2+
import { defineMeta } from '@storybook/addon-svelte-csf';
3+
import ErrorMessage from './ErrorMessage.svelte';
4+
import TeamErrorMessage from './TeamErrorMessage.svelte';
5+
6+
const { Story } = defineMeta({
7+
title: 'Errors/Vulnerable Image',
8+
tags: ['autodocs']
9+
});
10+
</script>
11+
12+
<Story name="Risk Score - Workload">
13+
<ErrorMessage
14+
docURL={(p) => p}
15+
error={{
16+
__typename: 'WorkloadStatusVulnerable',
17+
level: 'WARNING',
18+
riskScore: 276,
19+
critical: 0
20+
}}
21+
teamSlug="team-service-management"
22+
workloadName="ip-lookup-preprod"
23+
environment="dev-fss"
24+
workloadType="App"
25+
/>
26+
</Story>
27+
28+
<Story name="Critical - Workload">
29+
<ErrorMessage
30+
docURL={(p) => p}
31+
error={{
32+
__typename: 'WorkloadStatusVulnerable',
33+
level: 'WARNING',
34+
riskScore: 70,
35+
critical: 7
36+
}}
37+
teamSlug="team-service-management"
38+
workloadName="ip-lookup-preprod"
39+
environment="dev-fss"
40+
workloadType="App"
41+
/>
42+
</Story>
43+
44+
<Story name="Both - Workload">
45+
<ErrorMessage
46+
docURL={(p) => p}
47+
error={{
48+
__typename: 'WorkloadStatusVulnerable',
49+
level: 'WARNING',
50+
riskScore: 276,
51+
critical: 1
52+
}}
53+
teamSlug="team-service-management"
54+
workloadName="ip-lookup-preprod"
55+
environment="dev-fss"
56+
workloadType="App"
57+
/>
58+
</Story>
59+
60+
<Story name="Team - Singular">
61+
<TeamErrorMessage
62+
teamSlug="team-service-management"
63+
error={{
64+
__typename: 'WorkloadStatusVulnerable',
65+
level: 'WARNING'
66+
}}
67+
workloads={[
68+
{
69+
__typename: 'App',
70+
name: 'ip-lookup-preprod',
71+
teamEnvironment: { environment: { name: 'dev-fss' } },
72+
team: { slug: 'team-service-management' }
73+
}
74+
]}
75+
/>
76+
</Story>
77+
78+
<Story name="Team - Multiple">
79+
<TeamErrorMessage
80+
teamSlug="team-service-management"
81+
error={{
82+
__typename: 'WorkloadStatusVulnerable',
83+
level: 'WARNING'
84+
}}
85+
workloads={[
86+
{
87+
__typename: 'App',
88+
name: 'ip-lookup-preprod',
89+
teamEnvironment: { environment: { name: 'dev-fss' } },
90+
team: { slug: 'team-service-management' }
91+
},
92+
{
93+
__typename: 'App',
94+
name: 'tsm-dustin-integration-preprod',
95+
teamEnvironment: { environment: { name: 'prod-fss' } },
96+
team: { slug: 'team-service-management' }
97+
},
98+
{
99+
__typename: 'App',
100+
name: 'tsm-dustin-integration-preprod',
101+
teamEnvironment: { environment: { name: 'prod-fss' } },
102+
team: { slug: 'team-service-management' }
103+
}
104+
]}
105+
/>
106+
</Story>

src/lib/components/errors/TeamErrorMessage.svelte

+23-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
| 'WorkloadStatusSynchronizationFailing'
1717
| 'WorkloadStatusDeprecatedRegistry'
1818
| 'WorkloadStatusNoRunningInstances'
19-
| 'WorkloadStatusFailedRun';
19+
| 'WorkloadStatusFailedRun'
20+
| 'WorkloadStatusVulnerable';
2021
};
2122
workloads: {
2223
__typename: string | null;
@@ -43,14 +44,16 @@
4344
WorkloadStatusSynchronizationFailing: 'Rollout Failed - Synchronization Error',
4445
WorkloadStatusDeprecatedRegistry: 'Deprecated Image Registry',
4546
WorkloadStatusNoRunningInstances: 'No Running Instances',
46-
WorkloadStatusFailedRun: 'Job Failed'
47+
WorkloadStatusFailedRun: 'Job Failed',
48+
WorkloadStatusVulnerable: 'High Risk: Vulnerabilities Detected'
4749
};
4850
const summary = {
4951
WorkloadStatusInvalidNaisYaml: 'Workloads with invalid manifests',
5052
WorkloadStatusSynchronizationFailing: 'Workloads with synchronization errors',
5153
WorkloadStatusDeprecatedRegistry: 'Workloads with deprecated image registries',
5254
WorkloadStatusNoRunningInstances: 'Applications with no running instances',
53-
WorkloadStatusFailedRun: 'Failed jobs'
55+
WorkloadStatusFailedRun: 'Failed jobs',
56+
WorkloadStatusVulnerable: 'High risk workloads'
5457
};
5558
</script>
5659

@@ -94,21 +97,36 @@
9497
<BodyLong>
9598
The following job{workloads.length === 1 ? ' has' : 's have'} failed.
9699
</BodyLong>
100+
{:else if error.__typename === 'WorkloadStatusVulnerable'}
101+
<BodyLong>
102+
The following workload{workloads.length === 1 ? ' is' : 's are'} flagged as vulnerable because
103+
{workloads.length === 1 ? 'its' : 'their'} dependencies have a high risk score or critical vulnerabilities.
104+
</BodyLong>
97105
{/if}
98106
<div>
99107
{#if workloads.length < 5}
100108
{#each workloads as workload (workload)}
101-
<WorkloadLink {workload} />
109+
<WorkloadLink {workload} hideTeam />
102110
{/each}
103111
{:else}
104112
<details>
105113
<summary>{summary[error.__typename]}</summary>
106114
{#each workloads as workload (workload)}
107-
<WorkloadLink {workload} />
115+
<WorkloadLink {workload} hideTeam />
108116
{/each}
109117
</details>
110118
{/if}
111119
</div>
120+
121+
{#if error.__typename === 'WorkloadStatusVulnerable'}
122+
<BodyLong>
123+
// TODO: fortsett her Review detailed vulnerability information in each workload's
124+
Vulnerability Report, and update affected dependencies to their latest patched versions.
125+
</BodyLong>
126+
<BodyLong>
127+
Ignoring these vulnerabilities can expose your workloads to potential security breaches.
128+
</BodyLong>
129+
{/if}
112130
</div></Alert
113131
>
114132

0 commit comments

Comments
 (0)