Repository navigation
[after #2296] feat(flow): harden customer-run connector authority and local data boundary #2300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
f922378
Flow connector: allow-listed egress, signed requests, kill switch, co…
abrichr ea0130a
Flow connector: local admission key dir, default secrets ref, daemon-…
abrichr 5b0b1b0
test(flow): complete restart-safe synthetic connector admission harness
abrichr a2daf91
Merge remote-tracking branch 'origin/main' into feat/byoc-runner-pilot
abrichr afb07ec
docs(flow): describe the customer-run connector controls
abrichr 807be87
fix(flow): preserve governed approval policy in connector runs
abrichr 4be1804
fix(flow): bind BYOC live execution to exact managed session
abrichr 5e6400c
Merge commit '6d903848f2d14b96f2f38025351b8a9a5236d7ab' into feat/byo…
abrichr eab484b
fix(flow): verify exact BYOC managed authority before handoff
abrichr 6fe00f5
Merge commit 'f985ec1a98197e46f6ddc2bddbe2c3259d35334f' into feat/byo…
abrichr 2a7e7ee
Merge Flow 3.4.0 (#2296 head fbe911c4) into the BYOC connector authority
abrichr 2a853d9
test(flow): run main's connector service and privacy controls under c…
abrichr 574aa7c
test(flow): expect the closed governance_refused ack code in the Wind…
abrichr f30e40e
Merge #2296 head 0481cdf6 into the BYOC connector authority
abrichr 80df335
chore: pin the connector pilot's synthetic canary as a reviewed gitle…
abrichr 63eedfe
test(flow): run the service stop control through the production handl…
abrichr 9f2ad81
fix(flow): let digest-named keys of the closed outcome envelope leave…
abrichr f4e979e
Merge pull request #2380 from OpenAdaptAI/fix/byoc-outcome-envelope-keys
abrichr 84dd88c
fix(flow): read the connector's read-back labels from the v1 effect r…
abrichr 2af77e0
style(flow): format the connector pilot tests
abrichr 97eda5a
feat(flow): send the stored report's SHA-256 from the connector
abrichr 01fee9b
Merge pull request #2384 from OpenAdaptAI/fix/byoc-readback-receipt-s…
abrichr ab1f04b
Merge origin/feat/byoc-runner-pilot into fix/byoc-report-digest
abrichr 9435a65
Halt when callback egress is refused after child handoff
abrichr 6b959cb
Merge pull request #2386 from OpenAdaptAI/fix/byoc-report-digest
abrichr fd71338
Merge pull request #2399 from OpenAdaptAI/codex/2385-halt-on-egress
abrichr a8a7a11
Merge remote-tracking branch 'origin/main' into HEAD
abrichr 6d7e32b
fix(connector): a cancel that kills a started child halts as outcome …
abrichr 0d98b8d
Merge remote-tracking branch 'origin/main' into HEAD
abrichr fc33b88
fix(connector): a cancel that kills a child after it reported success…
abrichr fa1d437
Merge remote-tracking branch 'origin/main' into HEAD
abrichr f3b737d
fix(connector): a stop or kill mid-run is uncertain, never a clean fa…
abrichr 1138ea5
fix(connector): no readable report after start is uncertain; SIGTERM …
abrichr 979c3ff
fix(connector,security): resolve 2 CodeQL sensitive-data alerts in wi…
abrichr 52e7f6d
Merge main into feat/byoc-runner-pilot and align __main__.py budget t…
abrichr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| wheels/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # OpenAdapt connector (customer-run runner) for Linux hosts. | ||
| # | ||
| # The container makes outbound HTTPS requests only and listens on no port. | ||
| # Build it from a pinned, signed Flow release wheel placed in ./wheels: | ||
| # | ||
| # mkdir -p wheels && cp openadapt_flow-<version>-py3-none-any.whl wheels/ | ||
| # docker build -t openadapt-connector:<version> . | ||
| # | ||
| # Run it with three mounts (see docker-compose.yml): /etc/openadapt holds | ||
| # connector.toml (0600, the connector token) and the local secret store; | ||
| # /srv/openadapt is the encrypted customer storage volume (programs in, reports | ||
| # out); nothing else is written outside the container's tmpfs. | ||
| ARG BASE_IMAGE=python:3.12-slim-bookworm | ||
| FROM ${BASE_IMAGE} | ||
|
|
||
| ENV PIP_DISABLE_PIP_VERSION_CHECK=1 \ | ||
| PYTHONDONTWRITEBYTECODE=1 \ | ||
| OPENADAPT_HOME=/etc/openadapt \ | ||
| PLAYWRIGHT_BROWSERS_PATH=/opt/playwright | ||
|
|
||
| RUN apt-get update \ | ||
| && apt-get install -y --no-install-recommends ca-certificates libnss3-tools libatomic1 tini | ||
|
|
||
| COPY wheels /tmp/wheels | ||
| RUN set -eu; \ | ||
| python -m venv /opt/openadapt; \ | ||
| wheel="$(ls /tmp/wheels/openadapt_flow-*.whl | head -1)"; \ | ||
| /opt/openadapt/bin/pip install --no-cache-dir --find-links /tmp/wheels "${wheel}[browser,vision]"; \ | ||
| apt-get update; /opt/openadapt/bin/python -m playwright install --with-deps chromium; \ | ||
| /opt/openadapt/bin/pip check; \ | ||
| rm -rf /tmp/wheels /var/lib/apt/lists/* | ||
|
|
||
| RUN useradd --system --create-home --uid 10001 openadapt \ | ||
| && mkdir -p /etc/openadapt /srv/openadapt \ | ||
| && chown openadapt:openadapt /srv/openadapt | ||
| COPY entrypoint.sh /usr/local/bin/openadapt-connector-entrypoint | ||
| RUN chmod 0755 /usr/local/bin/openadapt-connector-entrypoint | ||
|
|
||
| USER openadapt | ||
| ENV PATH="/opt/openadapt/bin:${PATH}" | ||
| WORKDIR /srv/openadapt | ||
| ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/openadapt-connector-entrypoint"] | ||
| CMD ["openadapt-flow", "connector", "run"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # The author's workstation for the end-to-end check: Flow at the cloud's pinned | ||
| # compiler version, used once to teach, admit and publish the synthetic program | ||
| # against the private app. Not part of the runner. | ||
| FROM python:3.12-slim-bookworm | ||
| ARG FLOW_VERSION=3.1.0 | ||
| ENV PLAYWRIGHT_BROWSERS_PATH=/opt/playwright PIP_DISABLE_PIP_VERSION_CHECK=1 | ||
| RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates libnss3-tools libatomic1 tesseract-ocr \ | ||
| && python -m venv /opt/flow \ | ||
| && /opt/flow/bin/pip install --no-cache-dir "openadapt-flow[browser,vision,privacy]==${FLOW_VERSION}" \ | ||
| && /opt/flow/bin/python -m spacy download en_core_web_sm \ | ||
| && /opt/flow/bin/python -m playwright install --with-deps chromium \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
| ENV PATH="/opt/flow/bin:${PATH}" | ||
| COPY entrypoint.sh /usr/local/bin/ca-entrypoint | ||
| RUN chmod 0755 /usr/local/bin/ca-entrypoint | ||
| ENTRYPOINT ["/usr/local/bin/ca-entrypoint"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| """mitmproxy addon: the runner's only way out. | ||
|
|
||
| Every request the runner (or anything on the private network) sends toward the | ||
| internet passes here. The addon writes each one, in full (method, URL, headers | ||
| with credentials masked, body), to a JSONL file, and refuses any host that is | ||
| not on the allow-list. The end-to-end check then searches that file for the | ||
| canary values that exist only inside the private network. | ||
| """ | ||
|
|
||
| import base64 | ||
| import json | ||
| import os | ||
| import time | ||
|
|
||
| from mitmproxy import http | ||
|
|
||
| ALLOWED = { | ||
| h.strip() | ||
| for h in os.environ.get("EGRESS_ALLOWED_HOSTS", "").split(",") | ||
| if h.strip() | ||
| } | ||
| LOG = os.environ.get("EGRESS_LOG", "/log/egress.jsonl") | ||
| MASK = {"authorization", "x-run-token", "cookie", "x-api-key"} | ||
|
|
||
|
|
||
| def request(flow: http.HTTPFlow) -> None: | ||
| host = flow.request.pretty_host | ||
| allowed = host in ALLOWED | ||
| body = flow.request.get_content() or b"" | ||
| entry = { | ||
| "at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()), | ||
| "allowed": allowed, | ||
| "method": flow.request.method, | ||
| "host": host, | ||
| "port": flow.request.port, | ||
| "path": flow.request.path, | ||
| "headers": { | ||
| k: ("<masked>" if k.lower() in MASK else v) | ||
| for k, v in flow.request.headers.items() | ||
| }, | ||
| "body_b64": base64.b64encode(body).decode(), | ||
| "body_bytes": len(body), | ||
| } | ||
| with open(LOG, "a", encoding="utf-8") as fh: | ||
| fh.write(json.dumps(entry) + "\n") | ||
| if not allowed: | ||
| flow.response = http.Response.make( | ||
| 403, b"egress refused by pilot proxy", {"content-type": "text/plain"} | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/sh | ||
| # Trust any extra CA certificates the operator mounts (an internal CA for the | ||
| # target application, or a TLS-inspecting egress proxy), for Python and for | ||
| # the headless browser, then start the connector. | ||
| set -eu | ||
| if [ -d /etc/openadapt/ca ] && ls /etc/openadapt/ca/*.crt >/dev/null 2>&1; then | ||
| bundle="$HOME/ca-bundle.crt" | ||
| cat /etc/ssl/certs/ca-certificates.crt /etc/openadapt/ca/*.crt > "$bundle" | ||
| export SSL_CERT_FILE="$bundle" REQUESTS_CA_BUNDLE="$bundle" | ||
| mkdir -p "$HOME/.pki/nssdb" | ||
| [ -f "$HOME/.pki/nssdb/cert9.db" ] || certutil -d "sql:$HOME/.pki/nssdb" -N --empty-password | ||
| for crt in /etc/openadapt/ca/*.crt; do | ||
| certutil -d "sql:$HOME/.pki/nssdb" -A -t "C,," -n "$(basename "$crt")" -i "$crt" | ||
| done | ||
| fi | ||
| exec "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/sh | ||
| # A throwaway local CA and a server certificate for the private app's name. | ||
| set -eu | ||
| out="$1"; name="$2" | ||
| mkdir -p "$out" | ||
| openssl req -x509 -newkey rsa:2048 -nodes -days 7 -subj "/CN=byoc-pilot-local-ca" \ | ||
| -keyout "$out/ca.key" -out "$out/ca.crt" 2>/dev/null | ||
| openssl req -newkey rsa:2048 -nodes -subj "/CN=$name" -keyout "$out/notes.key" -out "$out/notes.csr" 2>/dev/null | ||
| printf 'subjectAltName=DNS:%s\nextendedKeyUsage=serverAuth\n' "$name" > "$out/ext.cnf" | ||
| openssl x509 -req -in "$out/notes.csr" -CA "$out/ca.crt" -CAkey "$out/ca.key" -CAcreateserial \ | ||
| -days 7 -extfile "$out/ext.cnf" -out "$out/notes.crt" 2>/dev/null | ||
| rm -f "$out/notes.csr" "$out/ext.cnf" "$out/ca.srl" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| """Synthetic notes app for the customer-run runner end-to-end check. | ||
|
|
||
| It stands in for an internal application: it is reachable only on the private | ||
| Docker network, under a DNS name that does not resolve on the public internet, | ||
| over HTTPS signed by a local CA. It holds made-up records that include canary | ||
| strings; the check then searches everything the runner sent for them. | ||
|
|
||
| * ``GET /`` the notes form (what the program types into) | ||
| * ``POST /save`` saves a note | ||
| * ``GET /api/notes`` the records, for the program's independent read-back; | ||
| requires ``X-Api-Key`` (the runner's local secret) | ||
|
|
||
| Synthetic data only. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import html | ||
| import json | ||
| import os | ||
| import ssl | ||
| import threading | ||
| from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer | ||
| from pathlib import Path | ||
| from urllib.parse import parse_qs | ||
|
|
||
| API_KEY = os.environ["NOTES_READER_KEY"] | ||
| STORE = Path(os.environ.get("NOTES_STORE", "/data/notes.json")) | ||
| CANARY = os.environ.get("NOTES_CANARY", "ZQX-CANARY-RECORD") | ||
| LOCK = threading.Lock() | ||
|
|
||
| PAGE = """<!doctype html><html><head><title>Notes</title> | ||
| <style>td{{padding:6px 10px}}td.ctx{{padding-left:120px}}</style></head><body> | ||
| <h1>Notes</h1><form method="post" action="/save"><fieldset><legend>Notes</legend><table> | ||
| <tr><td><label for="note">Note</label></td><td><input id="note" name="note" type="text"></td><td class="ctx">Notes: clinic notebook, list demo</td></tr> | ||
| <tr><td></td><td><button type="submit">Save</button></td><td class="ctx">Notes: clinic notebook, list demo</td></tr> | ||
| </table></fieldset></form>{msg}<ul>{items}</ul></body></html>""" | ||
|
|
||
|
|
||
| def records() -> list[dict]: | ||
| if not STORE.exists(): | ||
| STORE.parent.mkdir(parents=True, exist_ok=True) | ||
| STORE.write_text("[]") | ||
| return json.loads(STORE.read_text()) | ||
|
|
||
|
|
||
| def seed_canaries() -> None: | ||
| """Add made-up records that hold canary strings. Run after the program is | ||
| published, as real records would exist only at run time.""" | ||
| with LOCK: | ||
| current = records() | ||
| next_id = (current[-1]["id"] + 1) if current else 1 | ||
| for n, text in enumerate( | ||
| ( | ||
| f"{CANARY}-1 synthetic patient Jane Roe DOB 1970-01-01", | ||
| f"{CANARY}-2 synthetic MRN 000-111-222", | ||
| ) | ||
| ): | ||
| current.append( | ||
| {"id": next_id + n, "note": text, "list": "demo", "key": "clinic"} | ||
| ) | ||
| STORE.write_text(json.dumps(current)) | ||
|
|
||
|
|
||
| class Handler(BaseHTTPRequestHandler): | ||
| def _send(self, code: int, body: bytes, ctype: str) -> None: | ||
| self.send_response(code) | ||
| self.send_header("content-type", ctype) | ||
| self.send_header("cache-control", "no-store") | ||
| self.send_header("content-length", str(len(body))) | ||
| self.end_headers() | ||
| self.wfile.write(body) | ||
|
|
||
| def _page(self, msg: str = "") -> None: | ||
| items = "".join(f"<li>{html.escape(r['note'])}</li>" for r in records()) | ||
| self._send( | ||
| 200, PAGE.format(msg=msg, items=items).encode(), "text/html; charset=utf-8" | ||
| ) | ||
|
|
||
| def do_GET(self) -> None: # noqa: N802 | ||
| if self.path == "/": | ||
| return self._page() | ||
| if self.path == "/api/notes": | ||
| if self.headers.get("x-api-key") != API_KEY: | ||
| return self._send(401, b'{"error":"unauthorized"}', "application/json") | ||
| return self._send( | ||
| 200, json.dumps({"records": records()}).encode(), "application/json" | ||
| ) | ||
| self._send(404, b"not found", "text/plain") | ||
|
|
||
| def do_POST(self) -> None: # noqa: N802 | ||
| if self.path != "/save": | ||
| return self._send(404, b"not found", "text/plain") | ||
| length = min(int(self.headers.get("content-length") or 0), 2000) | ||
| note = (parse_qs(self.rfile.read(length).decode()).get("note") or [""])[0][:200] | ||
| with LOCK: | ||
| current = records() | ||
| if note: | ||
| next_id = (current[-1]["id"] + 1) if current else 1 | ||
| current.append( | ||
| {"id": next_id, "note": note, "list": "demo", "key": "clinic"} | ||
| ) | ||
| STORE.write_text(json.dumps(current[-500:])) | ||
| self._page("<p>Saved!</p>") | ||
|
|
||
| def log_message(self, fmt: str, *args: object) -> None: | ||
| print("notes:", self.command, self.path, flush=True) | ||
|
|
||
|
|
||
| def main() -> None: | ||
| server = ThreadingHTTPServer(("0.0.0.0", 443), Handler) | ||
| ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER) | ||
| ctx.minimum_version = ssl.TLSVersion.TLSv1_2 | ||
| ctx.load_cert_chain(os.environ["NOTES_CERT"], os.environ["NOTES_KEY"]) | ||
| server.socket = ctx.wrap_socket(server.socket, server_side=True) | ||
| print("notes app listening on 443", flush=True) | ||
| server.serve_forever() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| import sys | ||
|
|
||
| if sys.argv[1:] == ["seed-canaries"]: | ||
| seed_canaries() | ||
| else: | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import sys | ||
|
|
||
| from openadapt_flow.wrap import publish | ||
|
|
||
| sys.exit(publish.main(sys.argv[1:])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #!/bin/sh | ||
| # End-to-end check of the customer-run runner against a staging control plane. | ||
| # | ||
| # run_e2e.sh up private network, synthetic app, egress proxy | ||
| # run_e2e.sh publish teach, admit and publish the program (author side) | ||
| # run_e2e.sh runner start the connector (needs $STATE/connector.toml) | ||
| # run_e2e.sh down remove everything | ||
| # | ||
| # Topology: the app and the runner sit on an --internal network with no route | ||
| # out. The only way out is the egress proxy, which logs every request in full | ||
| # and refuses any host not on EGRESS_ALLOWED_HOSTS. The app's name resolves | ||
| # only inside the private network. Synthetic data only. | ||
| set -eu | ||
| CTR="${CTR:-docker}" | ||
| HERE="$(cd "$(dirname "$0")" && pwd)" | ||
| STATE="${STATE:?set STATE to a durable directory}" | ||
| APP_HOST="${APP_HOST:-notes.byoc-pilot.openadapt.ai}" | ||
| CLOUD_HOST="${CLOUD_HOST:-openadapt-cloud-staging.netlify.app}" | ||
| RUNNER_IMAGE="${RUNNER_IMAGE:-openadapt-connector:pilot-dev}" | ||
| PUBLISHER_IMAGE="${PUBLISHER_IMAGE:-byoc-publisher:3.1.0}" | ||
| PROXY_IMAGE="${PROXY_IMAGE:-mitmproxy/mitmproxy:11.1.3}" | ||
| PROXY="http://egress-proxy:8080" | ||
|
|
||
| up() { | ||
| mkdir -p "$STATE/certs" "$STATE/mitm" "$STATE/log" "$STATE/notes-data" "$STATE/ca" | ||
| [ -f "$STATE/certs/ca.crt" ] || "$HERE/gen_certs.sh" "$STATE/certs" "$APP_HOST" | ||
| [ -f "$STATE/secrets/notes-reader.env" ] || { | ||
| mkdir -p "$STATE/secrets" | ||
| printf 'NOTES_READER_KEY=ZQX-CANARY-SECRET-%s\n' "$(openssl rand -hex 8)" > "$STATE/secrets/notes-reader.env" | ||
| chmod 600 "$STATE/secrets/notes-reader.env" | ||
| } | ||
| $CTR network inspect byoc-private >/dev/null 2>&1 || $CTR network create --internal byoc-private >/dev/null | ||
| $CTR network inspect byoc-egress >/dev/null 2>&1 || $CTR network create byoc-egress >/dev/null | ||
| $CTR rm -f byoc-notes byoc-egress-proxy >/dev/null 2>&1 || true | ||
| $CTR run -d --name byoc-notes --network byoc-private --network-alias "$APP_HOST" \ | ||
| --env-file "$STATE/secrets/notes-reader.env" \ | ||
| -e NOTES_CERT=/certs/notes.crt -e NOTES_KEY=/certs/notes.key -e NOTES_STORE=/data/notes.json \ | ||
| -v "$STATE/certs:/certs:ro" -v "$STATE/notes-data:/data" -v "$HERE/notes_app.py:/app/notes_app.py:ro" \ | ||
| python:3.12-slim-bookworm python /app/notes_app.py >/dev/null | ||
| $CTR run -d --name byoc-egress-proxy --network byoc-egress \ | ||
| -e EGRESS_ALLOWED_HOSTS="$CLOUD_HOST" -e EGRESS_LOG=/log/egress.jsonl \ | ||
| -v "$STATE/mitm:/home/mitmproxy/.mitmproxy" -v "$STATE/log:/log" -v "$HERE/egress_log.py:/addon/egress_log.py:ro" \ | ||
| "$PROXY_IMAGE" mitmdump --listen-port 8080 -s /addon/egress_log.py --set block_global=false >/dev/null | ||
| $CTR network connect --alias egress-proxy byoc-private byoc-egress-proxy | ||
| i=0; until [ -f "$STATE/mitm/mitmproxy-ca-cert.pem" ] || [ $i -gt 30 ]; do i=$((i+1)); sleep 1; done | ||
| cp "$STATE/certs/ca.crt" "$STATE/ca/app-ca.crt" | ||
| cp "$STATE/mitm/mitmproxy-ca-cert.pem" "$STATE/ca/egress-proxy-ca.crt" | ||
| echo "up: app at https://$APP_HOST (private only), egress via $PROXY" | ||
| } | ||
|
|
||
| publish() { | ||
| mkdir -p "$STATE/work" | ||
| cp "$HERE/teach_admit.py" "$STATE/work/teach_admit.py" | ||
| $CTR run --rm --name byoc-publisher --network byoc-private \ | ||
| -e HTTPS_PROXY="$PROXY" -e HTTP_PROXY="$PROXY" -e NO_PROXY="$APP_HOST" \ | ||
| -e NOTES_ORIGIN="https://$APP_HOST" \ | ||
| --env-file "$STATE/secrets/notes-reader.env" \ | ||
| --env-file "$STATE/publisher.env" \ | ||
| -v "$STATE/ca:/etc/openadapt/ca:ro" -v "$STATE/work:/work" -w /work \ | ||
| "$PUBLISHER_IMAGE" sh -c "${PUBLISH_CMD:?set PUBLISH_CMD}" | ||
| } | ||
|
|
||
| runner() { | ||
| $CTR rm -f byoc-runner >/dev/null 2>&1 || true | ||
| $CTR run -d --name byoc-runner --network byoc-private \ | ||
| --read-only --tmpfs /tmp --tmpfs /home/openadapt \ | ||
| -e HTTPS_PROXY="$PROXY" -e HTTP_PROXY="$PROXY" -e NO_PROXY="$APP_HOST" \ | ||
| -e OPENADAPT_HOME=/etc/openadapt \ | ||
| -v "$STATE/runner-etc:/etc/openadapt" -v "$STATE/runner-storage:/srv/openadapt" \ | ||
| "$RUNNER_IMAGE" ${RUNNER_CMD:-openadapt-flow connector run} >/dev/null | ||
| echo "runner started; logs: $CTR logs -f byoc-runner" | ||
| } | ||
|
|
||
| down() { | ||
| $CTR rm -f byoc-runner byoc-publisher byoc-notes byoc-egress-proxy >/dev/null 2>&1 || true | ||
| $CTR network rm byoc-private byoc-egress >/dev/null 2>&1 || true | ||
| } | ||
|
|
||
| "${1:?up|publish|runner|down}" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.