Skip to content
Open
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
5 changes: 2 additions & 3 deletions lib/vendorCargoRegistries.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ let
inherit (lib)
concatMapStrings
concatStrings
escapeShellArg
flatten
foldl
groupBy
Expand Down Expand Up @@ -65,7 +64,7 @@ let
runCommandLocal "vendor-registry" { } ''
mkdir -p $out
${concatMapStrings (p: ''
ln -s ${escapeShellArg (vendorCrate p)} $out/${escapeShellArg "${p.name}-${p.version}"}
ln -s ${vendorCrate p} $out/${p.name}-${p.version}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. vendorCrate p should be a store path yes, but can store paths contain spaces? If not the /nix/store/<hash>-<name> path, what about subdirectories? Technically the caller can override the download derivation with whatever they want. Maybe its their own fault if they do a shell injection, but escaping here is a foolproof way of dealing with quoting
  2. I'd strongly prefer we keep escaping ${p.name}-${p.version}. There's probably a number of different ways to set them to something potentially evil

@llakala llakala Jun 26, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. How about we just always quote? ln -s '${vendorCrate }'. Depends on whether subdirectories can contain '.
  2. I can live with that. Although it would need single quotes for escapeShellArg to do anything, which your example doesn't use.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If overrideVendorCargoPackage returns a quoted path quoting it again might end up "undoing" the quotes

'') packages}
'';

Expand Down Expand Up @@ -158,7 +157,7 @@ let
hashed = hash prefixedUrl;
in
''
[source.${escapeShellArg name}]
[source.${name}]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original motivation for escaping name here was to avoid potential quoting issues, though its probably the wrong tool for the job anyway. I suppose these are directly controlled by the caller (via whatever registries they have configured directly in the craneLib instantiation) so I'm okay with relaxing this

registry = "${url}"
replace-with = "nix-sources-${hashed}"
''
Expand Down