Skip to content

Commit a59037e

Browse files
committed
still WIP
1 parent d3e3d67 commit a59037e

File tree

7 files changed

+96
-50
lines changed

7 files changed

+96
-50
lines changed

src/lib/components/errors/ErrorMessage.svelte

+17-11
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
teamSlug,
2121
workloadName,
2222
environment,
23-
docURL
23+
docURL,
24+
collapsible = true
2425
}: {
26+
collapsible?: boolean;
2527
workloadType: 'App' | 'Job';
2628
teamSlug: string;
2729
workloadName: string;
@@ -52,8 +54,10 @@
5254
}
5355
| {
5456
__typename: 'WorkloadStatusVulnerable';
55-
riskScore: number;
56-
critical: number;
57+
summary: {
58+
riskScore: number;
59+
critical: number;
60+
};
5761
}
5862
))
5963
| { __typename: "non-exhaustive; don't match this" };
@@ -89,11 +93,13 @@
8993
<div class="content">
9094
<div style="display: flex; align-items: center; gap: var(--a-spacing-2);">
9195
<Heading level="2" size="small">{heading[error.__typename]}</Heading>
92-
<Button variant="tertiary" size="xsmall" onclick={() => (open = !open)}>
93-
{open ? 'Hide' : 'Show'} details
94-
</Button>
96+
{#if collapsible}
97+
<Button variant="tertiary" size="xsmall" onclick={() => (open = !open)}>
98+
{open ? 'Hide' : 'Show'} details
99+
</Button>
100+
{/if}
95101
</div>
96-
{#if open}
102+
{#if open || !collapsible}
97103
{#if error.__typename === 'WorkloadStatusInvalidNaisYaml'}
98104
<BodyLong>
99105
The rollout of your {workloadType === 'Job' ? 'job' : 'application'} has failed due to an
@@ -172,13 +178,13 @@
172178
</BodyLong>
173179
{:else if error.__typename === 'WorkloadStatusVulnerable'}
174180
<BodyLong>
175-
{#if error.riskScore > 100}
181+
{#if error.summary.riskScore > 100}
176182
<strong>Risk Score:</strong>
177-
{error.riskScore} (Exceeds threshold of 100)<br />
183+
{error.summary.riskScore} (Exceeds threshold of 100)<br />
178184
{/if}
179-
{#if error.critical > 0}
185+
{#if error.summary.critical > 0}
180186
<strong>Critical Vulnerabilities:</strong>
181-
{error.critical}
187+
{error.summary.critical}
182188
{/if}
183189
</BodyLong>
184190
<BodyLong>

src/lib/components/errors/RiskScore.stories.svelte

+12-6
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
error={{
1616
__typename: 'WorkloadStatusVulnerable',
1717
level: 'WARNING',
18-
riskScore: 276,
19-
critical: 0
18+
summary: {
19+
riskScore: 276,
20+
critical: 0
21+
}
2022
}}
2123
teamSlug="team-service-management"
2224
workloadName="ip-lookup-preprod"
@@ -31,8 +33,10 @@
3133
error={{
3234
__typename: 'WorkloadStatusVulnerable',
3335
level: 'WARNING',
34-
riskScore: 70,
35-
critical: 7
36+
summary: {
37+
riskScore: 70,
38+
critical: 7
39+
}
3640
}}
3741
teamSlug="team-service-management"
3842
workloadName="ip-lookup-preprod"
@@ -47,8 +51,10 @@
4751
error={{
4852
__typename: 'WorkloadStatusVulnerable',
4953
level: 'WARNING',
50-
riskScore: 276,
51-
critical: 1
54+
summary: {
55+
riskScore: 276,
56+
critical: 1
57+
}
5258
}}
5359
teamSlug="team-service-management"
5460
workloadName="ip-lookup-preprod"

src/lib/components/image/ImageVulnerabilities.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
};
148148
</script>
149149

150-
<Heading level="4" size="small">Vulnerabilities</Heading>
150+
<Heading level="2" size="medium">Vulnerabilities</Heading>
151151
<Table
152152
size="small"
153153
sort={{

src/routes/team/[team]/[env]/job/[job]/+page.gql

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ query Job($job: String!, $team: Slug!, $env: String!) @cache(policy: NetworkOnly
4444
detail
4545
name
4646
}
47+
... on WorkloadStatusVulnerable {
48+
summary {
49+
riskScore
50+
critical
51+
}
52+
}
4753
}
4854
}
4955

src/routes/team/[team]/[env]/job/[job]/vulnerability-report/+page.gql

+10
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,22 @@ query JobImageDetails($team: Slug!, $env: String!, $job: String!) @cache(policy:
33
slug
44
environment(name: $env) {
55
name
6+
environment {
7+
name
8+
}
69
workload(name: $job) {
710
__typename
811
name
912
status {
1013
errors {
1114
__typename
15+
level
16+
... on WorkloadStatusVulnerable {
17+
summary {
18+
critical
19+
riskScore
20+
}
21+
}
1222
}
1323
}
1424
image {

src/routes/team/[team]/[env]/job/[job]/vulnerability-report/+page.svelte

+50-32
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,67 @@
1111
1212
let { JobImageDetails, viewerIsMember } = $derived(data);
1313
14-
const error = $derived(
15-
$JobImageDetails.data?.team.environment.workload.status.errors.find(
16-
(e) => e.__typename === 'WorkloadStatusVulnerable'
17-
)
18-
);
14+
// const error = $derived(
15+
// $JobImageDetails.data?.team.environment.workload.status.errors.find(
16+
// (e) => e.__typename === 'WorkloadStatusVulnerable'
17+
// )
18+
// );
1919
</script>
2020

2121
<GraphErrors errors={$JobImageDetails.errors} />
2222

2323
{#if $JobImageDetails.data}
2424
{@const image = $JobImageDetails.data.team.environment.workload.image}
25-
<div class="grid">
26-
<div>
27-
{#if error}
28-
<!-- TODO -->
29-
<!-- <ErrorMessage {error} /> -->
30-
{/if}
31-
</div>
32-
<div class="card">
33-
<Heading level="4" size="small" spacing>Summary</Heading>
34-
{#if image.vulnerabilitySummary}
35-
<VulnerabilityBadges summary={image.vulnerabilitySummary} />
36-
{:else if !image.hasSBOM && image.vulnerabilitySummary !== null}
37-
<WarningIcon class="text-aligned-icon" />
38-
Data was discovered, but the SBOM was not rendered. Refer to the
39-
<a href={docURL('/services/vulnerabilities/')}>Nais documentation</a>
40-
for further assistance.
41-
{:else}
42-
<WarningIcon class="text-aligned-icon" />
43-
No data found.
44-
<a href={docURL('/services/vulnerabilities/how-to/sbom/')}> How to fix</a>
45-
{/if}
25+
<div class="wrapper">
26+
<div class="grid">
27+
<div>
28+
<!-- {#if error}
29+
<ErrorMessage
30+
collapsible={false}
31+
{error}
32+
{docURL}
33+
workloadType="Job"
34+
teamSlug={$JobImageDetails.data.team.slug}
35+
workloadName={$JobImageDetails.data.team.environment.workload.name}
36+
environment={$JobImageDetails.data.team.environment.environment.name}
37+
/>
38+
{/if} -->
39+
Risk score of 154 i too high. 1 critical is too high. Update affected dependencies to their latest
40+
patched versions. Application is not on Nais. plz lower <br />
41+
42+
Hvis ingen SBOM, stooor feilmelding!
43+
<img src="/SBOM.png" alt="SBOoooOooM" />
44+
</div>
45+
<div class="card">
46+
<Heading level="2" size="small" spacing>Summary</Heading>
47+
{#if image.vulnerabilitySummary}
48+
<VulnerabilityBadges summary={image.vulnerabilitySummary} />
49+
{:else if !image.hasSBOM && image.vulnerabilitySummary !== null}
50+
<WarningIcon class="text-aligned-icon" />
51+
Data was discovered, but the SBOM was not rendered. Refer to the
52+
<a href={docURL('/services/vulnerabilities/')}>Nais documentation</a>
53+
for further assistance.
54+
{:else}
55+
<WarningIcon class="text-aligned-icon" />
56+
No data found.
57+
<a href={docURL('/services/vulnerabilities/how-to/sbom/')}> How to fix</a>
58+
{/if}
59+
</div>
4660
</div>
61+
<ImageVulnerabilities
62+
team={$JobImageDetails.data?.team.slug}
63+
environment={$JobImageDetails.data?.team.environment.name}
64+
workload={$JobImageDetails.data?.team.environment.workload.name}
65+
authorized={viewerIsMember}
66+
/>
4767
</div>
48-
<ImageVulnerabilities
49-
team={$JobImageDetails.data?.team.slug}
50-
environment={$JobImageDetails.data?.team.environment.name}
51-
workload={$JobImageDetails.data?.team.environment.workload.name}
52-
authorized={viewerIsMember}
53-
/>
5468
{/if}
5569

5670
<style>
71+
.wrapper {
72+
display: grid;
73+
gap: 1rem;
74+
}
5775
.grid {
5876
display: grid;
5977
grid-template-columns: 1fr 300px;

static/SBOM.png

457 KB
Loading

0 commit comments

Comments
 (0)