|
1 | 1 | <script lang="ts">
|
2 | 2 | import { docURL } from '$lib/doc';
|
3 |
| - import SuccessIcon from '$lib/icons/SuccessIcon.svelte'; |
4 | 3 | import WarningIcon from '$lib/icons/WarningIcon.svelte';
|
5 |
| - import { BodyShort, Heading, Link } from '@nais/ds-svelte-community'; |
| 4 | + import { BodyShort, Link } from '@nais/ds-svelte-community'; |
6 | 5 | import VulnerabilityBadges from './VulnerabilityBadges.svelte';
|
7 | 6 |
|
8 | 7 | interface Props {
|
| 8 | + showReportLink?: boolean; |
9 | 9 | workload: {
|
10 |
| - __typename: string; |
| 10 | + __typename: string | null; |
11 | 11 | name: string;
|
12 | 12 | team: {
|
13 | 13 | slug: string;
|
14 | 14 | };
|
15 |
| - teamEnvironmnet: { |
| 15 | + teamEnvironment: { |
16 | 16 | environment: {
|
17 | 17 | name: string;
|
18 | 18 | };
|
|
26 | 26 | low: number;
|
27 | 27 | unassigned: number;
|
28 | 28 | riskScore: number;
|
29 |
| - }; |
| 29 | + } | null; |
30 | 30 | };
|
31 | 31 | };
|
32 | 32 | }
|
33 | 33 |
|
34 |
| - const { workload }: Props = $props(); |
| 34 | + const { workload, showReportLink = true }: Props = $props(); |
35 | 35 |
|
36 | 36 | const { image } = workload;
|
37 | 37 |
|
38 | 38 | const imageDetailsUrl = $derived(
|
39 |
| - `/team/${workload.team.slug}/${workload.teamEnvironmnet.environment.name}/${workload.__typename === 'Application' ? 'app' : 'job'}/${workload.name}/vulnerability-report` |
40 |
| - ); |
41 |
| -
|
42 |
| - const categories = ['critical', 'high', 'medium', 'low', 'unassigned'] as const; |
43 |
| - const hasFindings = categories.some( |
44 |
| - (severity) => (image.vulnerabilitySummary?.[severity] ?? 0) > 0 |
| 39 | + `/team/${workload.team.slug}/${workload.teamEnvironment.environment.name}/${workload.__typename === 'Application' ? 'app' : 'job'}/${workload.name}/vulnerability-report` |
45 | 40 | );
|
46 | 41 | </script>
|
47 | 42 |
|
48 | 43 | <div class="wrapper">
|
49 |
| - <Heading level="3" size="small">Vulnerabilities</Heading> |
50 |
| - |
51 |
| - {#if !image.hasSBOM && image.vulnerabilitySummary !== null} |
52 |
| - <BodyShort> |
53 |
| - <WarningIcon class="text-aligned-icon" /> Data was discovered, but the SBOM was not rendered. Refer |
54 |
| - to the <Link href={docURL('/services/vulnerabilities/')}>Nais documentation</Link> for further |
55 |
| - assistance. |
56 |
| - </BodyShort> |
57 |
| - {:else if image.vulnerabilitySummary === null} |
58 |
| - <BodyShort> |
59 |
| - <WarningIcon class="text-aligned-icon" /> No data found. |
60 |
| - <a href={docURL('/services/vulnerabilities/how-to/sbom/')} target="_blank">How to fix</a> |
61 |
| - </BodyShort> |
62 |
| - {:else if image.hasSBOM && image.vulnerabilitySummary && hasFindings} |
| 44 | + {#if image.hasSBOM && image.vulnerabilitySummary} |
63 | 45 | <VulnerabilityBadges summary={image.vulnerabilitySummary} />
|
64 |
| - {:else if image.hasSBOM} |
| 46 | + {#if showReportLink} |
| 47 | + <Link href={imageDetailsUrl}>View vulnerability report</Link> |
| 48 | + {/if} |
| 49 | + {:else} |
65 | 50 | <BodyShort>
|
66 |
| - <SuccessIcon class="text-aligned-icon" /> No vulnerabilities found. Good work! |
| 51 | + <WarningIcon class="text-aligned-icon" /> No vulnerability data available. Learn how to generate |
| 52 | + SBOMs and attestations for your workloads in the |
| 53 | + <a href={docURL('/services/vulnerabilities/how-to/sbom/')} target="_blank" |
| 54 | + >Nais documentation |
| 55 | + </a>. |
67 | 56 | </BodyShort>
|
68 | 57 | {/if}
|
69 |
| - |
70 |
| - <Link href={imageDetailsUrl}>View vulnerability report</Link> |
71 | 58 | </div>
|
72 | 59 |
|
73 | 60 | <style>
|
|
0 commit comments