mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-11-26 06:37:07 +00:00
feat(frontend): rebuild package, detail and vulnerable views
Package groups use Accordion with Table or DataTable in the cards layout below sm. Delete confirmations use ConfirmDialog and results go to the Toaster. Vulnerability descriptions render through Markdown instead of v-html, and references use the library Link.
This commit is contained in:
@@ -1,250 +1,154 @@
|
||||
<template>
|
||||
<div class="max-w-7xl mx-auto px-4 py-8">
|
||||
<!-- Header with Back Button -->
|
||||
<div class="mb-6">
|
||||
<Button @click="goBack" variant="ghost" class="mb-4">
|
||||
<i class="fas fa-arrow-left mr-2"></i>
|
||||
Back to Packages
|
||||
</Button>
|
||||
<div class="flex items-center gap-3">
|
||||
<i class="fas fa-box text-3xl text-primary-600"></i>
|
||||
<div>
|
||||
<h1 class="text-3xl font-bold text-gray-900">{{ packageName }}</h1>
|
||||
<div class="flex items-center gap-2 mt-2">
|
||||
<Badge :class="getRegistryBadgeClass(registry)">{{ registry }}</Badge>
|
||||
<Badge variant="outline" class="font-mono">v{{ version }}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-6">
|
||||
<PageHeader :title="packageName">
|
||||
<template #back>
|
||||
<Button variant="ghost" size="sm" :icon-start="faArrowLeft" @click="goBack">Back to packages</Button>
|
||||
</template>
|
||||
<template #description>
|
||||
<span class="flex flex-wrap items-center gap-2">
|
||||
<Badge variant="outline">{{ registry }}</Badge>
|
||||
<Badge variant="outline" class="font-mono">v{{ version }}</Badge>
|
||||
</span>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<!-- Loading State -->
|
||||
<div v-if="loading" class="text-center py-12">
|
||||
<i class="fas fa-spinner fa-spin text-4xl text-primary-600"></i>
|
||||
<p class="mt-4 text-gray-600">Loading vulnerability details...</p>
|
||||
</div>
|
||||
<LoadingState v-if="loading" variant="card" label="Loading vulnerability details..." />
|
||||
|
||||
<!-- Error State -->
|
||||
<Alert v-else-if="error" variant="destructive" class="mb-4">
|
||||
<i class="fas fa-exclamation-circle mr-2"></i>
|
||||
<AlertDescription>{{ error }}</AlertDescription>
|
||||
</Alert>
|
||||
<ErrorState
|
||||
v-else-if="error"
|
||||
variant="card"
|
||||
title="Could not load vulnerability details"
|
||||
:message="error"
|
||||
@retry="fetchVulnerabilities"
|
||||
/>
|
||||
|
||||
<!-- Vulnerability Details -->
|
||||
<div v-else-if="vulnerabilities" class="space-y-6">
|
||||
<!-- Summary Card -->
|
||||
<template v-else-if="vulnerabilities">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle class="flex items-center gap-2">
|
||||
<i class="fas fa-shield-virus text-red-600"></i>
|
||||
Security Scan Summary
|
||||
</CardTitle>
|
||||
<CardTitle as="h2">Security scan summary</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-4">
|
||||
<div class="text-center p-4 bg-red-50 rounded-lg border border-red-200">
|
||||
<p class="text-3xl font-bold text-red-600">{{ severityCounts.critical }}</p>
|
||||
<p class="text-sm text-gray-600 mt-1">Critical</p>
|
||||
</div>
|
||||
<div class="text-center p-4 bg-orange-50 rounded-lg border border-orange-200">
|
||||
<p class="text-3xl font-bold text-orange-600">{{ severityCounts.high }}</p>
|
||||
<p class="text-sm text-gray-600 mt-1">High</p>
|
||||
</div>
|
||||
<div class="text-center p-4 bg-yellow-50 rounded-lg border border-yellow-200">
|
||||
<p class="text-3xl font-bold text-yellow-600">{{ severityCounts.moderate }}</p>
|
||||
<p class="text-sm text-gray-600 mt-1">Moderate</p>
|
||||
</div>
|
||||
<div class="text-center p-4 bg-blue-50 rounded-lg border border-blue-200">
|
||||
<p class="text-3xl font-bold text-blue-600">{{ severityCounts.low }}</p>
|
||||
<p class="text-sm text-gray-600 mt-1">Low</p>
|
||||
</div>
|
||||
</div>
|
||||
<Separator class="my-4" />
|
||||
<div class="flex items-center justify-between text-sm">
|
||||
<div class="flex flex-col gap-3">
|
||||
<span class="text-gray-600">
|
||||
<i class="fas fa-search mr-1"></i>
|
||||
Scanned: {{ formatDate(vulnerabilities.scanned_at) }}
|
||||
<CardContent class="flex flex-col gap-4">
|
||||
<SeveritySummary :counts="severityCounts" label="Vulnerabilities by severity" />
|
||||
<DescriptionList variant="inline" divided>
|
||||
<DescriptionItem term="Scanned">{{ formatDate(vulnerabilities.scanned_at) }}</DescriptionItem>
|
||||
<DescriptionItem term="Scanners">
|
||||
<span class="flex flex-wrap gap-1">
|
||||
<Badge v-for="scanner in scannerList" :key="scanner" variant="secondary">{{ scanner }}</Badge>
|
||||
</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-gray-600">
|
||||
<i class="fas fa-cog mr-1"></i>
|
||||
Scanners:
|
||||
</span>
|
||||
<div class="flex flex-wrap gap-1">
|
||||
<Badge
|
||||
v-for="scanner in scannerList"
|
||||
:key="scanner"
|
||||
variant="secondary"
|
||||
class="text-xs"
|
||||
>
|
||||
{{ scanner }}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="bypassedCount > 0" class="flex items-center gap-2 text-green-600">
|
||||
<i class="fas fa-check-circle"></i>
|
||||
<span>{{ bypassedCount }} bypassed</span>
|
||||
</div>
|
||||
</div>
|
||||
</DescriptionItem>
|
||||
<DescriptionItem v-if="bypassedCount > 0" term="Bypassed">
|
||||
<StatusBadge status="bypassed" :label="`${bypassedCount} bypassed`" :tones="{ bypassed: 'success' }" />
|
||||
</DescriptionItem>
|
||||
</DescriptionList>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<!-- No Vulnerabilities -->
|
||||
<Card v-if="vulnerabilityList.length === 0">
|
||||
<CardContent class="text-center py-12">
|
||||
<i class="fas fa-check-circle text-6xl text-green-500 mb-4"></i>
|
||||
<p class="text-xl font-semibold text-gray-900">No Vulnerabilities Found</p>
|
||||
<p class="mt-2 text-gray-600">This package is clean and safe to use</p>
|
||||
<CardContent>
|
||||
<EmptyState
|
||||
tone="success"
|
||||
:icon="faCircleCheck"
|
||||
title="No vulnerabilities found"
|
||||
description="The scanners reported nothing for this package version."
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<!-- Vulnerability List -->
|
||||
<Card v-else>
|
||||
<CardHeader>
|
||||
<CardTitle class="flex items-center gap-2">
|
||||
<i class="fas fa-list text-gray-600"></i>
|
||||
Detected Vulnerabilities ({{ vulnerabilityList.length }})
|
||||
</CardTitle>
|
||||
<CardTitle as="h2">Detected vulnerabilities ({{ vulnerabilityList.length }})</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent class="p-0">
|
||||
<div class="border-t overflow-x-auto">
|
||||
<Table class="min-w-[800px]">
|
||||
<TableHeader>
|
||||
<TableRow class="bg-gray-50 hover:bg-gray-50">
|
||||
<TableHead class="w-[100px]">Severity</TableHead>
|
||||
<TableHead class="w-[180px]">CVE ID</TableHead>
|
||||
<TableHead>Description</TableHead>
|
||||
<TableHead class="w-[120px]">Fix Version</TableHead>
|
||||
<TableHead class="w-[100px] text-center">Details</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<template v-for="(vuln, index) in vulnerabilityList" :key="vuln.id">
|
||||
<!-- Main Row -->
|
||||
<TableRow
|
||||
:class="getRowClass(index, vuln.severity)"
|
||||
@click="toggleRow(index)"
|
||||
>
|
||||
<TableCell>
|
||||
<Badge :class="getSeverityBadgeClass(vuln.severity)">
|
||||
{{ formatSeverityName(vuln.severity) }}
|
||||
</Badge>
|
||||
<span
|
||||
<CardContent>
|
||||
<Table label="Detected vulnerabilities" layout="cards">
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Severity</TableHead>
|
||||
<TableHead>CVE ID</TableHead>
|
||||
<TableHead>Description</TableHead>
|
||||
<TableHead>Fix version</TableHead>
|
||||
<TableHead align="center">Details</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<template v-for="(vuln, index) in vulnerabilityList" :key="vuln.id">
|
||||
<TableRow class="cursor-pointer" :selected="expandedRows.has(index)" @click="toggleRow(index)">
|
||||
<TableCell label="Severity">
|
||||
<span class="flex flex-wrap items-center gap-2">
|
||||
<StatusBadge
|
||||
:status="vuln.severity"
|
||||
:tones="SEVERITY_TONES"
|
||||
:label="formatSeverityName(vuln.severity)"
|
||||
/>
|
||||
<StatusBadge
|
||||
v-if="vuln.bypassed"
|
||||
class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800"
|
||||
title="Bypassed"
|
||||
>
|
||||
<i class="fas fa-unlock text-xs"></i>
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<span class="font-mono text-sm font-medium">{{ vuln.id }}</span>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<p class="text-sm text-gray-900 line-clamp-2 break-words">{{ vuln.title || vuln.description }}</p>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<span v-if="vuln.fixed_in" class="inline-flex items-center text-sm text-green-700">
|
||||
<i class="fas fa-arrow-up text-xs mr-1"></i>
|
||||
v{{ vuln.fixed_in }}
|
||||
</span>
|
||||
<span v-else class="text-sm text-gray-400">-</span>
|
||||
</TableCell>
|
||||
<TableCell class="text-center">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
class="h-8 w-8 p-0"
|
||||
@click.stop="toggleRow(index)"
|
||||
>
|
||||
<i
|
||||
:class="[
|
||||
'fas transition-transform',
|
||||
expandedRows.has(index) ? 'fa-chevron-up' : 'fa-chevron-down'
|
||||
]"
|
||||
></i>
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
status="bypassed"
|
||||
label="Bypassed"
|
||||
:tones="{ bypassed: 'success' }"
|
||||
/>
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCell label="CVE ID" class="font-mono font-medium">{{ vuln.id }}</TableCell>
|
||||
<TableCell label="Description">
|
||||
<p class="m-0 line-clamp-2 break-words">{{ vuln.title || vuln.description }}</p>
|
||||
</TableCell>
|
||||
<TableCell label="Fix version">
|
||||
<span v-if="vuln.fixed_in">v{{ vuln.fixed_in }}</span>
|
||||
<span v-else class="text-muted-foreground">-</span>
|
||||
</TableCell>
|
||||
<TableCell label="Details" align="center">
|
||||
<IconButton
|
||||
size="icon-sm"
|
||||
:icon="expandedRows.has(index) ? faChevronUp : faChevronDown"
|
||||
:label="`${expandedRows.has(index) ? 'Hide' : 'Show'} details for ${vuln.id}`"
|
||||
:aria-expanded="expandedRows.has(index)"
|
||||
@click.stop="toggleRow(index)"
|
||||
/>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
|
||||
<!-- Expanded Details Row -->
|
||||
<TableRow v-if="expandedRows.has(index)" class="bg-gray-50 hover:bg-gray-50">
|
||||
<TableCell colspan="5" class="p-0">
|
||||
<div class="px-6 py-4 space-y-3">
|
||||
<!-- Full Description -->
|
||||
<div>
|
||||
<h5 class="font-semibold text-gray-900 mb-2">Description</h5>
|
||||
<div
|
||||
class="text-sm text-gray-700 leading-relaxed prose prose-sm max-w-none break-words overflow-hidden"
|
||||
v-html="renderMarkdown(vuln.description)"
|
||||
></div>
|
||||
</div>
|
||||
<TableRow v-if="expandedRows.has(index)" :hoverable="false">
|
||||
<TableCell :colspan="5">
|
||||
<div class="flex flex-col gap-4 py-2">
|
||||
<section>
|
||||
<h3 class="mb-2 text-sm font-semibold">Description</h3>
|
||||
<Markdown :source="vuln.description" :heading-offset="3" />
|
||||
</section>
|
||||
|
||||
<!-- Bypass Information -->
|
||||
<div v-if="vuln.bypassed && vuln.bypass" class="bg-green-50 border border-green-200 rounded-lg p-3">
|
||||
<h5 class="font-semibold text-green-900 mb-2 flex items-center gap-2">
|
||||
<i class="fas fa-info-circle"></i>
|
||||
Bypass Active
|
||||
</h5>
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm text-green-800">
|
||||
<div class="break-words">
|
||||
<span class="font-medium">Reason:</span> {{ vuln.bypass.reason }}
|
||||
</div>
|
||||
<div class="break-words">
|
||||
<span class="font-medium">By:</span> {{ vuln.bypass.created_by }}
|
||||
</div>
|
||||
<div class="break-words">
|
||||
<span class="font-medium">Expires:</span> {{ formatDate(vuln.bypass.expires_at) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Alert v-if="vuln.bypassed && vuln.bypass" variant="success">
|
||||
<AlertTitle>Bypass active</AlertTitle>
|
||||
<AlertDescription>
|
||||
<DescriptionList variant="grid" :columns="3" size="sm">
|
||||
<DescriptionItem term="Reason">{{ vuln.bypass.reason }}</DescriptionItem>
|
||||
<DescriptionItem term="By">{{ vuln.bypass.created_by }}</DescriptionItem>
|
||||
<DescriptionItem term="Expires">{{ formatDate(vuln.bypass.expires_at) }}</DescriptionItem>
|
||||
</DescriptionList>
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
<!-- Fix Information -->
|
||||
<div v-if="vuln.fixed_in" class="bg-blue-50 border border-blue-200 rounded-lg p-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<i class="fas fa-wrench text-blue-700"></i>
|
||||
<span class="text-sm text-blue-900">
|
||||
<span class="font-semibold">Fix Available:</span> Upgrade to version <strong>{{ vuln.fixed_in }}</strong> or later
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<Alert v-if="vuln.fixed_in" variant="info">
|
||||
<AlertTitle>Fix available</AlertTitle>
|
||||
<AlertDescription>
|
||||
Upgrade to version <strong>{{ vuln.fixed_in }}</strong> or later.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
|
||||
<!-- References -->
|
||||
<div v-if="vuln.references && vuln.references.length > 0">
|
||||
<h5 class="font-semibold text-gray-900 mb-2 flex items-center gap-2">
|
||||
<i class="fas fa-link"></i>
|
||||
References ({{ vuln.references.length }})
|
||||
</h5>
|
||||
<div class="space-y-1.5">
|
||||
<div
|
||||
v-for="(ref, refIndex) in vuln.references"
|
||||
:key="refIndex"
|
||||
class="flex items-start gap-2 text-sm"
|
||||
>
|
||||
<i class="fas fa-external-link-alt text-gray-400 text-xs mt-0.5"></i>
|
||||
<a
|
||||
:href="ref"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="text-blue-600 hover:text-blue-800 hover:underline break-all"
|
||||
>
|
||||
{{ ref }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</template>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
<section v-if="vuln.references && vuln.references.length > 0">
|
||||
<h3 class="mb-2 text-sm font-semibold">References ({{ vuln.references.length }})</h3>
|
||||
<ul class="m-0 flex list-none flex-col gap-1 p-0 text-sm">
|
||||
<li v-for="(ref, refIndex) in vuln.references" :key="refIndex" class="break-all">
|
||||
<Link :href="ref" external>{{ ref }}</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</template>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -252,32 +156,37 @@
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import axios from 'axios'
|
||||
import { marked } from 'marked'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
|
||||
import { Badge } from '@/components/ui/badge'
|
||||
import { Alert, AlertDescription } from '@/components/ui/alert'
|
||||
import { Separator } from '@/components/ui/separator'
|
||||
import {
|
||||
Alert,
|
||||
AlertDescription,
|
||||
AlertTitle,
|
||||
Badge,
|
||||
Button,
|
||||
Card,
|
||||
CardContent,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
DescriptionItem,
|
||||
DescriptionList,
|
||||
EmptyState,
|
||||
ErrorState,
|
||||
IconButton,
|
||||
Link,
|
||||
LoadingState,
|
||||
Markdown,
|
||||
PageHeader,
|
||||
StatusBadge,
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from '@/components/ui/table'
|
||||
import {
|
||||
getSeverityBadgeClass,
|
||||
getRegistryBadgeClass,
|
||||
getVulnerabilityBorderClass,
|
||||
formatSeverityName,
|
||||
} from '@/composables/useBadgeStyles'
|
||||
|
||||
// Configure marked
|
||||
marked.setOptions({
|
||||
breaks: true,
|
||||
gfm: true,
|
||||
})
|
||||
} from '@perfect-design/ui'
|
||||
import SeveritySummary from './SeveritySummary.vue'
|
||||
import { formatDate } from '@/lib/format'
|
||||
import { faArrowLeft, faChevronDown, faChevronUp, faCircleCheck } from '@/lib/icons'
|
||||
import { NO_VULNERABILITIES, SEVERITY_TONES, formatSeverityName, severityRank } from '@/lib/severity'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
@@ -332,27 +241,15 @@ const error = ref<string | null>(null)
|
||||
const vulnerabilities = ref<VulnerabilityResponse | null>(null)
|
||||
const expandedRows = ref<Set<number>>(new Set())
|
||||
|
||||
// Severity order for sorting (higher values = more severe)
|
||||
const severityOrder: Record<string, number> = {
|
||||
CRITICAL: 4,
|
||||
HIGH: 3,
|
||||
MEDIUM: 2,
|
||||
MODERATE: 2, // Treat MODERATE same as MEDIUM
|
||||
LOW: 1,
|
||||
UNKNOWN: 0,
|
||||
}
|
||||
|
||||
const vulnerabilityList = computed(() => {
|
||||
const vulns = vulnerabilities.value?.vulnerabilities || []
|
||||
// Sort by severity (most severe first)
|
||||
return [...vulns].sort((a, b) => {
|
||||
const severityA = severityOrder[a.severity.toUpperCase()] || 0
|
||||
const severityB = severityOrder[b.severity.toUpperCase()] || 0
|
||||
return severityB - severityA // Descending order
|
||||
return severityRank(b.severity) - severityRank(a.severity)
|
||||
})
|
||||
})
|
||||
|
||||
const severityCounts = computed(() => vulnerabilities.value?.severity_counts || { critical: 0, high: 0, moderate: 0, low: 0 })
|
||||
const severityCounts = computed(() => vulnerabilities.value?.severity_counts || NO_VULNERABILITIES)
|
||||
const bypassedCount = computed(() => vulnerabilities.value?.bypassed_count || 0)
|
||||
|
||||
// Parse scanner string into array of scanner names
|
||||
@@ -396,21 +293,4 @@ function toggleRow(index: number) {
|
||||
}
|
||||
}
|
||||
|
||||
function getRowClass(index: number, severity: string): string {
|
||||
const classes = ['cursor-pointer']
|
||||
if (expandedRows.value.has(index)) {
|
||||
classes.push('bg-gray-50')
|
||||
}
|
||||
classes.push(getVulnerabilityBorderClass(severity))
|
||||
return classes.join(' ')
|
||||
}
|
||||
|
||||
function formatDate(date: string): string {
|
||||
return new Date(date).toLocaleString()
|
||||
}
|
||||
|
||||
function renderMarkdown(text: string): string {
|
||||
if (!text) return ''
|
||||
return marked.parse(text) as string
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user