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

Only audit packages we actually provide #92

Closed
wants to merge 14 commits into from
Closed

Conversation

phenaproxima
Copy link
Collaborator

I discovered why Composer makes so many extra requests for packages that are not part of a particular repository (as surfaced in composer/composer#11704 and php-tuf/drupal-project#1) -- composer require and composer update will do a security audit by default, unless you pass the --no-audit option. While auditing, repositories that support it are queried for all packages, even ones they don't provide.

To be clear, this is an upstream bug in Composer and still needs to be fixed; I will update and repurpose composer/composer#11704. But we can work around it by overriding ComposerRepository::getSecurityAdvisories() so that, if we are using an available-package-patterns filter, we don't try to get security advisories for packages we don't provide.

Copy link
Contributor

@tedbow tedbow left a comment

Choose a reason for hiding this comment

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

We need some sort of test for this because the worst case scenario is that we accidently unset it for package we are suppose return an advisory for and the whole system doesn't work.

One idea is to 2 repositories set up both "security-advisories" set up and have both packages installed with insecure versions. Then do a composer audit then confirm only the one we expect to filtered out is actually filtered out

@phenaproxima
Copy link
Collaborator Author

Looks like the upstream bug was fixed in Composer: composer/composer#11704.

Do we want to just close this out?

@phenaproxima
Copy link
Collaborator Author

Here's how we could test this out manually. In a Drupal project (just a regular recommended-project will do), running composer update -vvv should NOT have requests like this in it:

Downloading https://packages.drupal.org/files/packages/8/p2/consolidation/annotated-command.json

That's an example of Composer asking a repository for info on a package it does not have, and never has.

@phenaproxima
Copy link
Collaborator Author

Can confirm that, testing manually with Composer 2.7.7, I didn't see any of those bad requests.

@phenaproxima phenaproxima deleted the refuse-audit branch July 2, 2024 13:48
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.

2 participants