Composer Repository Vulnerability Mirroring#4515
Conversation
|
@nscuro It's still in draft as I need to add docs, testcases and some cleanup. Would you be able to look at the overall approach taken? |
e2fab37 to
6489de1
Compare
|
There's one thing specifically I need feedback on. It is on how to handle advisories from Composer repositories that are really just a mirror of a CVE or GHSA. Composer, or more specific packagist.org, is merely just a vulnerability aggregator similar to OSV. It aggregates CVEs and GHSAs. But also vulnerabilities from other sources such as FriendsofPHP. This means a lot of advisories look like this: Which currently leads to DT creating a new vulnerability with Id I am wondering if this is the best approach? Osv has similar situation, but they do not put their own Id on these vulnerabilities. They use the CVE or GHSA is Id for their advisories. And DT then does not create a new vulnerability (unless NVD or GHSA mirroring is disabled/lagging behind). Should we do the same for these Composer advisories? Or should I just accept that DT is not (yet) good at deduplicating aliases and just add a new vulnerability with PKSA Id? The idea is that VulnerableSoftware and AffectedVersionAttribution (and aliases) should still be synced for these vulnerabilities. BTW After writing this comment I checked the advisories of packagist.org and it looks like all of them have at least a CVE or GHSA. I believe this is relatively new and it looks like GHSA has started to create advisories for all vulnerabilities of FriendsofPHP. So why enable Packagist advisory sync at all, just for the attribution part? For other repositories like Drupal8 the mirroring is still valid as they provide their own vulnerabilities in their feed (SA-CORE-xxxx, SA-CONTRIB-yyyy). There maybe more repositories in the future, such as for Magento, Shopware, ... This question about whether or not to "duplicate" all the CVE/GHSA vulnerabilities applies to more future vulnerability sources, for example Wordfence or WPScan. These are also aggregating from other sources. But they also add their own vulnerabilities to their feed. At some point you may have 5-6 aliases per vulnerability. |
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferencesCodacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more |
e392719 to
976bafa
Compare
d2917df to
e7a8de6
Compare
e222894 to
381634c
Compare
Signed-off-by: Valentijn Scholten <valentijnscholten@gmail.com>
381634c to
daa81e3
Compare
|
Did not yet have an answer to my question above, but went ahead and finsihed the implementation and test cases. Vulnerabilities that have a GHSA or CVE are not replicated, we only set the affected version attribution. Updated the description of the PR with the implemented logic. |
For the moment, it would be best to use CVEs and GHSAs if possible. The alias design needs an overhaul to properly deal with a lot of identifiers (perhaps you have some input for #4528?). Separately, what's your impression on the mapping of those aliases you've seen so far? Do PKSA's always map to one CVE/GHSA, or can there be multiple? Could those PHP sources suffer from the same problem as google/osv.dev#888? |
It's one-on-one, also for CVEs that alias GHSA and vice versa. Just verified that with some extra checks/logging during a mirror task. Packagist also makes some effort to deduplicate things from the two sources they import from:
source: https://blog.packagist.com/discover-security-advisories-with-composers-audit-command/ |
|
@nscuro What's the plan for this? I'm happy to resolve the conflicts, but would like to do it only once when a review/merge is near. |
The [Drupal Advisory Database](https://github.com/DrupalSecurityTeam/drupal-advisory-database) is a database maintained by Ackama on behalf of the Drupal community that provides [Drupal security advisories](https://www.drupal.org/drupal-security-team/security-advisory-process-and-permissions-policy) in OSV format to allow them to be ingested by osv.dev. While Drupal packages are installed and managed using Composer, they are (mostly) sourced from a dedicated repository rather than the Packagist repository; since these packages are all within the `drupal/` namespace which is owned by the Drupal community, it's been agreed that it is fine to still use the Packagist rather than introduce a new one. This means that existing tools like `osv-scanner` and libraries like `osv-scalibr` should "just work" with the advisories in this database. For the database prefix, the community are decided to use `DRUPAL` as that is straightforward and matches what other has been proposed in other tools like [`dependency-track`](DependencyTrack/dependency-track#4515), which replaces the "SA" prefix used by advisories published on drupal.org so advisory ids can be easily mapped to their original advisory by just replacing `DRUPAL` with `SA`. Discussion on this can be found [here](https://www.drupal.org/project/drupalorg/issues/3410338#comment-16200707) and [here](https://www.drupal.org/project/drupalorg/issues/3410338#comment-16200707) --------- Signed-off-by: Gareth Jones <3151613+G-Rath@users.noreply.github.com>

Description
Mirrors Security Advisories from Composer Repositories.
Implementation based on / tested with:
The packagist repository provides advisories that are imported from:
So mirroring from Packagist provides little benefit, unless you have GitHub advisories disabled.
The biggest benefit is in third party repositories such as the Drupal8 repository. For some vulnerabilities (plugins/themes), this is currently the only way to get these vulnerabilities into Dependency Track. These are not tracked by Trivy/GitHub/OSV/Snyk/....
For this reason this PR introduces DRUPAL is a new SOURCE of vulnerabilities.
PACKAGIST is not added as a source as it doesn't provide new vulnerabilities and doesn't have commonly known IDs (PKSA-xxxx-yyyy).
This PR does introduce COMPOSER as a new source for Affected Version Attribution.
It mimics as mich as possible the code / behaviour of the Composer CLI. I had to up my Php reading skill to get there ;-)
Addressed Issue
Fixes #4465
Frontent companion: DependencyTrack/frontend#1130
Checklist