Skip to content

Commit

Permalink
feat: Add Vulnerabilies CVE, CWE
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Junk committed Sep 4, 2023
1 parent 4fc9b4f commit c047a17
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 4 deletions.
20 changes: 17 additions & 3 deletions src/lib/Collapsible.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
export let header: string;
export let open: boolean = true;
export let index: string = "2";
export let class_: string = "";
let visibility = open ? "block" : "none";
let icon = "bx-chevron-down";
const toggle = (e: Event) => {
Expand All @@ -17,9 +19,21 @@
</script>

<div>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div on:click={toggle}><h2><i class="bx {icon}" />{header}</h2></div>
{#if index == "2"}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div on:click={toggle} class={class_}><h2><i class="bx {icon}" />{header}</h2></div>
{/if}
{#if index == "3"}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div on:click={toggle} class={class_}><h3><i class="bx {icon}" />{header}</h3></div>
{/if}
{#if index == "4"}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div on:click={toggle} class={class_}><h4><i class="bx {icon}" />{header}</h4></div>
{/if}
<div style="display:{visibility}" class="body">
<slot />
</div>
Expand Down
8 changes: 7 additions & 1 deletion src/lib/singleview/vulnerabilities/Vulnerabilities.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<script lang="ts">
import { appStore } from "$lib/store";
import Vulnerability from "./Vulnerability.svelte";
$: vulnerabilities = $appStore.doc?.vulnerabilities;
</script>

<div />
<div>
{#each vulnerabilities as vulnerability, index}
<Vulnerability {vulnerability} index={index + 1} />
{/each}
</div>
75 changes: 75 additions & 0 deletions src/lib/singleview/vulnerabilities/Vulnerability.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<script lang="ts">
import Collapsible from "$lib/Collapsible.svelte";
export let vulnerability: any;
export let index: number = 1;
let header = `Vulnerability ${index}`;
$: if (vulnerability.cve) {
header = vulnerability.cve;
}
</script>

<div>
<Collapsible {header} class_="text-primary" index="3">
<div>
<dl>
{#if vulnerability.title}
<dt>Title</dt>
<dd>{vulnerability.title}</dd>
{/if}
{#if vulnerability.cwe}
<dt>CWE ID</dt>
<dd>{vulnerability.cwe.id}</dd>
<dt>CWE Name</dt>
<dd>{vulnerability.cwe.name}</dd>
{/if}
{#if vulnerability.discovery_date}
<dt>Discovery date</dt>
<dd>{vulnerability.discovery_date}</dd>
{/if}
{#if vulnerability.release_date}
<dt>Release date</dt>
<dd>{vulnerability.release_date}</dd>
{/if}
</dl>
{#if vulnerability.ids && Array.isArray(vulnerability.ids)}
<Collapsible header="IDs" index="4">
{#each vulnerability.ids as vulnerabilityID}
<dl>
<dt>Systemname</dt>
<dd>{vulnerabilityID.system_name}</dd>
<dt>Text</dt>
<dd>{vulnerabilityID.text}</dd>
</dl>
{/each}
</Collapsible>
{/if}
{#if vulnerability.notes && Array.isArray(vulnerability.notes)}
<Collapsible header="Notes" index="4">
{#each vulnerability.notes as note}
<dl>
<dt>Title</dt>
<dd>{note.title}</dd>
<dt>Category</dt>
<dd>{note.category}</dd>
<dt>Text</dt>
<dd>{note.text}</dd>
</dl>
{/each}
</Collapsible>
{/if}
</div>
</Collapsible>
</div>

<style>
dt {
font-size: large;
float: left;
clear: left;
width: 15%;
}
dd {
margin-bottom: 0.3em;
}
</style>

0 comments on commit c047a17

Please sign in to comment.