Skip to content

Commit

Permalink
fix: ensure that package exists in affected property (#1055)
Browse files Browse the repository at this point in the history
This has always been allowed by the spec but now there's at least one
real-world advisory in the Debian database like this which causes it to
error.
  • Loading branch information
G-Rath committed Jun 25, 2024
1 parent 8497af4 commit fdca369
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scripts/generators/GenerateMavenVersions.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static Map<String, List<String>> fetchPackageVersions() throws IOExceptio
osvs.forEach(osv -> osv.getJSONArray("affected").forEach(aff -> {
JSONObject affected = (JSONObject) aff;

if(affected.getJSONObject("package").getString("ecosystem").equals("Maven")) {
if(!affected.has("package") || affected.getJSONObject("package").getString("ecosystem").equals("Maven")) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/generators/generate-cran-versions.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extract_packages_with_versions <- function(osvs) {

for (osv in osvs) {
for (affected in osv$affected) {
if (affected$package$ecosystem != "CRAN") {
if (is.null(affected["package"]) || affected$package$ecosystem != "CRAN") {
next
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/generators/generate-debian-versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def extract_packages_with_versions(osvs):

for osv in osvs:
for affected in osv['affected']:
if not affected['package']['ecosystem'].startswith('Debian'):
if 'package' not in affected or not affected['package']['ecosystem'].startswith('Debian'):
continue

package = affected['package']['name']
Expand Down
2 changes: 1 addition & 1 deletion scripts/generators/generate-packagist-versions.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function fetchPackageVersions(): array

foreach ($osvs as $osv) {
foreach ($osv['affected'] as $affected) {
if ($affected['package']['ecosystem'] !== 'Packagist') {
if (!isset($affected['package']) || $affected['package']['ecosystem'] !== 'Packagist') {
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/generators/generate-pypi-versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def extract_packages_with_versions(osvs):

for osv in osvs:
for affected in osv['affected']:
if affected['package']['ecosystem'] != 'PyPI':
if 'package' not in affected or affected['package']['ecosystem'] != 'PyPI':
continue

package = affected['package']['name']
Expand Down
2 changes: 1 addition & 1 deletion scripts/generators/generate-rubygems-versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def extract_packages_with_versions(osvs)

osvs.each do |osv|
osv["affected"].each do |affected|
next unless affected["package"]["ecosystem"] == "RubyGems"
next unless affected.dig("package", "ecosystem") == "RubyGems"

package = affected["package"]["name"]

Expand Down

0 comments on commit fdca369

Please sign in to comment.