Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Junk committed Aug 28, 2023
1 parent 80653ae commit 0f08a30
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/lib/Droparea.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<script lang="ts">
import { appStore } from "$lib/store";
import { convertToDocModel } from "$lib/docmodel/docmodel";
import { generateProductVulnerabilities } from "./productvulnerabilities/productvulnerabilities";
let hover: boolean = false;
let valid: boolean | null = null;
Expand Down Expand Up @@ -44,8 +45,9 @@
DocModel.
*/
}
const result = convertToDocModel(jsonDocument);
appStore.setDocument(result);
let docModel = convertToDocModel(jsonDocument);
docModel.vulnerabilities = generateProductVulnerabilities(jsonDocument);
appStore.setDocument(docModel);
}
};
fileReader.readAsText(csafFile);
Expand Down
75 changes: 75 additions & 0 deletions src/lib/ProductVulnerabilities.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,85 @@

<script lang="ts">
import { appStore } from "$lib/store";
let headerColumns: any = [];
let productLines: string[][];
$: if ($appStore.doc) {
const vulnerabilities = [...$appStore.doc.vulnerabilities];
headerColumns = vulnerabilities.shift();
productLines = vulnerabilities;
}
</script>

{#if $appStore.doc}
<div>
<h2>Vulnerabilities overview</h2>
{#if productLines.length > 0}
<table class="striped">
<thead>
<tr>
{#each headerColumns as column, index}
<th>{column}</th>
{/each}
</tr>
</thead>
<tbody>
{#each productLines as line, index}
<tr>
{#each line as column, index}
{#if index < 1}
<td>{column}</td>
{:else if column === "N.A"}
<td>{column}</td>
{:else}
<td
><i
class:bx={true}
class:bx-x={column === "K"}
class:bx-check={column === "F"}
class:bx-error={column === "U"}
class:bx-minus={column === "N"}
class:bx-heart={column === "R"}
/></td
>
{/if}
{/each}
</tr>
{/each}
</tbody>
</table>
<div class="legend">
<h6>Legend</h6>
<dl>
<dt><i class="bx bx-check" /></dt>
<dd>Fixed</dd>
<dt><i class="bx bx-error" /></dt>
<dd>Under investigation</dd>
<dt><i class="bx bx-x" /></dt>
<dd>Known affected</dd>
<dt><i class="bx bx-minus" /></dt>
<dd>Not affected</dd>
<dt><i class="bx bx-heart" /></dt>
<dd>Recommended</dd>
</dl>
</div>
{/if}
</div>
{/if}

<style>
tr {
line-height: 2rem;
}
.legend {
margin-top: 2rem;
}
dt {
font-size: large;
float: left;
clear: left;
width: 1rem;
}
dd {
margin-bottom: 0.3em;
}
</style>
1 change: 1 addition & 0 deletions src/lib/docmodel/docmodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const convertToDocModel = (csafDoc: any): DocModel => {
status: getStatus(csafDoc),
published: getPublished(csafDoc),
lastUpdate: getLastUpdate(csafDoc),
vulnerabilities: [],
isDocPresent: checkDocumentPresent(csafDoc),
isTrackingPresent: checkTrackingPresent(csafDoc),
isDistributionPresent: checkDistributionPresent(csafDoc),
Expand Down
1 change: 1 addition & 0 deletions src/lib/docmodel/docmodeltypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export type DocModel = {
status: string;
published: string;
lastUpdate: string;
vulnerabilities: Array<Array<string>>;
isDocPresent: boolean;
isTrackingPresent: boolean;
isDistributionPresent: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<!-- svelte-ignore a11y-no-redundant-roles -->
<div class="header">
<h1 role="heading" class="text-center">CSAF Webview+</h1>
<button class="switchbutton" on:click={switchView}>{mode}</button>
<button class="switchbutton button" on:click={switchView}>{mode}</button>
<h4>v. {version}</h4>
</div>
{#if noRef && mode === MODE.SINGLE}
Expand Down

0 comments on commit 0f08a30

Please sign in to comment.