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

[BUG] [DEP0170] DeprecationWarning for git+ssh:// dependencies #6869

Closed
2 tasks done
dmke opened this issue Oct 5, 2023 · 6 comments
Closed
2 tasks done

[BUG] [DEP0170] DeprecationWarning for git+ssh:// dependencies #6869

dmke opened this issue Oct 5, 2023 · 6 comments
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 9.x work is associated with a specific npm 9 release Release 10.x

Comments

@dmke
Copy link

dmke commented Oct 5, 2023

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

On Node v20, DEP0170 is active:

Type: Runtime

url.parse() accepts URLs with ports that are not numbers. This behavior might result in host name spoofing with unexpected input. These URLs will throw an error in future versions of Node.js, as the WHATWG URL API does already.

It looks like npm tries to parse dependencies like

{
  "dependencies": {
    "something-private": "git+ssh://git@gitlab.example.com:group/project.git#commitish"
  }
}

with url.parse, which in turn interprets group as port number.

The NPM docs on Git URLs as Dependencies state:

Git urls are of the form:

<protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit-ish> | #semver:<semver>]

<protocol> is one of git, git+ssh, git+http, git+https, or git+file.

Changing the dependency URL to

git+ssh://git@gitlab.example.com:22:group/project.git#commitish

leads to Gitlab intepreting "22:group" as (non-existing) project namespace.

Expected Behavior

The warning should be addressed.

Since Node obviously seeks WHATWG URL API compatibility, there are a few options:

  1. Use a custom URL parser, which allows to parse all documented NPM dependency URL formats, without warnings.
  2. Deprecate dependency URL formats which don't follow the WHATWG API URL specification.
  3. Amend the WHATWG API URL with generic URL formats, such as git+ssh, where host/port and path are separated by a colon.

Steps To Reproduce

See current behaviour above:

  1. reference a dependency via git+ssh:// URL
  2. run npm install
  3. observe the warning [DEP0170] DeprecationWarning: The URL git+ssh://... is invalid. Future versions of Node.js will throw an error.

Environment

  • npm: 10.1.0
  • Node.js: v20.8.0
  • OS Name: Debian 11.7
  • System Model Name: n/a
  • npm config:
; "user" config from /home/dm/.npmrc

prefix = "/home/dm/.local" 
python = "/usr/bin/python3" 

; node bin location = /usr/bin/node
; node version = v20.8.0
; npm local prefix = [irrelevant]
; npm version = 10.1.0
; cwd = [irrelevant]
; HOME = [irrelevant]
; Run `npm config ls -l` to show all defaults.
@dmke dmke added Bug thing that needs fixing Needs Triage needs review for next steps Release 10.x labels Oct 5, 2023
@ljharb
Copy link
Contributor

ljharb commented Oct 5, 2023

Indeed, npm (and the ecosystem) will need a longer-term solution for URLs like this.

@lukekarrys lukekarrys added Priority 2 secondary priority issue regression:10.x and removed Needs Triage needs review for next steps labels Oct 6, 2023
@dmke
Copy link
Author

dmke commented Oct 6, 2023

@lukekarrys: This isn't a regression in 10.x, the 9.x series is affected as well (I suspect all NPM versions running on Node 20+ are).

@lukekarrys
Copy link
Contributor

@dmke Thank you, I thought we switched URL parsers in the switch to npm@10 but that must have happened at a different time.

@lukekarrys lukekarrys added Release 9.x work is associated with a specific npm 9 release and removed regression:10.x labels Oct 6, 2023
@wraithgar
Copy link
Member

This was fixed in npm@10.2.0 which brought in npm-package-arg@11.0.1

cf npm/npm-package-arg#141

@dmke
Copy link
Author

dmke commented Oct 13, 2023

Can confirm, updating to 10.2.0 fixes this issue.

Thank you!

hellodword added a commit to hellodword/edgestatus that referenced this issue Oct 18, 2023
hellodword added a commit to hellodword/edgestatus that referenced this issue Oct 21, 2023
@DeepzUa
Copy link

DeepzUa commented Mar 27, 2024

I have same warning on npm 10.5.0 and nodejs 20.12.0 but im using #tag

{
  "dependencies": {
    "something-private": "git+ssh://git@gitlab.example.com:group/project.git#tag"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 9.x work is associated with a specific npm 9 release Release 10.x
Projects
None yet
Development

No branches or pull requests

5 participants