Skip to content

Commit

Permalink
Add virustotal results to version screen (#192)
Browse files Browse the repository at this point in the history
* feat: added virustotal results to versions screen

* fix: remove canedit from vt results

* fix: update to virustotal_results

* fix: move thead to tbody/make text translatable

---------

Co-authored-by: Rob B <[email protected]>
  • Loading branch information
knightzac19 and budak7273 authored Oct 12, 2024
1 parent 8a6afe6 commit 1d65000
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/gql/mods/versions.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ query GetModVersions($mod: ModID!, $limit: Int!, $offset: Int!) {
hash
size
}
virustotal_results {
created_at
file_name
hash
id
safe
updated_at
version_id
}
}
}
}
9 changes: 9 additions & 0 deletions src/gql/versions/mod_version.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,14 @@ query GetModVersion($version: VersionID!) {
optional
condition
}
virustotal_results {
created_at
file_name
hash
id
safe
updated_at
version_id
}
}
}
55 changes: 55 additions & 0 deletions src/lib/components/versions/VirustotalResults.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<script lang="ts">
import type { VirustotalResult } from '$lib/generated';
import { getTranslate } from '@tolgee/svelte';
export let results!: Array<VirustotalResult>;
export const { t } = getTranslate();
</script>

<div class="grid grid-flow-row">
<h3 class="my-4 text-2xl font-bold">{$t('virustotal.table.title')}</h3>
<table aria-label={$t('virustotal.table.title')} class="max-w-auto table table-hover !overflow-visible">
<tbody>
<tr class="rounded border !border-surface-500">
<td style="width: 25%;"
><div title={$t('virustotal.table.file_name')}>
{$t('virustotal.table.file_name')}
</div></td>
<td style="width: 25%;"
><div class="text-center" title={$t('virustotal.table.results')}>{$t('virustotal.table.results')}</div></td>
<td style="width: 25%;"
><div class="text-center" title={$t('virustotal.table.safe')}>{$t('virustotal.table.safe')}</div></td>
</tr>
{#each results as result}
<tr class="rounded border !border-surface-500">
<td>
<div>{result.file_name}</div>
</td>
<td>
<div class="text-center">
<a
title={$t('version.virustotal.result')}
href={`https://www.virustotal.com/gui/file/${result.hash}`}
target="_blank"
class="text-white">
<span class="material-icons text-center" style="width: 20px" title={$t('version.virustotal.result')}>
policy
</span>
</a>
</div>
</td>
<td
><div class="text-center">
<span
class="material-icons text-center"
style="width: 20px"
title={result.safe ? $t('version.virustotal.safe') : $t('version.virustotal.not_safe')}>
{result.safe ? 'checkmark' : 'cancel'}
</span>
</div>
</td>
</tr>
{/each}
</tbody>
</table>
</div>
4 changes: 4 additions & 0 deletions src/routes/mod/[modId]/version/[versionId]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { getModalStore, getToastStore, type ModalSettings, popup } from '@skeletonlabs/skeleton';
import Page404 from '$lib/components/general/Page404.svelte';
import { getTranslate } from '@tolgee/svelte';
import VirustotalResults from '$lib/components/versions/VirustotalResults.svelte';
export const { t } = getTranslate();
Expand Down Expand Up @@ -164,6 +165,9 @@
<VersionInfo version={$version.data.getVersion} />
<VersionTargetSupportGrid targets={$version.data.getVersion.targets} />
<VersionDependenciesGrid dependencies={$version.data.getVersion.dependencies} />
{#if $version.data.getVersion.virustotal_results.length != 0}
<VirustotalResults results={$version.data.getVersion.virustotal_results} />
{/if}
</div>
</div>
</div>
Expand Down

0 comments on commit 1d65000

Please sign in to comment.