Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/apply-exemptions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:

- name: Install dependencies
run: pip install requests

- name: Validate allow.json
run: python exemptions/validate_allowlist.py

- name: Apply exemptions
env:
Expand Down
44 changes: 44 additions & 0 deletions exemptions/validate_allowlist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import json
import re
import sys
from pathlib import Path
Comment thread
ciaracarey marked this conversation as resolved.

ALLOW_FILE = Path(__file__).parent / "allow.json"
ENTRY_PATTERN = re.compile(r"^[a-zA-Z0-9_\-]+:[a-zA-Z0-9_\-\.]+:[a-zA-Z0-9_\-\.]+$")

Comment on lines +6 to +8
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file re-implements allowlist entry validation that already exists in exemptions/update_policy.py (_validate_allowlist_entry). Because the criteria differ (regex here vs just enforcing two ':' separators there), CI can end up rejecting entries that the upload code would accept (or vice versa). Consider sharing one validation function/module or aligning the checks exactly.

Copilot uses AI. Check for mistakes.
def validate():
if not ALLOW_FILE.exists():
print("❌ allow.json not found")
sys.exit(1)

try:
data = json.loads(ALLOW_FILE.read_text())
except json.JSONDecodeError as e:
print(f"❌ Invalid JSON: {e}")
sys.exit(1)

if not isinstance(data, list):
print("❌ allow.json must be a list")
sys.exit(1)

if len(data) == 0:
print("❌ allow.json is empty")
sys.exit(1)

errors = []
for i, entry in enumerate(data):
if not isinstance(entry, str):
errors.append(f" [{i}] not a string: {entry}")
elif not ENTRY_PATTERN.match(entry):
errors.append(f" [{i}] invalid format: '{entry}' (expected format:name:version)")

if errors:
print("❌ Invalid entries:")
for e in errors:
print(e)
sys.exit(1)

print(f"✅ {len(data)} entries valid")

if __name__ == "__main__":
validate()
Loading