Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
6 changes: 4 additions & 2 deletions legacy/deploy/deploy/models/omniparser/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}...")
Expand Down
2 changes: 1 addition & 1 deletion legacy/openadapt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions packages/desktop/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions packages/flow/benchmark/api_generalization/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions packages/flow/benchmark/harness/hybrid_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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) ----------------------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions packages/flow/benchmark/harness/openemr_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion packages/flow/benchmark/lab_chaos/shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions packages/flow/benchmark/write_leaderboard_v2/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 5 additions & 2 deletions packages/flow/openadapt_flow/agent_test/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions packages/flow/openadapt_flow/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 7 additions & 3 deletions packages/flow/openadapt_flow/taskgen/workbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 4 additions & 2 deletions packages/flow/tests/test_latency_settle_live_openemr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
5 changes: 3 additions & 2 deletions packages/flow/tests/test_readiness_devtools_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ def _stun_probe(block_webrtc: bool) -> bool:

app, _ = _server(b"<h1>app</h1>")
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:
Expand All @@ -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)
Expand Down
Loading
Loading