Skip to content

Commit

Permalink
load TUF seeds via require not require.resolve (#1014)
Browse files Browse the repository at this point in the history
Signed-off-by: Brian DeHamer <bdehamer@github.com>
  • Loading branch information
bdehamer authored Feb 15, 2024
1 parent 1e50cf6 commit d40c443
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-waves-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sigstore/tuf": patch
---

Load TUF seeds via `require` instead of `require.resolve`
7 changes: 2 additions & 5 deletions packages/tuf/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import type { MakeFetchHappenOptions } from 'make-fetch-happen';

export type Retry = MakeFetchHappenOptions['retry'];

const TUF_SEEDS_PATH = require.resolve('../seeds.json');
const TARGETS_DIR_NAME = 'targets';

type RepoSeed = {
Expand Down Expand Up @@ -125,10 +124,8 @@ function seedCache({
if (tufRootPath) {
fs.copyFileSync(tufRootPath, cachedRootPath);
} else {
// Load the embedded repo seeds
const seeds: RepoSeeds = JSON.parse(
fs.readFileSync(TUF_SEEDS_PATH).toString('utf-8')
);
/* eslint-disable @typescript-eslint/no-var-requires */
const seeds: RepoSeeds = require('../seeds.json');
const repoSeed = seeds[mirrorURL];

if (!repoSeed) {
Expand Down

0 comments on commit d40c443

Please sign in to comment.