Bound the number and length of payload.egress_allowlist entries

Open
#84 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
66/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
fastapi, python
Domain
api, backend

Research direction

Start with server/orcaster_server/env_names.py, especially validate_payload_egress_allowlist and the existing task_env limits; then trace the listed task, control-op and worker command routes. Check the related tests and document the limits in docs/operator-manual.md and the Unreleased changelog. Done when the specified boundaries and error details are covered, existing stored tasks still poll, and the routes and docs meet the acceptance criteria.

Written by the indexing model from the issue text.

Description

enhancement P2 server

Problem

payload.task_env has limits: at most TASK_ENV_MAX_ENTRIES (256) entries and TASK_ENV_NAME_MAX_LEN (128) characters per entry (server/orcaster_server/env_names.py:22-23, :183-184).

payload.egress_allowlist has no limits. validate_payload_egress_allowlist only checks that the value is a list of strings (server/orcaster_server/env_names.py:228-248). It runs on the same routes as the task_env check: creating and forking a task (server/orcaster_server/schemas/tasks.py:331, in AdminCreateTaskRequest), the control-op route (server/orcaster_server/schemas/tasks.py:582, in AdminControlOpRequest) and the worker command route (server/orcaster_server/api/admin_workers.py:174).

So a client can store a task with a very large list or very long entries. The server stores and signs it, and every worker that claims the task must parse it and write it into its egress allow file.

Proposed change

  1. Add two constants next to the task_env ones in server/orcaster_server/env_names.py:
    • EGRESS_ALLOWLIST_MAX_ENTRIES, for example 256.
    • EGRESS_ALLOWLIST_ENTRY_MAX_LEN, for example 255 (a 253-character DNS name plus a *. wildcard prefix).
  2. In validate_payload_egress_allowlist, after the shape check, reject a list with more entries than the maximum, and any entry longer than the maximum. The error names the field, the index and the limit, never the full value. FastAPI turns the ValueError into a 422, as for task_env.
  3. Keep the check at write time only. Rows already stored are still served and run, as the docstring already says for the shape check.
  4. Document both limits in docs/operator-manual.md, next to the egress_allowlist field (docs/operator-manual.md:138).

Compatibility

This is a contract change on the task creation routes: a request with a list above a limit now gets 422 instead of being stored.

Guard:

  • The limits are far above any realistic allowlist, so existing clients and workloads keep working unchanged. Choose the final values with that in mind, and do not go below the examples above.
  • Tasks already stored are not re-validated. They are still delivered and run, and the worker is unchanged.
  • Forking an old task whose list is above a limit fails with 422 and a clear message. This is the only new failure for existing data.
  • The release note states the new limits.

Acceptance criteria

  • Test: a list with exactly the maximum number of entries is accepted. One more entry returns 422 on task create, on fork, and on the worker command and control-op routes.
  • Test: an entry of exactly the maximum length is accepted. One more character returns 422.
  • Test: the 422 detail names payload.egress_allowlist, the index and the limit, and does not echo the whole entry.
  • Test: an existing task row with a larger list is still delivered to a worker by the poll.
  • [] (strict mode) and an absent field still behave as today.
  • Existing clients that send allowlists below the limits keep working without changes.
  • The limits are documented in docs/operator-manual.md.
  • CHANGELOG entry under Unreleased, marked as an API contract change.
Dominant language
Python
Stars
0
Forks
0
Avg merge
1d 1h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AInvirion/orcaster

All issues in AInvirion/orcaster

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.