Skip to content

Conversation

@danielhardej
Copy link
Contributor

@danielhardej danielhardej commented Oct 23, 2025

The issue was that encodeURI(change.package_url) was encoding already encoded URLs. For example, for a package with PURL pkg:npm/@netdata/charts after encoding with encodeURI() would be: pkg:npm/%40netdata/charts.

Removing this unnecessary encoding prevents the mismatch issue in #1006

The fix would be to modify line 177 in licenses.ts to remove the use of the encodeURI() method. From what I understand, the parsePURL() function in purl.ts already handles URI decoding properly with decodeURIComponent() and PURLs from the Dependency Graph API are (notionally) already properly formatted. The license exclusions list would contain the normal, unencoded package URLs and so the namespace comparison on line 186 of licenses.ts will no longer always return false, thereby excluding scoped packages in allow-dependencies-licenses from the license check.

AFAIK, this change should be safe because:

  • parsePURL() can handle both encoded and unencoded URLs
  • decodeURIComponent() is used to normalise the namespace and name.

Closes: #1006

@danielhardej danielhardej requested a review from a team as a code owner October 23, 2025 08:15
Copilot AI review requested due to automatic review settings October 23, 2025 08:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where scoped npm packages (e.g., @netdata/charts) were incorrectly handled in license checking due to double-encoding of package URLs. The fix removes unnecessary encodeURI() call since PURLs from the Dependency Graph API are already properly formatted and parsePURL() handles decoding internally.

  • Removed redundant encodeURI() call that was double-encoding already-encoded package URLs
  • Updated @types/jest dependency to latest patch version

Reviewed Changes

Copilot reviewed 2 out of 5 changed files in this pull request and generated no comments.

File Description
src/licenses.ts Removed encodeURI() wrapper to prevent double-encoding of package URLs when parsing
package.json Updated @types/jest from 29.5.12 to 29.5.14

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

dangoor
dangoor previously approved these changes Nov 4, 2025
Copy link
Contributor

@dangoor dangoor left a comment

Choose a reason for hiding this comment

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

This makes sense! Thanks for the fix!

@danielhardej danielhardej reopened this Nov 7, 2025
@danielhardej danielhardej requested a review from dangoor November 7, 2025 04:40
dangoor
dangoor previously approved these changes Nov 7, 2025
@ahpook
Copy link
Contributor

ahpook commented Nov 7, 2025

I am in favor of this change but I wonder if it will break people's configs who have already worked around the double-escaping with the workaround as in #1006 and #1011 ?

@dangoor dangoor merged commit ebabd31 into actions:main Nov 7, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] DRA doesn't detect scoped packages due to PURL encoding

3 participants