Delete old advisories

This commit is contained in:
Nemo 2023-04-28 14:16:36 +05:30
parent fee22eda9d
commit d29c9a7129
2 changed files with 10 additions and 1 deletions

View File

@ -20,6 +20,7 @@ republishes the advisories in the OSV format, and syncs them against the
## TODO:
- [x] Delete advisories that are deleted upstream (Experimental)
- [x] Automatic Update
- [ ] Automatic Sync (to GSD)
- [ ] Schema: Provide `credits`

View File

@ -159,7 +159,6 @@ def merge_advisories(advisory_file, data):
if canonicaljson.encode_canonical_json(
original[key]
) != canonicaljson.encode_canonical_json(current[key]):
print(f"Found changes in {current['id']} / {key}")
no_important_changes = False
break
@ -195,8 +194,10 @@ def fetch_cve_metadata(PHOTON_VERSIONS):
def __main__(advisory_id = None):
cve_metadata = fetch_cve_metadata(PHOTON_VERSIONS)
advisories = set()
for d in get_osv(cve_metadata):
advisories.add(d['id'])
# If we are only running for a single advisory
# Check and continue if it doesn't match
if advisory_id and d['id'] != advisory_id:
@ -208,6 +209,13 @@ def __main__(advisory_id = None):
with open(fn, "wb") as f:
f.write(canonicaljson.encode_pretty_printed_json(d))
# Remove any advisories that are no longer in the upstream data
for advisory in os.listdir("advisories"):
if advisory.endswith(".json"):
if advisory[:-5] not in advisories:
print(f"[-] Removing {advisory}")
# os.unlink(f"advisories/{advisory}")
if __name__ == "__main__":
if len(sys.argv) >=2: