fix(valid-detection-benchmark): normalize mixed-case .git suffixes in reservation identity

A reference such as OWNER/REPO.GIT escaped the reserved-identity check at both reservation sites because the suffix was stripped case-sensitively. One shared strip now handles the suffix case-insensitively; identities without a mixed-case suffix are byte-identical.
This commit is contained in:
Marius Ciepluch
2026-11-23 11:40:09 +01:00
parent f2093a5380
commit 7e6da2efae
4 changed files with 118 additions and 2 deletions
+2 -1
View File
@@ -23,6 +23,7 @@ from benchmarks.valid.reservation import (
census_bytes,
)
from benchmarks.valid.reservation_guard_sources import PINNED_LEGACY_RESERVATION_SOURCE_DIGESTS
from benchmarks.valid.reservation_identity import strip_git_suffix
from openultrasast.core.canonical import JsonValue, content_digest
GUARD_REPORT_SCHEMA = "openultrasast.valid-detection-benchmark.reservation-guard.v1"
@@ -175,7 +176,7 @@ def _historical_paths(root: Path, withdrawal: HistoricalWithdrawalV1 | None) ->
def _repository_matches(content: bytes) -> tuple[str, ...]:
values = {match.group(1).decode("ascii").removesuffix(".git") for match in _REPOSITORY.finditer(content)}
values = {strip_git_suffix(match.group(1).decode("ascii")) for match in _REPOSITORY.finditer(content)}
return tuple(sorted(f"https://github.com/{value}" for value in values))
+9 -1
View File
@@ -11,6 +11,7 @@ from openultrasast.core.canonical import JsonValue, content_digest
NETWORK_SCHEMA = "openultrasast.valid-detection-benchmark.repository-network.v1"
_DIGEST = re.compile(r"[0-9a-f]{64}")
_GIT_SUFFIX = ".git"
class ReservationError(ValueError):
@@ -52,6 +53,13 @@ def _require_digest(value: object, field: str) -> str:
return value
def strip_git_suffix(repository: str) -> str:
"""Drop a trailing provider clone suffix in any letter case, nothing else."""
if repository.lower().endswith(_GIT_SUFFIX):
return repository[: len(repository) - len(_GIT_SUFFIX)]
return repository
def _repository_locator(value: object) -> str:
text = _require_text(value, "repository locator")
try:
@@ -67,7 +75,7 @@ def _repository_locator(value: object) -> str:
if len(parts) != 2:
raise ReservationError("repository locator must identify owner and repository")
owner, repository = parts
repository = repository.removesuffix(".git")
repository = strip_git_suffix(repository)
if not owner or not repository:
raise ReservationError("repository locator must identify owner and repository")
return f"https://{parsed.hostname.lower()}/{owner.lower()}/{repository.lower()}"