-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for intoto v0.0.1 entries (#70)
* Add support for intoto v0.0.1 entries There are still many applications that upload intoto v001 entries, so adding back support. Fixes #69 Signed-off-by: Hayden Blauzvern <[email protected]> * prettier Signed-off-by: Hayden Blauzvern <[email protected]> --------- Signed-off-by: Hayden Blauzvern <[email protected]>
- Loading branch information
1 parent
7f3e714
commit cee2879
Showing
3 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Box> | ||
<Typography | ||
variant="h5" | ||
sx={{ py: 1 }} | ||
> | ||
<NextLink | ||
href={`/?hash=${intoto.content.payloadHash?.algorithm}:${intoto.content.payloadHash?.value}`} | ||
passHref | ||
> | ||
<Link>Hash</Link> | ||
</NextLink> | ||
</Typography> | ||
|
||
<SyntaxHighlighter | ||
language="text" | ||
style={atomDark} | ||
> | ||
{`${intoto.content.payloadHash?.algorithm}:${intoto.content.payloadHash?.value}`} | ||
</SyntaxHighlighter> | ||
|
||
<Typography | ||
variant="h5" | ||
sx={{ py: 1 }} | ||
> | ||
Signature | ||
</Typography> | ||
<SyntaxHighlighter | ||
language="text" | ||
style={atomDark} | ||
> | ||
{"Missing for intoto v0.0.1 entries"} | ||
</SyntaxHighlighter> | ||
<Typography | ||
variant="h5" | ||
sx={{ py: 1 }} | ||
> | ||
{publicKey.title} | ||
</Typography> | ||
<SyntaxHighlighter | ||
language="yaml" | ||
style={atomDark} | ||
> | ||
{publicKey.content} | ||
</SyntaxHighlighter> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters