-
Notifications
You must be signed in to change notification settings - Fork 14
fix: improve attachment validation and testing stability with delay #416
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,11 +5,14 @@ const { join } = cds.utils.path | |
| const app = join(__dirname, "../incidents-app") | ||
| const { axios, POST, PUT, GET } = cds.test(app) | ||
| const { validateAttachmentMimeType } = require("../../lib/generic-handlers") | ||
| const { newIncident } = require("../utils/testUtils") | ||
| const { newIncident, delay } = require("../utils/testUtils") | ||
|
|
||
| describe("validateAttachmentMimeType - Content-Type header bypass security test", () => { | ||
| axios.defaults.auth = { username: "alice" } | ||
|
|
||
| // Allow background operations (malware scan status updates) to complete before teardown | ||
| afterAll(() => delay(2000)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Best Practices: Hardcoded Same issue as in the integration test: a fixed 2-second sleep is non-deterministic and could either waste time or still race on heavily loaded CI runners. If the background operations being awaited are detectable events (e.g., Please provide feedback on the review comment by checking the appropriate box:
|
||
|
|
||
| /** | ||
| * Security Test: Content-Type Header Bypass Attack | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best Practices: Hardcoded
delay(2000)is a fragile teardown strategyUsing a fixed 2-second sleep to wait for background operations (malware scan status updates) is non-deterministic: it will silently pass on fast machines and silently fail on slow ones or under load. The codebase already has a purpose-built
waitForScanStatusutility that properly awaits the actual completion event with a timeout.Consider replacing the blind delay with a proper awaitable hook that tracks pending background operations, or at minimum document what specific operations are expected to complete and the rationale for the chosen timeout value. If this test suite consistently triggers a scan,
waitForScanStatusfromtestUtilsshould be used instead.Please provide feedback on the review comment by checking the appropriate box: