Skip to content

Commit 87dcbfc

Browse files
committed
Fix SDK template and runtime image findings
1 parent 6300c4d commit 87dcbfc

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

crates/actant-sdk-codegen/templates/client.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
11
# Generated by actant-sdk-codegen. Edit the template, not this file.
2-
import urllib.request, json
2+
import json
3+
import urllib.parse
4+
import urllib.request
5+
6+
_ALLOWED_URL_SCHEMES = {"http", "https"}
7+
8+
9+
def _validate_url_scheme(url):
10+
scheme = urllib.parse.urlparse(url).scheme
11+
if scheme not in _ALLOWED_URL_SCHEMES:
12+
allowed = ", ".join(sorted(_ALLOWED_URL_SCHEMES))
13+
raise ValueError(f"ActantClient only supports these URL schemes: {allowed}")
14+
15+
16+
def _build_http_opener():
17+
opener = urllib.request.OpenerDirector()
18+
opener.add_handler(urllib.request.HTTPHandler())
19+
opener.add_handler(urllib.request.HTTPSHandler())
20+
opener.add_handler(urllib.request.HTTPDefaultErrorHandler())
21+
opener.add_handler(urllib.request.HTTPRedirectHandler())
22+
opener.add_handler(urllib.request.HTTPErrorProcessor())
23+
return opener
24+
25+
26+
_HTTP_OPENER = _build_http_opener()
27+
28+
29+
def _open_http_request(req):
30+
_validate_url_scheme(req.full_url)
31+
return _HTTP_OPENER.open(req)
32+
333

434
class ActantClient:
535
def __init__(self, base="http://127.0.0.1:4555"):
36+
_validate_url_scheme(base)
637
self.base = base
738

839
def command(self, workspace_id, actor_id, command_type, input_, idempotency_key=None):
@@ -19,5 +50,5 @@ def command(self, workspace_id, actor_id, command_type, input_, idempotency_key=
1950
data=json.dumps(body).encode("utf-8"),
2051
headers={"content-type": "application/json"},
2152
)
22-
with urllib.request.urlopen(req) as r:
53+
with _open_http_request(req) as r:
2354
return json.loads(r.read())

deploy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ COPY rustfmt.toml clippy.toml ./
2121
# Build only the server binary; cargo will pull just the crates it needs.
2222
RUN cargo build --release -p actant-server --bin actantdb-server
2323

24-
FROM gcr.io/distroless/cc-debian12 AS runtime
24+
FROM gcr.io/distroless/cc-debian12:latest@sha256:aa0b7af67fa8211751ea6e00baa8373ba56cc1417ffc986ec9619bd0e1556b56 AS runtime
2525
COPY --from=builder /src/target/release/actantdb-server /usr/local/bin/actantdb-server
2626
COPY --from=builder /src/migrations /opt/actantdb/migrations
2727

0 commit comments

Comments
 (0)