Initial Red Hat CSAF mirror
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Validate the local Red Hat CSAF mirror."""
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def validate(root):
|
||||
root = Path(root)
|
||||
state = root / 'state/sync.json'
|
||||
if not state.exists():
|
||||
raise RuntimeError('Sync state missing')
|
||||
obj = json.loads(state.read_text())
|
||||
files = list((root / 'data/csaf').glob('*/*.json'))
|
||||
if not files:
|
||||
raise RuntimeError('No CSAF documents present')
|
||||
for path in files:
|
||||
data = json.loads(path.read_bytes())
|
||||
if not isinstance(data, dict) or not isinstance(data.get('document'), dict):
|
||||
raise RuntimeError(f'Invalid CSAF document: {path}')
|
||||
print(f'Validated {len(files)} Red Hat CSAF documents; source index entries: {obj["index_count"]}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument('--root', default='.')
|
||||
validate(ap.parse_args().root)
|
||||
Reference in New Issue
Block a user