Skip to content

Instantly share code, notes, and snippets.

@vfreex
Created October 13, 2022 10:43
Show Gist options
  • Save vfreex/101a20232573b781c3fa7d8ec6040b0f to your computer and use it in GitHub Desktop.
Save vfreex/101a20232573b781c3fa7d8ec6040b0f to your computer and use it in GitHub Desktop.
# install dependencies with `pip install requests requests-gssapi`
import requests
from requests_gssapi import HTTPSPNEGOAuth
def main():
non_paginated_url = "https://errata.devel.redhat.com/api/v1/cve_package_exclusion?filter[errata_id]=103179&page[size]=600&page[number]=1"
resp = requests.get(non_paginated_url, auth=HTTPSPNEGOAuth(), verify=False)
resp.raise_for_status()
non_paginated_result = resp.json()
non_paginated_ids = [item["id"] for item in non_paginated_result["data"]]
print(f"[non_paginated] page: {non_paginated_result['page']}")
paginated_url = "https://errata.devel.redhat.com/api/v1/cve_package_exclusion?filter[errata_id]=103179&page[size]=300"
page_num = 1
paginated_ids = []
while True:
resp = requests.get(paginated_url, params={"page[number]": page_num}, auth=HTTPSPNEGOAuth(), verify=False)
resp.raise_for_status()
paginated_result = resp.json()
print(f"[paginated] page: {paginated_result['page']}")
if not paginated_result["data"]:
break
paginated_ids.extend([item["id"] for item in paginated_result["data"]])
page_num += 1
if sorted(paginated_ids) == sorted(non_paginated_ids):
print("No bug: paginated_ids == non_paginated_ids.")
return
non_paginated_ids = set(non_paginated_ids)
paginated_ids = set(paginated_ids)
missing = paginated_ids - non_paginated_ids
extra = non_paginated_ids - paginated_ids
print("Bug found:")
print(f"paginated_ids - non_paginated_ids = {missing}")
print(f"non_paginated_ids - paginated_ids = {extra}")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment