Skip to content

feat(crs-compose): add bounds for staged input artifacts - #507

Open
imshubham22apr-gif wants to merge 1 commit into
ossf:mainfrom
imshubham22apr-gif:fix/stage-artifact-input-limits
Open

imshubham22apr-gif wants to merge 1 commit into
ossf:mainfrom
imshubham22apr-gif:fix/stage-artifact-input-limits

Conversation

@imshubham22apr-gif

Copy link
Copy Markdown
Contributor

Summary

Adds optional bounds validation for staged input files and input directories passed via artifact input flags (--pov/--pov-dir, --seed-dir, --bug-candidate/--bug-candidate-dir, --report/--report-dir, --patch/--patch-dir). Limits can be set via environment variables OSS_CRS_MAX_INPUT_FILE_SIZE and OSS_CRS_MAX_INPUT_FILE_COUNT or through code invocation parameters.

Problem

When staging host artifact inputs into the exchange directory for a run, _copy_artifact_input copies files or entire directory trees without pre-checking file sizes or file counts. If oversized files or runaway directories (e.g. nested symlink loops or accidentally staging an entire disk/repo tree) are supplied as inputs, the staging step can exhaust host disk space, degrade performance, or crash runner containers before the run starts.

Solution

  1. Added _validate_artifact_input_limits(artifact_inputs, max_file_size=None, max_file_count=None) to CRSCompose.
    • Supports bounds configuration via OSS_CRS_MAX_INPUT_FILE_SIZE (maximum byte size per file) and OSS_CRS_MAX_INPUT_FILE_COUNT (maximum number of files within an input directory).
    • Validates individual input files and all files discovered in input directories during pre-run validation.
    • Rejects inputs exceeding the thresholds with clear, descriptive error messages identifying the violating flag and path.
  2. Hooked limit validation into CRSCompose.run() immediately after syntax validation.
  3. Added unit tests in oss_crs/tests/unit/test_directed_inputs_behavior.py covering:
    • Valid file inputs within size limits.
    • File inputs exceeding max size.
    • Directory inputs with files exceeding max size.
    • Directory inputs exceeding max file count.
    • Parsing limits from environment variables (OSS_CRS_MAX_INPUT_FILE_SIZE, OSS_CRS_MAX_INPUT_FILE_COUNT).
  4. Updated CHANGELOG.md under [Unreleased] ### Added.

Testing

  • uv run pytest oss_crs/tests/unit/test_directed_inputs_behavior.py (23 passed)
  • uv run ruff check oss_crs/src/crs_compose.py oss_crs/tests/unit/test_directed_inputs_behavior.py (passed)
  • uv run ruff format --check oss_crs/src/crs_compose.py oss_crs/tests/unit/test_directed_inputs_behavior.py (passed)
  • uv run pyright oss_crs/src/crs_compose.py oss_crs/tests/unit/test_directed_inputs_behavior.py (0 errors)

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