artifact refs and manifest fingerprinting

This commit is contained in:
2026-05-07 13:11:29 +02:00
parent 12ab9c88cb
commit 0b90004a6e
8 changed files with 177 additions and 8 deletions

View File

@@ -3,6 +3,7 @@
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen
@@ -24,6 +25,7 @@ def run(context: dict[str, Any]) -> dict[str, Any]:
}
timeout = _timeout_seconds(context)
artifact_refs: list[str] = []
request = Request(
endpoint["url"],
headers={
@@ -35,8 +37,25 @@ def run(context: dict[str, Any]) -> dict[str, Any]:
with urlopen(request, timeout=timeout) as response:
status_code = response.status
content_type = response.headers.get("Content-Type", "")
headers = dict(response.headers.items())
body = response.read(1024 * 1024)
artifact_refs = _write_response_artifacts(
context,
status_code,
content_type,
headers,
body,
)
except HTTPError as exc:
body = exc.read(1024 * 1024)
content_type = exc.headers.get("Content-Type", "")
artifact_refs = _write_response_artifacts(
context,
exc.code,
content_type,
dict(exc.headers.items()),
body,
)
return {
"result": "infrastructure_error",
"observations": [
@@ -46,8 +65,9 @@ def run(context: dict[str, Any]) -> dict[str, Any]:
"endpoint_found": True,
"url": endpoint["url"],
"http_status": exc.code,
"content_type": content_type,
},
"artifact_refs": [],
"artifact_refs": artifact_refs,
}
except URLError as exc:
return {
@@ -60,7 +80,7 @@ def run(context: dict[str, Any]) -> dict[str, Any]:
"url": endpoint["url"],
"error": str(exc.reason),
},
"artifact_refs": [],
"artifact_refs": artifact_refs,
}
except TimeoutError:
return {
@@ -73,7 +93,7 @@ def run(context: dict[str, Any]) -> dict[str, Any]:
"url": endpoint["url"],
"timeout_seconds": timeout,
},
"artifact_refs": [],
"artifact_refs": artifact_refs,
}
facts: dict[str, Any] = {
@@ -93,7 +113,7 @@ def run(context: dict[str, Any]) -> dict[str, Any]:
"CMIS Browser Binding endpoint is reachable but did not return parseable JSON."
],
"facts": facts,
"artifact_refs": [],
"artifact_refs": artifact_refs,
}
facts["json_detected"] = True
@@ -104,7 +124,7 @@ def run(context: dict[str, Any]) -> dict[str, Any]:
"CMIS Browser Binding endpoint is reachable and returned parseable JSON."
],
"facts": facts,
"artifact_refs": [],
"artifact_refs": artifact_refs,
}
@@ -159,3 +179,35 @@ def _repository_facts(value: Any) -> dict[str, Any]:
"repository_shape": "object",
"top_level_keys": sorted(str(key) for key in value.keys())[:20],
}
def _write_response_artifacts(
context: dict[str, Any],
status_code: int,
content_type: str,
headers: dict[str, str],
body: bytes,
) -> list[str]:
run_dir = Path(context["run_dir"])
artifact_dir = run_dir / "artifacts" / "open-cmis-tck" / "preflight"
artifact_dir.mkdir(parents=True, exist_ok=True)
response_ref = "artifacts/open-cmis-tck/preflight/response-body.bin"
metadata_ref = "artifacts/open-cmis-tck/preflight/response-metadata.json"
(run_dir / response_ref).write_bytes(body)
(run_dir / metadata_ref).write_text(
json.dumps(
{
"status_code": status_code,
"content_type": content_type,
"headers": headers,
"byte_count": len(body),
},
indent=2,
sort_keys=True,
)
+ "\n",
encoding="utf-8",
)
return [metadata_ref, response_ref]

View File

@@ -107,6 +107,8 @@ Progress:
- The first CMIS Browser Binding preflight runner checks endpoint reachability
and parseable JSON repository metadata through the guide-board runner bridge.
- The preflight runner preserves raw response metadata and body artifacts for
assessment-package fingerprinting.
- Capability flag normalization remains to be expanded after a live target sample
is captured.