Skip to content

fix(webui): validate run_id parameter across API endpoints - #510

Open
imshubham22apr-gif wants to merge 1 commit into
ossf:mainfrom
imshubham22apr-gif:fix/webui-run-id-validation
Open

imshubham22apr-gif wants to merge 1 commit into
ossf:mainfrom
imshubham22apr-gif:fix/webui-run-id-validation

Conversation

@imshubham22apr-gif

Copy link
Copy Markdown
Contributor

Summary

Validates the run_id path parameter in the WebUI service across all API routes and dashboard detail views to enforce safe alphanumeric identifiers (^[a-zA-Z0-9_\-]+$), returning HTTP 400 for invalid inputs and preventing unexpected globbing or file-system traversal.

Changes

  1. oss-crs-infra/webui/main.py:
    • Added regex pattern RUN_ID_REGEX = re.compile(r"^[a-zA-Z0-9_\-]+$") and _validate_run_id(run_id).
    • Wired _validate_run_id(run_id) into _get_or_create_run(), run_status(), run_history(), run_detail(), and artifact inspection/download routes (/api/runs/{run_id}/artifacts* and /run/{run_id}/artifacts/{atype}).
    • Rejects malformed or special character run identifiers with HTTP 400.
  2. oss_crs/tests/unit/test_webui_server.py:
    • Added new unit test suite using FastAPI's TestClient verifying /health, registration and status queries for valid run IDs, and parameterized checks asserting HTTP 400 rejection on invalid run identifiers containing injection tokens, wildcards, spaces, or illegal punctuation.
  3. CHANGELOG.md:
    • Documented the validation behavior under [Unreleased] ### Changed.

Testing

  • uv run pytest oss_crs/tests/unit/test_webui_server.py (9 passed)
  • uv run ruff check and uv run ruff format --check (clean)
  • uv run pyright (clean)
  • DCO signed-off commit.

Signed-off-by: imshubham22apr-gif <imshubham.22apr@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant