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: Scorecard's npm search doesn't match exact #2441

Closed
scovetta opened this issue Nov 8, 2022 · 1 comment
Closed

BUG: Scorecard's npm search doesn't match exact #2441

scovetta opened this issue Nov 8, 2022 · 1 comment
Labels
kind/bug Something isn't working

Comments

@scovetta
Copy link
Contributor

scovetta commented Nov 8, 2022

Describe the bug
The Scorecard npm package integration uses the npm registry full text search function, which seems to omit deprecated packages. This means when searching for left-pad, you get the package repeat-string, which causes a later failure:

Error: GetClients: getting local directory client: error during parse: invalid repo flag: . Exepted full repository url

https://registry.npmjs.org/-/v1/search?text=left-pad&size=1
image

I think the call could be changed to just registry.npmjs.org/<package name>, but you'd have to find the best repository URL (probably in versions[dist-tags.latest].repository.url). Or, if there's an advantage to doing it the current way, then try that first and then fall back to the direct URL.

Reproduction steps
Steps to reproduce the behavior:

  1. Run Scorecard against left-pad:
docker run -e GITHUB_AUTH_TOKEN=XXXXXXXXXXXXXXXXXXXXXX gcr.io/openssf/scorecard:stable --npm=left-pad --show-details
  1. See the error:
Error: GetClients: getting local directory client: error during parse: invalid repo flag: . Exepted full repository url
2022/11/08 22:47:42 error during command execution: GetClients: getting local directory client: error during parse: invalid repo flag: . Exepted full repository url

Expected behavior
For left-pad, it should attempt to load the GitHub repository URL.

Additional context
N/A

@scovetta scovetta added the kind/bug Something isn't working label Nov 8, 2022
@afmarcum afmarcum moved this to Backlog - Bugs in Scorecard - NEW Mar 5, 2024
aklevans added a commit to aklevans/scorecard that referenced this issue May 21, 2024
spencerschrock pushed a commit that referenced this issue Jun 5, 2024
…pm database (#4118)

* Update endpoint used when getting repo from npm to solve #3166

Signed-off-by: aklevans <[email protected]>

* Update test files to account for endpoint change when getting repo from npm

Signed-off-by: aklevans <[email protected]>

* Fix linter issues

Signed-off-by: aklevans <[email protected]>

* Added unit tests for #3166 and #2441

Signed-off-by: aklevans <[email protected]>

* fix linter issues and reduce mock json output in package_manager_test to only include necessary data

Signed-off-by: aklevans <[email protected]>

* fix linter issues in package_managers.go

Signed-off-by: aklevans <[email protected]>

* convert windows line breaks to linux

Signed-off-by: aklevans <[email protected]>

* reduce test case size, still has windows line breaks

Signed-off-by: aklevans <[email protected]>

* Fix unit tests

Signed-off-by: aklevans <[email protected]>

* attempt linter fix

Signed-off-by: aklevans <[email protected]>

* Fix linter issues stemming from windows line breaks

Signed-off-by: aklevans <[email protected]>

* Remove magic number and rename variable to be more accurate

Signed-off-by: aklevans <[email protected]>

---------

Signed-off-by: aklevans <[email protected]>
Signed-off-by: aklevans <[email protected]>
@spencerschrock
Copy link
Member

Fixed by #4118

@github-project-automation github-project-automation bot moved this from Backlog - Bugs to Done in Scorecard - NEW Jun 5, 2024
balteravishay pushed a commit to balteravishay/scorecard that referenced this issue Jun 12, 2024
…pm database (ossf#4118)

* Update endpoint used when getting repo from npm to solve ossf#3166

Signed-off-by: aklevans <[email protected]>

* Update test files to account for endpoint change when getting repo from npm

Signed-off-by: aklevans <[email protected]>

* Fix linter issues

Signed-off-by: aklevans <[email protected]>

* Added unit tests for ossf#3166 and ossf#2441

Signed-off-by: aklevans <[email protected]>

* fix linter issues and reduce mock json output in package_manager_test to only include necessary data

Signed-off-by: aklevans <[email protected]>

* fix linter issues in package_managers.go

Signed-off-by: aklevans <[email protected]>

* convert windows line breaks to linux

Signed-off-by: aklevans <[email protected]>

* reduce test case size, still has windows line breaks

Signed-off-by: aklevans <[email protected]>

* Fix unit tests

Signed-off-by: aklevans <[email protected]>

* attempt linter fix

Signed-off-by: aklevans <[email protected]>

* Fix linter issues stemming from windows line breaks

Signed-off-by: aklevans <[email protected]>

* Remove magic number and rename variable to be more accurate

Signed-off-by: aklevans <[email protected]>

---------

Signed-off-by: aklevans <[email protected]>
Signed-off-by: aklevans <[email protected]>
Signed-off-by: balteraivshay <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants