Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
uurien committed Jun 14, 2024
1 parent a4142bf commit 96f208c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions integration-tests/appsec/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ describe('RASP', () => {

assert.fail('Request should have failed')
} catch (e) {
if (!e.response) {
throw e
}

assert.strictEqual(e.response.status, 403)
}
})
Expand Down Expand Up @@ -113,5 +117,9 @@ describe('RASP', () => {
it('should not crash the app when writeEarlyHints after blocking', () => {
return testNotCrashedAfterBlocking('/ssrf/http/unhandled-async-write-G')
})

it('should not crash the app when res.json after blocking', () => {
return testNotCrashedAfterBlocking('/ssrf/http/unhandled-async-write-H')
})
})
})
6 changes: 6 additions & 0 deletions integration-tests/appsec/rasp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ app.get('/ssrf/http/unhandled-async-write-G', (req, res) => {
})
})

app.get('/ssrf/http/unhandled-async-write-H', (req, res) => {
makeOutgoingRequestAndCbAfterTimeout(req, res, () => {
res.json({ key: 'value' })
})
})

function streamFile (res) {
const stream = fs.createReadStream(path.join(__dirname, 'streamtest.txt'), { encoding: 'utf8' })
stream.pipe(res, { end: false })
Expand Down

0 comments on commit 96f208c

Please sign in to comment.