Repository navigation
Expand file tree
/
Copy pathcheck-postgresql-update.py
More file actions
65 lines (51 loc) · 2.58 KB
/
Copy pathcheck-postgresql-update.py
File metadata and controls
65 lines (51 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
"""Create a fail-closed PostgreSQL upstream update report."""
from __future__ import annotations
import argparse
import datetime as dt
import json
import urllib.request
from pathlib import Path
VERSIONS_URL = "https://www.postgresql.org/versions.json"
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--inputs", type=Path, default=Path("artifacts/lock-inputs.json"))
parser.add_argument("--report", type=Path, required=True)
parser.add_argument("--github-output", type=Path)
arguments = parser.parse_args()
inputs = json.loads(arguments.inputs.read_text(encoding="utf-8"))
current = inputs["postgresql_version"]
major = current.split(".", 1)[0]
request = urllib.request.Request(
VERSIONS_URL, headers={"User-Agent": "datopsis/postgresql-ubi update monitor"}
)
with urllib.request.urlopen(request, timeout=30) as response:
versions = json.load(response)
selected = next(item for item in versions if item["major"] == major)
latest = f"{major}.{selected['latestMinor']}"
update_available = latest != current
status = "UPDATE REVIEW REQUIRED" if update_available else "current"
timestamp = dt.datetime.now(dt.timezone.utc).replace(microsecond=0).isoformat()
report = f"""# PostgreSQL and supply-chain update monitor
Generated: `{timestamp}`
| Input | Locked/selected | Authoritative result | Status |
| --- | --- | --- | --- |
| PostgreSQL major {major} | `{current}` | `{latest}` (released {selected['relDate']}, EOL {selected['eolDate']}) | **{status}** |
Authoritative PostgreSQL data: {VERSIONS_URL}
The scheduled artifact-lock workflow separately resolves both native
architectures from current PGDG and UBI metadata and verifies every downloaded
RPM, source RPM, signing-key hash/fingerprint, and base digest. Review its
artifacts and failures; automation must never accept a changed key or lock.
Dependabot and Renovate propose pinned GitHub Action, Python tool, UBI image,
Syft, Grype, Trivy, Cosign, and assurance-tool updates. Scanner databases are
refreshed by scheduled CI and release runs. Every proposal still requires the
review and qualification in `docs/MAINTENANCE.md`.
"""
arguments.report.write_text(report, encoding="utf-8", newline="\n")
if arguments.github_output:
with arguments.github_output.open("a", encoding="utf-8", newline="\n") as output:
output.write(f"update_available={str(update_available).lower()}\n")
output.write(f"current={current}\nlatest={latest}\n")
return 0
if __name__ == "__main__":
raise SystemExit(main())