Skip to content

feat: Github fallback for empty PURL for license exclusion #848

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

Closed
wants to merge 2 commits into from

Conversation

jscaltreto
Copy link

The action uses the change's package_url (as returned from the dependency graph API) to match against the exclusions passed via allow-dependencies-licenses. However, some changes do not include package_url, but they can still result in the action failing a license check as the check itself doesn't rely on package_url. Currently there's no mechanism in place to exclude a dependency from the license check if the package_url is empty.

This adds a fallback mechanism that parses source_repository_url to attempt to match based on the repository name. So allow-dependencies-licenses could include, for example, pkg:github/owner/repo and that would match a change with source_repository_url: "https://github.com/owner/repo".

This doesn't cover all cases; if source_repository_url is empty or doesn't point to a github-hosted repository then it will still fail to match.

@hmaurer
Copy link
Contributor

hmaurer commented Nov 22, 2024

Hi @jscaltreto , thanks for filing a pull request, and my apologies for the delay in reviewing it. Could you provide an example of a situation where package_url is not included but source_repository_url is? I know this would be the case for dependency changes to version ranges (e.g. to a package.json file). Is that what you encountered?

@hmaurer hmaurer self-assigned this Nov 22, 2024
@jscaltreto
Copy link
Author

Hi @hmaurer! The example where I encountered this was when using a package directly from a github repo instead of npm as one might do to install an unreleased version of a dependency. Here's a trivial example. In this case, calling the dependency-graph API the result contains:

 {
    "change_type": "added",
    "manifest": "package.json",
    "ecosystem": "npm",
    "name": "octokit",
    "version": "github:octokit/octokit.js#4.0.2",
    "package_url": "",
    "license": null,
    "source_repository_url": "https://github.com/octokit/octokit.js",
    "scope": "runtime",
    "vulnerabilities": []
  }

@hmaurer
Copy link
Contributor

hmaurer commented Nov 22, 2024

@jscaltreto I see, thank you for the prompt reply. Let me talk to some people internally about this. I wonder if the right approach here would be for us to change the API so that we'd return a PURL without a version specifier in such cases, similar to what you're doing in this pull request, e.g.

 {
    "change_type": "added",
    "manifest": "package.json",
    "ecosystem": "npm",
    "name": "octokit",
    "version": "github:octokit/octokit.js#4.0.2",
+   "package_url": "pkg:npm/octokit",
    "license": null,
    "source_repository_url": "https://github.com/octokit/octokit.js",
    "scope": "runtime",
    "vulnerabilities": []
  }

Ideally we would include a version specifier but we may not be able to do this in the short term.

Copy link

👋 This pull request has been marked as stale because it has been open with no activity for 180 days. You can: comment on the PR or remove the stale label to hold stalebot off for a while, add the Keep label to hold stale off permanently, or do nothing. If you do nothing, this pull request will be closed eventually by the stalebot. Please see CONTRIBUTING.md for more policy details.

@github-actions github-actions bot added the Stale label May 22, 2025
Copy link

github-actions bot commented Jun 6, 2025

👋 This pull request has been closed by stalebot because it has been open with no activity for over 180 days. Please see CONTRIBUTING.md for more policy details.

@github-actions github-actions bot closed this Jun 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants