Commit fd1b980
Prioritize hashes and download URL for PurlDB mapping (#430)
* Prioritize hashes and download URL for PurlDB mapping
In order to get an accurate mapping for a package in DejaCode to PurlDB entries the patched query prioritizes the hashes. This is needed in cases where the same PURL (without query parameters) can have multiple different download URLs as is the case with Python packages and various binaries for different hardware architectures or interpreter versions. Additionally, lookups for SHA-256 and MD5 are added as SHA-1 may not be populated under all circumstances. Hashes from SBOM imports, generated by tools such as cdxgen, commonly do not use SHA-1 anymore, since it is a mostly deprecated hashing algorithm due to the risk of hash collisions. SHA-512 could not yet be added as PurlDB does not support a lookup for it. The reason for the order of prioritization is that hashes give the most accurate for the content of the package, download URL at least points to the download location which would still allow to differentiate between the different target architectures, and lastly the PURL itself in case no fully accurate matches could be found otherwise. The results are then filtered by checking that PURLs match. Here a modification is made to also strip the query parameters from the PurlDB PURL as they may also contain them and previously caused matches to not be found. For reference see the following issues: #307 #383
Signed-off-by: Robert Guetzkow <[email protected]>
* Update component_catalog/models.py
Remove code duplication and reduce database queries to a single one
Signed-off-by: tdruez <[email protected]>
* Add details about matching order in docstring
Signed-off-by: tdruez <[email protected]>
---------
Signed-off-by: Robert Guetzkow <[email protected]>
Signed-off-by: tdruez <[email protected]>
Co-authored-by: tdruez <[email protected]>1 parent 74e9e5e commit fd1b980
1 file changed
+20
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2506 | 2506 | | |
2507 | 2507 | | |
2508 | 2508 | | |
2509 | | - | |
2510 | | - | |
2511 | | - | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
2512 | 2519 | | |
2513 | 2520 | | |
2514 | 2521 | | |
| |||
2527 | 2534 | | |
2528 | 2535 | | |
2529 | 2536 | | |
2530 | | - | |
2531 | | - | |
2532 | | - | |
2533 | | - | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
2534 | 2541 | | |
2535 | 2542 | | |
2536 | 2543 | | |
| |||
2542 | 2549 | | |
2543 | 2550 | | |
2544 | 2551 | | |
2545 | | - | |
2546 | | - | |
| 2552 | + | |
| 2553 | + | |
2547 | 2554 | | |
2548 | 2555 | | |
| 2556 | + | |
| 2557 | + | |
2549 | 2558 | | |
2550 | 2559 | | |
| 2560 | + | |
| 2561 | + | |
2551 | 2562 | | |
2552 | 2563 | | |
2553 | 2564 | | |
| |||
0 commit comments