Skip to content

Harden Lambda scan temp-file and timeout handling#320

Open
docwho2 wants to merge 1 commit intomainfrom
codex/review-repo-for-improvement-opportunities
Open

Harden Lambda scan temp-file and timeout handling#320
docwho2 wants to merge 1 commit intomainfrom
codex/review-repo-for-improvement-opportunities

Conversation

@docwho2
Copy link
Owner

@docwho2 docwho2 commented Feb 20, 2026

Motivation

  • Prevent file name collisions in /tmp when multiple scans use the same S3 object base name by using unique temp file names.
  • Avoid passing a negative or too-small timeout to Process.waitFor which can cause unexpected behavior near Lambda timeouts.
  • Improve correctness on interruption by restoring the thread interrupt status when InterruptedException is caught.

Description

  • Replace deterministic /tmp path generation with a new helper createTempFilePath(String) that generates a UUID-based filename (preserving the original extension) and returns a Path under /tmp (file: lambda/src/main/java/cloud/cleo/clamav/lambda/ScanningLambda.java).
  • Add getClamScanWaitMillis(int) to compute a safe wait time (remainingMillis - 10000) and bail out if there is insufficient execution time, destroying the clamscan process and tagging the object ERROR when configured to do so.
  • Restore thread interrupt status inside the catch for InterruptedException to avoid swallowing the interrupt.
  • Add Paths import and ensure the temp file is deleted in the finally block after scanning.

Testing

  • Ran the project's test suite with mvn test -q and the tests completed successfully.

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant