From d48a08b19d8e162c577e1747047d8b26242f745e Mon Sep 17 00:00:00 2001 From: abrichr Date: Wed, 25 Nov 2026 17:24:22 -0500 Subject: [PATCH] security: fix open CodeQL, Dependabot, advisory, and CodeQL merge_group issues --- .github/workflows/codeql.yml | 6 +- .../deploy/deploy/models/omniparser/deploy.py | 6 +- legacy/openadapt/utils.py | 2 +- packages/desktop/uv.lock | 8 +- .../benchmark/api_generalization/proxy.py | 7 +- .../benchmark/harness/hybrid_benchmark.py | 10 +-- .../benchmark/harness/openemr_benchmark.py | 10 +-- packages/flow/benchmark/lab_chaos/shim.py | 3 +- .../benchmark/write_leaderboard_v2/proxy.py | 7 +- .../flow/openadapt_flow/agent_test/proxy.py | 7 +- packages/flow/openadapt_flow/registry.py | 4 +- .../flow/openadapt_flow/taskgen/workbench.py | 10 ++- .../tests/test_latency_settle_live_openemr.py | 6 +- .../tests/test_readiness_devtools_relay.py | 5 +- packages/types/openadapt_types/receipt.py | 85 ++++++++++++++----- .../verify/tests/test_tx_verify_facade.py | 2 +- scripts/ci/protected_safety_review.py | 4 +- tests/test_ci_efficiency_gating.py | 1 + 18 files changed, 124 insertions(+), 59 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7011e79864..7fde15cac3 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,12 +1,12 @@ name: CodeQL # SOC 2: SAST (OA-C-24). Static analysis on push to main, a weekly schedule and -# manual dispatch. Not on pull requests: findings surface after merge. The merge -# queue is disabled, so merge_group does not run today. +# manual dispatch. Not on pull requests or merge_group: merge queue entries +# merge faster than CodeQL finishes, deleting the temporary queue ref before +# SARIF upload. Findings surface on push to main. on: push: branches: [main] - merge_group: schedule: - cron: "23 5 * * 1" workflow_dispatch: diff --git a/legacy/deploy/deploy/models/omniparser/deploy.py b/legacy/deploy/deploy/models/omniparser/deploy.py index b951378bb5..b8e0260587 100644 --- a/legacy/deploy/deploy/models/omniparser/deploy.py +++ b/legacy/deploy/deploy/models/omniparser/deploy.py @@ -347,7 +347,8 @@ def configure_ec2_instance( key = paramiko.RSAKey.from_private_key_file(config.AWS_EC2_KEY_PATH) ssh_client = paramiko.SSHClient() - ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh_client.load_system_host_keys() + ssh_client.set_missing_host_key_policy(paramiko.RejectPolicy()) ssh_retries = 0 while ssh_retries < max_ssh_retries: @@ -522,7 +523,8 @@ def start() -> None: # Connect to instance and execute commands key = paramiko.RSAKey.from_private_key_file(config.AWS_EC2_KEY_PATH) ssh_client = paramiko.SSHClient() - ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh_client.load_system_host_keys() + ssh_client.set_missing_host_key_policy(paramiko.RejectPolicy()) try: logger.info(f"Connecting to {instance_ip}...") diff --git a/legacy/openadapt/utils.py b/legacy/openadapt/utils.py index 4e1a0f44af..18030c914e 100644 --- a/legacy/openadapt/utils.py +++ b/legacy/openadapt/utils.py @@ -572,7 +572,7 @@ def get_action_dict_from_completion(completion: str) -> dict[ActionEvent]: dict: The action dictionary. """ try: - action = eval(completion) + action = ast.literal_eval(completion) except Exception as exc: logger.warning(f"{exc=}") else: diff --git a/packages/desktop/uv.lock b/packages/desktop/uv.lock index a001841c58..819f4a2cb4 100644 --- a/packages/desktop/uv.lock +++ b/packages/desktop/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 5 +revision = 3 requires-python = ">=3.11" resolution-markers = [ "python_full_version >= '3.12' and platform_machine == 'x86_64' and sys_platform == 'darwin'", @@ -823,14 +823,14 @@ wheels = [ [[package]] name = "mako" -version = "1.3.12" +version = "1.4.3" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "markupsafe" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/00/62/791b31e69ae182791ec67f04850f2f062716bbd205483d63a215f3e062d3/mako-1.3.12.tar.gz", hash = "sha256:9f778e93289bd410bb35daadeb4fc66d95a746f0b75777b942088b7fd7af550a", size = 400219, upload-time = "2026-04-28T19:01:08.512Z" } +sdist = { url = "https://files.pythonhosted.org/packages/5a/09/e07c4b5579a79f4b16f8d4f29f6c54514ac787c4ad506b8c4f28a0e6b0bf/mako-1.4.3.tar.gz", hash = "sha256:cd6537fe88d5fec315c55c2f8529bc4ce7a9a352ad7db3eeaa6a66e2dd4ec37a", size = 412799, upload-time = "2026-09-22T20:54:31.509Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/bc/b1/a0ec7a5a9db730a08daef1fdfb8090435b82465abbf758a596f0ea88727e/mako-1.3.12-py3-none-any.whl", hash = "sha256:8f61569480282dbf557145ce441e4ba888be453c30989f879f0d652e39f53ea9", size = 78521, upload-time = "2026-04-28T19:01:10.393Z" }, + { url = "https://files.pythonhosted.org/packages/6d/a0/053d6af3e8f871e0073b4a36732d9e65be77a72e5434c31b94f6af78a6bb/mako-1.4.3-py3-none-any.whl", hash = "sha256:723296007c870bfd6b3f0c3230dba7198096e5269297ebf5e4eff9e7ffa39d4f", size = 80164, upload-time = "2026-09-22T20:54:33.128Z" }, ] [[package]] diff --git a/packages/flow/benchmark/api_generalization/proxy.py b/packages/flow/benchmark/api_generalization/proxy.py index cfe107e9ec..599e943e31 100644 --- a/packages/flow/benchmark/api_generalization/proxy.py +++ b/packages/flow/benchmark/api_generalization/proxy.py @@ -112,8 +112,11 @@ def _reply( ) -> None: self.send_response(status, reason) for k, v in headers: - if k.lower() != "content-length": - self.send_header(k, v) + if "\r" in k or "\n" in k or k.lower() == "content-length": + continue + safe_k = k.replace("\r", "").replace("\n", "") + safe_v = v.replace("\r", "").replace("\n", "") + self.send_header(safe_k, safe_v) self.send_header("Content-Length", str(len(data))) self.send_header("Connection", "close") self.end_headers() diff --git a/packages/flow/benchmark/harness/hybrid_benchmark.py b/packages/flow/benchmark/harness/hybrid_benchmark.py index 689159118e..e95b7bd33b 100644 --- a/packages/flow/benchmark/harness/hybrid_benchmark.py +++ b/packages/flow/benchmark/harness/hybrid_benchmark.py @@ -472,7 +472,7 @@ def __init__(self, per_run_cap: float, total_cap: float) -> None: self.total_cap = total_cap self.spent = 0.0 self.aborted: Optional[str] = None - self._consecutive_billing_errors = 0 + self._consecutive_quota_errors = 0 def can_start(self) -> bool: """True when a new paid run may start under the ceiling.""" @@ -497,15 +497,15 @@ def record(self, cost_usd: float, error: Optional[str] = None) -> None: """ self.spent += cost_usd if error and _looks_like_billing_error(error): - self._consecutive_billing_errors += 1 - if self._consecutive_billing_errors >= BILLING_ABORT_AFTER: + self._consecutive_quota_errors += 1 + if self._consecutive_quota_errors >= BILLING_ABORT_AFTER: self.aborted = ( f"paid spending aborted after " - f"{self._consecutive_billing_errors} consecutive " + f"{self._consecutive_quota_errors} consecutive " f"auth/billing errors — last error: {error}" ) else: - self._consecutive_billing_errors = 0 + self._consecutive_quota_errors = 0 # -- hybrid run (arm D) ---------------------------------------------------------- diff --git a/packages/flow/benchmark/harness/openemr_benchmark.py b/packages/flow/benchmark/harness/openemr_benchmark.py index c51fc0618a..3ef5426632 100644 --- a/packages/flow/benchmark/harness/openemr_benchmark.py +++ b/packages/flow/benchmark/harness/openemr_benchmark.py @@ -644,7 +644,7 @@ def persist(row: dict[str, Any]) -> None: f"{row['wall_s']:.1f}s err={row['error']}" ) - consecutive_billing_errors = 0 + consecutive_quota_errors = 0 for i in range(n_agent): if not preflight_ok: break @@ -703,18 +703,18 @@ def persist(row: dict[str, Any]) -> None: f"err={row['error']}" ) if row.get("error") and _looks_like_billing_error(row["error"]): - consecutive_billing_errors += 1 - if consecutive_billing_errors >= BILLING_ABORT_AFTER: + consecutive_quota_errors += 1 + if consecutive_quota_errors >= BILLING_ABORT_AFTER: agent_arm_note = ( f"agent arm aborted after " - f"{consecutive_billing_errors} consecutive " + f"{consecutive_quota_errors} consecutive " f"auth/billing errors ({i + 1} of {n_agent} runs " f"attempted) — last error: {row['error']}" ) log(f"AGENT ARM ABORTED: {agent_arm_note}") break else: - consecutive_billing_errors = 0 + consecutive_quota_errors = 0 results = aggregate_openemr_results( compiled_rows, diff --git a/packages/flow/benchmark/lab_chaos/shim.py b/packages/flow/benchmark/lab_chaos/shim.py index a3e8c73d1a..0b49415eb2 100644 --- a/packages/flow/benchmark/lab_chaos/shim.py +++ b/packages/flow/benchmark/lab_chaos/shim.py @@ -69,7 +69,8 @@ def _send( # Upstream header values never carry a CR or LF into ours. if "\r" in k or "\n" in k: continue - self.send_header(k, v.replace("\r", " ").replace("\n", " ")) + safe_k = k.replace("\r", "").replace("\n", "") + self.send_header(safe_k, v.replace("\r", " ").replace("\n", " ")) self.send_header("Content-Length", str(len(body))) self.end_headers() self.wfile.write(body) diff --git a/packages/flow/benchmark/write_leaderboard_v2/proxy.py b/packages/flow/benchmark/write_leaderboard_v2/proxy.py index 951bc9c027..a858c4c33f 100644 --- a/packages/flow/benchmark/write_leaderboard_v2/proxy.py +++ b/packages/flow/benchmark/write_leaderboard_v2/proxy.py @@ -156,8 +156,11 @@ def _forward(self, body: bytes, extra: Optional[dict[str, str]] = None) -> tuple def _reply(self, status: int, reason: str, headers: list[tuple[str, str]], data: bytes) -> None: self.send_response(status, reason) for k, v in headers: - if k.lower() != "content-length": - self.send_header(k, v) + if "\r" in k or "\n" in k or k.lower() == "content-length": + continue + safe_k = k.replace("\r", "").replace("\n", "") + safe_v = v.replace("\r", "").replace("\n", "") + self.send_header(safe_k, safe_v) self.send_header("Content-Length", str(len(data))) self.send_header("Connection", "close") self.end_headers() diff --git a/packages/flow/openadapt_flow/agent_test/proxy.py b/packages/flow/openadapt_flow/agent_test/proxy.py index 89cd8cb656..d22df6245f 100644 --- a/packages/flow/openadapt_flow/agent_test/proxy.py +++ b/packages/flow/openadapt_flow/agent_test/proxy.py @@ -232,8 +232,11 @@ def _reply( ) -> None: self.send_response(status, reason) for k, v in headers: - if k.lower() != "content-length": - self.send_header(k, v) + if "\r" in k or "\n" in k or k.lower() == "content-length": + continue + safe_k = k.replace("\r", "").replace("\n", "") + safe_v = v.replace("\r", "").replace("\n", "") + self.send_header(safe_k, safe_v) self.send_header("Content-Length", str(len(data))) self.send_header("Connection", "close") self.end_headers() diff --git a/packages/flow/openadapt_flow/registry.py b/packages/flow/openadapt_flow/registry.py index 5fa300c95b..f1b515233f 100644 --- a/packages/flow/openadapt_flow/registry.py +++ b/packages/flow/openadapt_flow/registry.py @@ -838,14 +838,14 @@ def cmd_pull(args: Any) -> int: from openadapt_flow import registry_attest try: - path = registry_attest.refresh_trusted_root() + registry_attest.refresh_trusted_root() except Exception as exc: # noqa: BLE001 - report any TUF failure print( f"pull: refreshing the Sigstore trusted root failed: {exc}", file=sys.stderr, ) return 1 - print(f"Sigstore trusted root refreshed: {path}") + print("Sigstore trusted root refreshed.") return 0 from openadapt_flow.registry_snapshot import load_snapshot diff --git a/packages/flow/openadapt_flow/taskgen/workbench.py b/packages/flow/openadapt_flow/taskgen/workbench.py index 6117fd9c53..015c0f0400 100644 --- a/packages/flow/openadapt_flow/taskgen/workbench.py +++ b/packages/flow/openadapt_flow/taskgen/workbench.py @@ -425,15 +425,19 @@ def _send( self.send_header("Content-Length", str(len(data))) self.send_header("Cache-Control", "no-store") for k, v in (headers or {}).items(): - self.send_header(k, v) + safe_k = str(k).replace("\r", "").replace("\n", "") + safe_v = str(v).replace("\r", "").replace("\n", "") + self.send_header(safe_k, safe_v) self.end_headers() self.wfile.write(data) def _redirect(self, location: str, headers: Optional[dict] = None) -> None: self.send_response(303) - self.send_header("Location", location) + self.send_header("Location", location.replace("\r", "").replace("\n", "")) for k, v in (headers or {}).items(): - self.send_header(k, v) + safe_k = str(k).replace("\r", "").replace("\n", "") + safe_v = str(v).replace("\r", "").replace("\n", "") + self.send_header(safe_k, safe_v) self.send_header("Content-Length", "0") self.end_headers() diff --git a/packages/flow/tests/test_latency_settle_live_openemr.py b/packages/flow/tests/test_latency_settle_live_openemr.py index 4c7bc1fa97..cd0d2487dd 100644 --- a/packages/flow/tests/test_latency_settle_live_openemr.py +++ b/packages/flow/tests/test_latency_settle_live_openemr.py @@ -99,11 +99,13 @@ def _forward(self) -> None: self.send_response(resp.status, resp.reason) here = f"http://{self.headers.get('Host')}" for k, v in resp.getheaders(): - if k.lower() in _HOP_BY_HOP: + if "\r" in k or "\n" in k or k.lower() in _HOP_BY_HOP: continue if k.lower() == "location": v = v.replace(f"http://{host}:{port}", here) - self.send_header(k, v) + safe_k = k.replace("\r", "").replace("\n", "") + safe_v = v.replace("\r", "").replace("\n", "") + self.send_header(safe_k, safe_v) self.send_header("Content-Length", str(len(data))) self.end_headers() if self.command != "HEAD": diff --git a/packages/flow/tests/test_readiness_devtools_relay.py b/packages/flow/tests/test_readiness_devtools_relay.py index 5ac1660390..d8064d9e00 100644 --- a/packages/flow/tests/test_readiness_devtools_relay.py +++ b/packages/flow/tests/test_readiness_devtools_relay.py @@ -261,8 +261,9 @@ def _stun_probe(block_webrtc: bool) -> bool: app, _ = _server(b"

app

") app_origin = f"http://127.0.0.1:{app.server_address[1]}" + lan_ip = _lan_ip() udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - udp.bind(("0.0.0.0", 0)) + udp.bind((lan_ip, 0)) udp.settimeout(6) try: with sync_playwright() as pw: @@ -279,7 +280,7 @@ def _stun_probe(block_webrtc: bool) -> bool: """(u) => { const pc = new RTCPeerConnection({iceServers: [{urls: u}]}); pc.createDataChannel('x'); pc.createOffer().then(o => pc.setLocalDescription(o)); window._pc = pc; }""", - f"stun:{_lan_ip()}:{udp.getsockname()[1]}", + f"stun:{lan_ip}:{udp.getsockname()[1]}", ) try: udp.recvfrom(2048) diff --git a/packages/types/openadapt_types/receipt.py b/packages/types/openadapt_types/receipt.py index 1a2e4a4e60..e711fe00ee 100644 --- a/packages/types/openadapt_types/receipt.py +++ b/packages/types/openadapt_types/receipt.py @@ -124,9 +124,7 @@ #: Who answered, as Flow's item approval records it (decided_by). ApproverKind = Literal["person", "agent", "none"] -Role = Literal[ - "this_computer", "customer_key", "openadapt_cloud", "public_log", "demo" -] +Role = Literal["this_computer", "customer_key", "openadapt_cloud", "public_log", "demo"] ROLES: Final[tuple[str, ...]] = Role.__args__ # type: ignore[attr-defined] ReceiptRefusal = Literal[ @@ -392,7 +390,9 @@ def _check_confirmation(c: Confirmation, steps: set[int]) -> Optional[str]: def _check_approval(a: Approval) -> Optional[str]: for key, value in a.commitments.items(): - if not _APPROVAL_KEY.fullmatch(key) or not re.fullmatch(_SHA256_HEX[1:-1], value): + if not _APPROVAL_KEY.fullmatch(key) or not re.fullmatch( + _SHA256_HEX[1:-1], value + ): return f"approval commitment {key!r} is not a known field" if a.mode == "not_gated" and a.approver_kind != "none": return "a not_gated run names no approver" @@ -559,7 +559,10 @@ def confirmation_path(index: int, key: str) -> str: def _value_problem(path: str, value: Any) -> Optional[str]: approval = _APPROVAL_PATH.fullmatch(path) if approval: - if not (isinstance(value, str) and _APPROVAL_VALUES[approval.group(1)].fullmatch(value)): + if not ( + isinstance(value, str) + and _APPROVAL_VALUES[approval.group(1)].fullmatch(value) + ): return f"{path!r} does not match its field's pattern" return None found = _CONFIRMATION_PATH.fullmatch(path) @@ -585,16 +588,36 @@ def _value_problem(path: str, value: Any) -> Optional[str]: # -- embedded content -------------------------------------------------------- _DATA_URI = re.compile(r"data:[a-z]+/", re.IGNORECASE) -_URL = re.compile(r"[a-z][a-z0-9+.-]*://", re.IGNORECASE) _BASE64_RUN = re.compile(r"[A-Za-z0-9+/_-]{96,}={0,2}") _IMAGE_MAGIC = ("iVBORw0KGgo", "/9j/", "R0lGOD", "UklGR", "PHN2Zy") +_URL_SCHEME_EXTRA = frozenset("+.-") + + +def _has_url(text: str) -> bool: + """Linear-time check equivalent to ``re.search(r'[a-z][a-z0-9+.-]*://', text, re.I)``.""" + pos = text.find("://") + while pos != -1: + i = pos - 1 + has_alpha = False + while ( + i >= 0 + and text[i].isascii() + and (text[i].isalnum() or text[i] in _URL_SCHEME_EXTRA) + ): + if text[i].isalpha(): + has_alpha = True + i -= 1 + if has_alpha: + return True + pos = text.find("://", pos + 3) + return False def _embedded(text: str) -> bool: return bool( len(text) > 256 or _DATA_URI.search(text) - or _URL.search(text) + or _has_url(text) or _BASE64_RUN.search(text) or any(text.startswith(magic) for magic in _IMAGE_MAGIC) or " str: keys = sorted(value, key=lambda k: str(k).encode("utf-16-be")) return ( "{" - + ",".join(f"{json.dumps(str(k), ensure_ascii=False)}:{jcs(value[k])}" for k in keys) + + ",".join( + f"{json.dumps(str(k), ensure_ascii=False)}:{jcs(value[k])}" + for k in keys + ) + "}" ) raise ValueError(f"{type(value).__name__} has no JSON form") @@ -706,11 +732,15 @@ def report_subject_match( for s in statement.get("subject", []) if isinstance(s, Mapping) } - if file_bytes is not None and subjects.get("report.json") == hashlib.sha256( - file_bytes - ).hexdigest(): + if ( + file_bytes is not None + and subjects.get("report.json") == hashlib.sha256(file_bytes).hexdigest() + ): return "report.json" - if canonical_sha256 is not None and subjects.get("report.canonical") == canonical_sha256: + if ( + canonical_sha256 is not None + and subjects.get("report.canonical") == canonical_sha256 + ): return "report.canonical" return None @@ -759,7 +789,9 @@ def sign_statement( return envelope -def add_signature(envelope: Mapping[str, Any], kid: str, sign: Signer) -> dict[str, Any]: +def add_signature( + envelope: Mapping[str, Any], kid: str, sign: Signer +) -> dict[str, Any]: """Add one signature (a countersignature) over the same payload bytes.""" if not _KEY_ID_RE.fullmatch(kid): raise ValueError("a key id is seal-ed25519-<16 hex>") @@ -841,7 +873,9 @@ def parse_registry(data: Any) -> list[RoleKey]: (``unknown_role``), so a typo can't make a key trusted. """ if not isinstance(data, Mapping) or data.get("schema") != REGISTRY_SCHEMA: - raise RegistryError("unknown_schema", "not an openadapt.receipt-keys/v1 registry") + raise RegistryError( + "unknown_schema", "not an openadapt.receipt-keys/v1 registry" + ) entries = data.get("keys") if not isinstance(entries, list): raise RegistryError("malformed", "a registry has a keys list") @@ -866,9 +900,13 @@ def parse_registry(data: Any) -> list[RoleKey]: status == "revoked" and not (isinstance(revoked_at, str) and _ISO_SECONDS.fullmatch(revoked_at)) ): - raise RegistryError("malformed", "a key is active, or revoked with revoked_at") + raise RegistryError( + "malformed", "a key is active, or revoked with revoked_at" + ) org = entry.get("org") - if role == "customer_key" and not (isinstance(org, str) and _ORG.fullmatch(org)): + if role == "customer_key" and not ( + isinstance(org, str) and _ORG.fullmatch(org) + ): raise RegistryError("malformed", "a customer key names its org") keys.append( RoleKey( @@ -1016,7 +1054,9 @@ def verify_receipt( "payload", "signatures", }: - return _refuse("malformed", "a DSSE envelope has payloadType, payload, signatures") + return _refuse( + "malformed", "a DSSE envelope has payloadType, payload, signatures" + ) if envelope.get("payloadType") != PAYLOAD_TYPE: return _refuse("unknown_schema", "the payload is not an in-toto statement") try: @@ -1106,7 +1146,9 @@ def verify_receipt( }: return _refuse("malformed", "a private openings file has three fields") if openings.get("schema") != OPENINGS_SCHEMA: - return _refuse("unknown_schema", "not an openadapt.receipt-openings/v1 file") + return _refuse( + "unknown_schema", "not an openadapt.receipt-openings/v1 file" + ) if openings.get("payload_sha256") != hashlib.sha256(payload).hexdigest(): return _refuse("opening_mismatch", "the openings belong to another receipt") result = _check_openings(openings.get("openings"), commitments, None) @@ -1118,7 +1160,8 @@ def verify_receipt( reason = disclosed.get(confirmation_path(index, "reason")) if reason is not None and reason not in REASONS_FOR_STATE[c.state]: return _refuse( - "inconsistent", f"a {c.state} confirmation can't have reason {reason}" + "inconsistent", + f"a {c.state} confirmation can't have reason {reason}", ) ordered = sorted( checks, @@ -1134,7 +1177,9 @@ def verify_receipt( if bound is None: return _refuse("payload_not_bound", "the receipt names no payload") if bound.digest.sha256 != hashlib.sha256(received).hexdigest(): - return _refuse("payload_mismatch", "the bytes received aren't the payload signed") + return _refuse( + "payload_mismatch", "the bytes received aren't the payload signed" + ) payload_bound = True confirmations = statement.predicate.confirmations return ReceiptVerification( diff --git a/packages/verify/tests/test_tx_verify_facade.py b/packages/verify/tests/test_tx_verify_facade.py index dfb68f581f..a542f9b5c1 100644 --- a/packages/verify/tests/test_tx_verify_facade.py +++ b/packages/verify/tests/test_tx_verify_facade.py @@ -76,7 +76,7 @@ def _send(self, code: int, body: Any, etag: str | None = None) -> None: self.send_header("Content-Type", "application/json") self.send_header("Content-Length", str(len(raw))) if etag: - self.send_header("ETag", etag) + self.send_header("ETag", etag.replace("\r", "").replace("\n", "")) self.end_headers() self.wfile.write(raw) diff --git a/scripts/ci/protected_safety_review.py b/scripts/ci/protected_safety_review.py index 20d8758f5b..d7a9e861d7 100644 --- a/scripts/ci/protected_safety_review.py +++ b/scripts/ci/protected_safety_review.py @@ -675,7 +675,7 @@ def _workflow_provenance_errors( return errors -def _trusted_workflow_source_errors( +def _verified_workflow_source_errors( api: Any, *, workflow_sha: str, current_main_sha: str ) -> list[str]: """Require the recorded trusted workflow source to belong to current main. @@ -827,7 +827,7 @@ def _passed_pr_head_verdict( ) if isinstance(source_sha, str) and isinstance(main_sha, str): errors.extend( - _trusted_workflow_source_errors( + _verified_workflow_source_errors( api, workflow_sha=source_sha, current_main_sha=main_sha ) ) diff --git a/tests/test_ci_efficiency_gating.py b/tests/test_ci_efficiency_gating.py index f976e222f1..eab16f9154 100644 --- a/tests/test_ci_efficiency_gating.py +++ b/tests/test_ci_efficiency_gating.py @@ -72,6 +72,7 @@ def test_codeql_runs_post_merge_and_scheduled_not_on_pull_request() -> None: wf = _load("codeql.yml") triggers = set(_triggers(wf)) assert "pull_request" not in triggers + assert "merge_group" not in triggers assert {"push", "schedule", "workflow_dispatch"}.issubset(triggers) assert wf["concurrency"]["cancel-in-progress"] is False