Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

json file missing #301

Closed
laurentsimon opened this issue Feb 15, 2023 · 10 comments
Closed

json file missing #301

laurentsimon opened this issue Feb 15, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@laurentsimon
Copy link
Contributor

laurentsimon commented Feb 15, 2023

I get this error when using the library and ncc to compile my project: ::error::Cannot find module '../../store/public-good-instance-root.json'

Problem with tuf-js?

Any pointers? happy to send a PR, but I'm not sure where this file is looked up.

@laurentsimon laurentsimon added the bug Something isn't working label Feb 15, 2023
@laurentsimon
Copy link
Contributor Author

/cc asraa

@ianlewis
Copy link

ianlewis commented Feb 15, 2023

@asraa
Copy link

asraa commented Feb 15, 2023

This seems like a similar problem to the rekor.pub being distributed - for Ian and Laurent - this file is likely the initial trusted root after which the Rekor/Fulcio key material is fetched from

@asraa
Copy link

asraa commented Feb 15, 2023

I think this is where it is being read:

const tufRootSrc = require.resolve(`../../store/${name}-root.json`);

There's a small indirection here that probably made codesearch hard. The public-good-instance-root.json is fetched from its definition in this map.json file that describes the TUF roots: https://github.com/sigstore/sigstore-js/blob/6ccf8d04a6b8c12e0a2457f217325a022dff7b76/store/map.json

@laurentsimon
Copy link
Contributor Author

laurentsimon commented Feb 15, 2023

Thanks Asra, indeed I just did a lazy grep which returned nothing :-)

The fix for the rekor.pub was to use require.resolve (see https://github.com/sigstore/sigstore-js/pull/216/files) but the code here already uses that. I do see the map.json file copied correctly by ncc, but not the dynamically-created one.

I wonder whether the dynamic name makes ncc not realize that it needs to copy the file over? The hard-codedmap.json

const mapSrc = require.resolve('../../store/map.json');
seems to be working just fine.

@bdehamer
Copy link
Collaborator

Haven't used ncc before, but it does seem that the dynamic nature of the resolution of the public-good-instance-root.json makes it so that ncc doesn't realize that this file needs to be packed.

After I ran ncc on the sigstore-js project, I saw that the require.resolve for the "map.json" file got re-written to:

const mapSrc = __nccwpck_require__.ab + "map.json";

while the statement for the "public-good-instance-root.json" was left as:

const tufRootSrc = require.resolve(`../../store/${name}-root.json`);

Definitely open to suggestions for how to make this more ncc-friendly.

@ianlewis
Copy link

ianlewis commented Feb 15, 2023

Based on vercel/ncc#74 (comment) we might have better luck with ncc static analysis if the require took the following form. I guess it then could know that anything under ../../store/ should be included?

const tufRootFile = `${name}-root.json`
const tufRootSrc = require.resolve(`../../store/' + tufRootFile);

@bdehamer
Copy link
Collaborator

@ianlewis we haven't yet published the new version (probably next week), but #330 should have resolved this issue.

@ianlewis
Copy link

@ianlewis we haven't yet published the new version (probably next week), but #330 should have resolved this issue.

@bdehamer Thanks! I saw your PR. I'll look forward to the new release.

@bdehamer
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants