Skip to content

Commit

Permalink
Enhance get_advisories to Handle Empty Advisories and Basis Version O…
Browse files Browse the repository at this point in the history
…verrides

This commit updates the get_advisories function in http_requests.py. Changes include:
- Filtering out releases with empty advisories.
- Checking for 'advisories!' overrides not just in the current version, but also in each basis version while processing. This ensures that any empty or specific advisories from the basis versions are appropriately applied to the current version.
  • Loading branch information
MartinPl0 committed Jan 24, 2024
1 parent f197b25 commit d1c0ca7
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions lib/http_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def process_version_advisories(version, yml_data, seen):
def get_advisories(branch_name):
"""
Gets the list of advisories from the releases.yml file of an OpenShift release.
Filters out releases with 'custom' assembly type.
Filters out releases with 'custom' assembly type or empty advisories.
:param branch_name: OpenShift branch name in ocp-build-data. eg: openshift-4.10
:returns: List of lists containing the advisories with the z-stream version. Eg:
[['4.11.6', {'extras': 102175, 'image': 102174, 'metadata': 102177, 'rpm': 102173}], ... ]
Expand Down Expand Up @@ -157,21 +157,33 @@ def get_advisories(branch_name):
if not current_advisories:
current_advisories = {}

override_applied = False
while depth < MAX_DEPTH:
depth += 1
basis_version = yml_data[current_version].get('assembly', {}).get('basis', {}).get('assembly')
if not basis_version or basis_version in seen:
break

# Check for 'advisories!' override in basis version
basis_override_advisories = yml_data[basis_version].get('assembly', {}).get('group', {}).get('advisories!', None)
if basis_override_advisories is not None:
if not basis_override_advisories: # If basis version's override_advisories is empty
current_advisories.clear()
break # No need to process further as the advisories are cleared
current_advisories.update(basis_override_advisories)

basis_advisories, _ = process_version_advisories(basis_version, yml_data, seen)
if basis_advisories:
current_advisories.update(basis_advisories)
current_version = basis_version

# Apply override advisories specified with 'advisories!'
override_advisories = yml_data[version].get('assembly', {}).get('group', {}).get('advisories!', {})
if override_advisories:
current_advisories.update(override_advisories)
# Check for 'advisories!' override in the current version if not applied from basis
if not override_applied:
current_override_advisories = assembly_data.get('group', {}).get('advisories!', None)
if current_override_advisories is not None:
if not current_override_advisories:
continue
current_advisories.update(current_override_advisories)

if current_advisories:
advisory_data.append([version, current_advisories, jira_link])
Expand Down

0 comments on commit d1c0ca7

Please sign in to comment.