feat(binary): enhance binary list with format and architecture badges

This commit is contained in:
Rodrigo Verdiani 2026-06-07 15:48:08 -03:00
parent 32d8e30fd9
commit d73366be73
2 changed files with 83 additions and 5 deletions

View File

@ -43,6 +43,7 @@ export interface BinaryResponse {
fileSize?: number; fileSize?: number;
format?: string; format?: string;
architecture?: string; architecture?: string;
compiler?: string;
/** @minLength 1 */ /** @minLength 1 */
filePath: string; filePath: string;
updatedAt: string; updatedAt: string;

View File

@ -18,6 +18,77 @@ import {
TableHeader, TableHeader,
TableRow, TableRow,
} from "@/components/ui/table.tsx"; } from "@/components/ui/table.tsx";
import { cn } from "@/lib/utils";
const formatConfig: Record<string, { bg: string; text: string }> = {
PE: { bg: "bg-chart-1/20", text: "text-chart-1" },
PE32: { bg: "bg-chart-1/20", text: "text-chart-1" },
PE64: { bg: "bg-chart-1/20", text: "text-chart-1" },
"PE32+": { bg: "bg-chart-1/20", text: "text-chart-1" },
ELF: { bg: "bg-chart-2/20", text: "text-chart-2" },
ELF32: { bg: "bg-chart-2/20", text: "text-chart-2" },
ELF64: { bg: "bg-chart-2/20", text: "text-chart-2" },
"Mach-O": { bg: "bg-chart-3/20", text: "text-chart-3" },
"Mach-O64": { bg: "bg-chart-3/20", text: "text-chart-3" },
NE: { bg: "bg-chart-4/20", text: "text-chart-4" },
LE: { bg: "bg-chart-4/20", text: "text-chart-4" },
LX: { bg: "bg-chart-4/20", text: "text-chart-4" },
"MS-DOS": { bg: "bg-chart-5/20", text: "text-chart-5" },
COM: { bg: "bg-chart-5/20", text: "text-chart-5" },
DEX: { bg: "bg-primary/20", text: "text-primary" },
APK: { bg: "bg-primary/20", text: "text-primary" },
IPA: { bg: "bg-primary/20", text: "text-primary" },
JAR: { bg: "bg-secondary/30", text: "text-secondary-foreground" },
ZIP: { bg: "bg-muted", text: "text-muted-foreground" },
Binary: { bg: "bg-muted", text: "text-muted-foreground" },
};
const architectureConfig: Record<string, { bg: string; text: string }> = {
"x86, 16-bit": { bg: "bg-chart-2/20", text: "text-chart-2" },
"x86, 32-bit": { bg: "bg-chart-2/20", text: "text-chart-2" },
"x86-64, 64-bit": { bg: "bg-chart-3/20", text: "text-chart-3" },
"ARM, 32-bit": { bg: "bg-chart-4/20", text: "text-chart-4" },
"ARM64, 64-bit": { bg: "bg-chart-1/20", text: "text-chart-1" },
"MIPS, 32-bit": { bg: "bg-chart-5/20", text: "text-chart-5" },
"MIPS64, 64-bit": { bg: "bg-chart-5/20", text: "text-chart-5" },
"PowerPC, 32-bit": { bg: "bg-chart-3/20", text: "text-chart-3" },
"PowerPC64, 64-bit": { bg: "bg-chart-3/20", text: "text-chart-3" },
};
const formatBadge = (format?: string) => {
if (!format) return "-";
const config = formatConfig[format] ?? { bg: "bg-muted", text: "text-muted-foreground" };
return (
<span
className={cn(
"inline-flex items-center rounded px-2 py-0.5 font-mono text-xs",
config.bg,
config.text
)}
>
{format}
</span>
);
};
const architectureBadge = (architecture?: string) => {
if (!architecture) return "-";
const config = architectureConfig[architecture] ?? {
bg: "bg-muted",
text: "text-muted-foreground",
};
return (
<span
className={cn(
"inline-flex items-center rounded px-2 py-0.5 font-mono text-xs",
config.bg,
config.text
)}
>
{architecture}
</span>
);
};
interface BinaryListProps { interface BinaryListProps {
binaries: BinaryResponse[]; binaries: BinaryResponse[];
@ -40,9 +111,9 @@ export const BinaryList = ({ binaries, onDelete, onDownload }: BinaryListProps)
<TableHead className="w-[40%]">Filename</TableHead> <TableHead className="w-[40%]">Filename</TableHead>
<TableHead>Format</TableHead> <TableHead>Format</TableHead>
<TableHead>Architecture</TableHead> <TableHead>Architecture</TableHead>
<TableHead>Compiler</TableHead>
<TableHead>Size</TableHead> <TableHead>Size</TableHead>
<TableHead>Functions</TableHead> <TableHead>Functions</TableHead>
<TableHead>Status</TableHead>
<TableHead>Uploaded</TableHead> <TableHead>Uploaded</TableHead>
<TableHead className="w-12.5"></TableHead> <TableHead className="w-12.5"></TableHead>
</TableRow> </TableRow>
@ -59,13 +130,19 @@ export const BinaryList = ({ binaries, onDelete, onDownload }: BinaryListProps)
<span className="font-mono text-sm">{binary.filename}</span> <span className="font-mono text-sm">{binary.filename}</span>
</Link> </Link>
</TableCell> </TableCell>
<TableCell>-</TableCell> <TableCell>{formatBadge(binary.format)}</TableCell>
<TableCell>-</TableCell> <TableCell>{architectureBadge(binary.architecture)}</TableCell>
<TableCell>
{binary.compiler ? (
<span className="text-muted-foreground font-mono text-xs">{binary.compiler}</span>
) : (
"-"
)}
</TableCell>
<TableCell className="text-muted-foreground font-mono text-sm"> <TableCell className="text-muted-foreground font-mono text-sm">
{formatSize(binary.fileSize!)} {binary.fileSize ? formatSize(binary.fileSize) : "-"}
</TableCell> </TableCell>
<TableCell className="font-mono text-sm">-</TableCell> <TableCell className="font-mono text-sm">-</TableCell>
<TableCell>-</TableCell>
<TableCell className="text-muted-foreground text-sm"> <TableCell className="text-muted-foreground text-sm">
{formatDistanceToNow(binary.updatedAt, { addSuffix: true })} {formatDistanceToNow(binary.updatedAt, { addSuffix: true })}
</TableCell> </TableCell>