diff --git a/src/modules/components/Entry.tsx b/src/modules/components/Entry.tsx index d4680d1..408ab09 100644 --- a/src/modules/components/Entry.tsx +++ b/src/modules/components/Entry.tsx @@ -18,11 +18,18 @@ import { Convert } from "pvtsutils"; import { ReactNode } from "react"; import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { atomDark } from "react-syntax-highlighter/dist/cjs/styles/prism"; -import { DSSEV001Schema, IntotoV002Schema, LogEntry, RekorSchema } from "rekor"; +import { + DSSEV001Schema, + IntotoV001Schema, + IntotoV002Schema, + LogEntry, + RekorSchema, +} from "rekor"; import { toRelativeDateString } from "../utils/date"; import { DSSEViewer } from "./DSSE"; import { HashedRekordViewer } from "./HashedRekord"; -import { IntotoViewer } from "./Intoto"; +import { IntotoViewer001 } from "./Intoto001"; +import { IntotoViewer002 } from "./Intoto002"; const DUMP_OPTIONS: jsyaml.DumpOptions = { replacer: (key, value) => { @@ -128,8 +135,13 @@ export function Entry({ entry }: { entry: LogEntry }) { parsed = ; break; case "intoto": - parsed = ; - break; + if (body.apiVersion == "0.0.1") { + parsed = ; + break; + } else { + parsed = ; + break; + } case "dsse": parsed = ; break; diff --git a/src/modules/components/Intoto001.tsx b/src/modules/components/Intoto001.tsx new file mode 100644 index 0000000..f46f4c3 --- /dev/null +++ b/src/modules/components/Intoto001.tsx @@ -0,0 +1,71 @@ +import { Box, Link, Typography } from "@mui/material"; +import { dump } from "js-yaml"; +import NextLink from "next/link"; +import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; +import { atomDark } from "react-syntax-highlighter/dist/cjs/styles/prism"; +import { IntotoV001Schema } from "rekor"; +import { decodex509 } from "../x509/decode"; + +export function IntotoViewer001({ intoto }: { intoto: IntotoV001Schema }) { + const certContent = window.atob(intoto.publicKey || ""); + + const publicKey = { + title: "Public Key", + content: certContent, + }; + if (certContent.includes("BEGIN CERTIFICATE")) { + publicKey.title = "Public Key Certificate"; + publicKey.content = dump(decodex509(certContent), { + noArrayIndent: true, + lineWidth: -1, + }); + } + + return ( + + + + Hash + + + + + {`${intoto.content.payloadHash?.algorithm}:${intoto.content.payloadHash?.value}`} + + + + Signature + + + {"Missing for intoto v0.0.1 entries"} + + + {publicKey.title} + + + {publicKey.content} + + + ); +} diff --git a/src/modules/components/Intoto.tsx b/src/modules/components/Intoto002.tsx similarity index 95% rename from src/modules/components/Intoto.tsx rename to src/modules/components/Intoto002.tsx index 91b3263..1af702b 100644 --- a/src/modules/components/Intoto.tsx +++ b/src/modules/components/Intoto002.tsx @@ -6,7 +6,7 @@ import { atomDark } from "react-syntax-highlighter/dist/cjs/styles/prism"; import { IntotoV002Schema } from "rekor"; import { decodex509 } from "../x509/decode"; -export function IntotoViewer({ intoto }: { intoto: IntotoV002Schema }) { +export function IntotoViewer002({ intoto }: { intoto: IntotoV002Schema }) { const signature = intoto.content.envelope?.signatures[0]; const certContent = window.atob(signature?.publicKey || "");