Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/attic-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export const PUBLIC_NIXOS_CACHE = 'https://cache.nixos.org';
export const PUBLIC_NIXOS_KEY =
'cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=';

// Leaf packages outside stdenv/nodejs so Nix's hash scanner keeps allowedReferences = [].
// Leaf packages outside stdenv/fetchFromGitHub/nodejs so Nix FOD and allowedReferences = [] stay clean.
export const DEFAULT_UPSTREAM_SAMPLES: SamplePath[] = [
{ name: 'hello-2.12.3', hash: 'sd779x86bjaqxj2lzh2jsir4h0zjz6d1', group: 'Upstream' },
{ name: 'ripgrep-15.2.0', hash: 'whbrk657qmih065xal60m4khwf6cb9pj', group: 'Upstream' },
{ name: 'curl-8.22.0', hash: '5lpg7j8y8lf8c4zv318yi4rmgyn5yhip', group: 'Upstream' }
{ name: 'fd-10.5.1', hash: 'p7m1rnj0fm1nm9hwwj9vrgy3fc7grgg2', group: 'Upstream' }
];

const WITHHELD_MSG = 'Token not sent over plain HTTP: use an https:// endpoint';
Expand Down
14 changes: 8 additions & 6 deletions test/attic-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import {
updateBreadcrumbTrail
} from '../src/lib/attic-api.ts';

const SAMPLE_HASH = '9l0j15jg8634hkb6d4c9y95mpxl0nhrd';
// Synthetic Nix-base32 hashes so fetchFromGitHub's FOD scanner never matches stdenv inputs.
const SAMPLE_HASH = '00000000000000000000000000000001';
const DEP_HASH = '00000000000000000000000000000002';
const SAMPLE_NARINFO = [
`StorePath: /nix/store/${SAMPLE_HASH}-jq-1.8.2`,
'URL: nar/1abc2def.nar.zst',
Expand All @@ -36,7 +38,7 @@ const SAMPLE_NARINFO = [
'FileSize: 204800',
'NarHash: sha256:fedcba9876543210',
'NarSize: 614400',
`References: ${SAMPLE_HASH}-jq-1.8.2 pqyiidz5mi73wv5f91d48s9plcqyj5bz-glibc-2.44`,
`References: ${SAMPLE_HASH}-jq-1.8.2 ${DEP_HASH}-glibc-2.44`,
'Deriver: 00000000000000000000000000000000-jq-1.8.2.drv',
'Sig: cache.nixos.org-1:sigOne==',
'Sig: custom-cache-1:sigTwo==',
Expand Down Expand Up @@ -68,7 +70,7 @@ describe('parseNarInfo & parseCacheInfo', () => {
assert.equal(parsed.narSize, 614400);
assert.deepEqual(parsed.references, [
`${SAMPLE_HASH}-jq-1.8.2`,
'pqyiidz5mi73wv5f91d48s9plcqyj5bz-glibc-2.44'
`${DEP_HASH}-glibc-2.44`
]);
assert.equal(parsed.deriver, '00000000000000000000000000000000-jq-1.8.2.drv');
assert.deepEqual(parsed.sig, ['cache.nixos.org-1:sigOne==', 'custom-cache-1:sigTwo==']);
Expand Down Expand Up @@ -578,9 +580,9 @@ describe('Target resolution, presets, public keys, and breadcrumb state', () =>
});

it('appends, rewinds, and caps closure breadcrumb history cleanly', () => {
const h1 = '9l0j15jg8634hkb6d4c9y95mpxl0nhrd';
const h2 = 'pqyiidz5mi73wv5f91d48s9plcqyj5bz';
const h3 = '5lpg7j8y8lf8c4zv318yi4rmgyn5yhip';
const h1 = '00000000000000000000000000000001';
const h2 = '00000000000000000000000000000002';
const h3 = '00000000000000000000000000000003';

let trail = updateBreadcrumbTrail([], `/nix/store/${h1}-jq-1.8.2`);
trail = updateBreadcrumbTrail(trail, `/nix/store/${h2}-glibc-2.44`);
Expand Down
15 changes: 15 additions & 0 deletions test/ui-contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,19 @@ describe('Frontend static, security, and accessibility contracts', () => {
);
}
});

it('uses only synthetic store hashes in test/ so fetchFromGitHub FOD checks never match stdenv', async () => {
const files = await listFiles('test');
for (const file of files) {
const content = await readFile(file, 'utf8');
const matches = content.match(/[0-9a-df-np-sv-z]{32}/g) ?? [];
for (const hash of matches) {
assert.match(
hash,
/^0{28}[0-9a-df-np-sv-z]{4}$/,
`Non-synthetic Nix store hash '${hash}' in ${file} risks colliding with fetchFromGitHub FOD inputs`
);
}
}
});
});
Loading