-
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.
implement all flags for conformance verify cmd
Signed-off-by: Brian DeHamer <bdehamer@github.com>
- Loading branch information
Showing
8 changed files
with
88 additions
and
89 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sigstore/conformance': minor | ||
--- | ||
|
||
Implement `--trusted-root` flag on `verify` command. |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,37 @@ | ||
import { TrustedRoot } from '@sigstore/protobuf-specs'; | ||
import * as tuf from '@sigstore/tuf'; | ||
import { toTrustMaterial, TrustMaterial } from '@sigstore/verify'; | ||
import fs from 'fs/promises'; | ||
import os from 'os'; | ||
import path from 'path'; | ||
import { TUF_STAGING_ROOT, TUF_STAGING_URL } from './staging'; | ||
|
||
// Initialize TrustMaterial from TUF | ||
export async function trustMaterialFromTUF( | ||
staging: boolean | ||
): Promise<TrustMaterial> { | ||
const opts: tuf.TUFOptions = {}; | ||
|
||
if (staging) { | ||
// Write the initial root.json to a temporary directory | ||
const tmpPath = await fs.mkdtemp(path.join(os.tmpdir(), 'sigstore-')); | ||
const rootPath = path.join(tmpPath, 'root.json'); | ||
await fs.writeFile(rootPath, Buffer.from(TUF_STAGING_ROOT, 'base64')); | ||
|
||
opts.mirrorURL = TUF_STAGING_URL; | ||
opts.rootPath = rootPath; | ||
} | ||
|
||
const trustedRoot = await tuf.getTrustedRoot(opts); | ||
return toTrustMaterial(trustedRoot); | ||
} | ||
|
||
// Initialize TrustMaterial from a file | ||
export async function trustMaterialFromPath( | ||
path: string | ||
): Promise<TrustMaterial> { | ||
const trustedRoot = await fs | ||
.readFile(path) | ||
.then((data) => JSON.parse(data.toString())); | ||
return toTrustMaterial(TrustedRoot.fromJSON(trustedRoot)); | ||
} |
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