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

NodeJS checksum not being verified after downloading via the npm plugin #717

Closed
alnvdl-work opened this issue Apr 24, 2024 · 4 comments
Closed
Labels
Bug Something isn't working

Comments

@alnvdl-work
Copy link

alnvdl-work commented Apr 24, 2024

Bug Description

Problem 1 (solved; see below)
The npm plugin installs NodeJS during the build step:

if options.npm_include_node:
arch = self._get_architecture()
version = options.npm_node_version
node_uri = (
f"https://nodejs.org/dist/v{version}"
f"/node-v{version}-linux-{arch}.tar.gz"
)
command.append(
dedent(
f"""\
if [ ! -f "${{CRAFT_PART_INSTALL}}/bin/node" ]; then
curl -s "{node_uri}" |
tar xzf - -C "${{CRAFT_PART_INSTALL}}/" \
--no-same-owner --strip-components=1
fi
"""
)
)

When building a ROCK, if we use override-build to customize the invocation of npm install as needed by our application, we don't get NodeJS installed. So we have to either download and install NodeJS ourselves, or resort to hacks like building the application during the stage step.

For building this ROCK, we found a nice workaround using overlay-script, which is good enough for us for now to install NodeJS independently:

The overlay step provides the means to modify the base filesystem before the build step is applied
See: https://canonical-rockcraft.readthedocs-hosted.com/en/latest/explanation/overlay-step/


Problem 2
Somewhat related to this: the download of NodeJS should also ideally have its checksum verified to mitigate the impacts of any supply-chain-attacks and eliminate the problem of corrupted downloads, maybe doing something similar to what Docker does:
https://github.com/nodejs/docker-node/blob/1fc16c3d1ea2be71fba69115f59d0e8f99876692/18/buster/Dockerfile

To Reproduce

Try to try to build any application whose npm install process needs to be customized to be different from the default dictated by the part.

part yaml

No response

Relevant log output

-
@alnvdl-work alnvdl-work added the Bug Something isn't working label Apr 24, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-2852.

This message was autogenerated

@tigarmo
Copy link
Contributor

tigarmo commented Apr 24, 2024

if we use override-build to customize the invocation of npm install as needed by our application

Can you talk about this customization in your specific case? One way to bypass this issue altogether would be to improve the plugin so that it does what you need it to do without having to override steps.

@alnvdl-work alnvdl-work changed the title Overriding the build step causes NodeJS to not be installed when using the npm plugin NodeJS checksum not being verified after downloading via the npm plugin Apr 25, 2024
@alnvdl-work
Copy link
Author

alnvdl-work commented Apr 25, 2024

Talked with @tigarmo in PMs. I did not know about craftctl default (https://snapcraft.io/docs/using-craftctl). That solved the problem for me, quite elegantly.

However, I believe the second part of this issue (downloading NodeJS without running a checksum) still persists. So I renamed it, and I will leave this open.

@cmatsuoka
Copy link
Collaborator

Fixed by PR #719

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

3 participants