-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add sources tests * styles
- Loading branch information
Showing
2 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
packages/dd-trace/test/appsec/iast/taint-tracking/plugin.express.plugin.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use strict' | ||
|
||
const { prepareTestServerForIastInExpress } = require('../utils') | ||
const axios = require('axios') | ||
|
||
function noop () {} | ||
|
||
describe('Taint tracking plugin sources express tests', () => { | ||
withVersions('express', 'express', '>=4.8.0', version => { | ||
prepareTestServerForIastInExpress('in express', version, | ||
(testThatRequestHasVulnerability, _, config) => { | ||
describe('tainted body', () => { | ||
function makePostRequest (done) { | ||
axios.post(`http://localhost:${config.port}/`, { | ||
command: 'echo 1' | ||
}).catch(done) | ||
} | ||
|
||
testThatRequestHasVulnerability((req) => { | ||
const childProcess = require('child_process') | ||
childProcess.exec(req.body.command, noop) | ||
}, 'COMMAND_INJECTION', 1, noop, makePostRequest) | ||
}) | ||
|
||
describe('tainted query param', () => { | ||
function makeRequestWithQueryParam (done) { | ||
axios.get(`http://localhost:${config.port}/?command=echo`).catch(done) | ||
} | ||
|
||
testThatRequestHasVulnerability((req) => { | ||
const childProcess = require('child_process') | ||
childProcess.exec(req.query.command, noop) | ||
}, 'COMMAND_INJECTION', 1, noop, makeRequestWithQueryParam) | ||
}) | ||
|
||
describe('tainted header', () => { | ||
function makeRequestWithHeader (done) { | ||
axios.get(`http://localhost:${config.port}/`, { | ||
headers: { | ||
'x-iast-test-command': 'echo 1' | ||
} | ||
}).catch(done) | ||
} | ||
|
||
testThatRequestHasVulnerability((req) => { | ||
const childProcess = require('child_process') | ||
childProcess.exec(req.headers['x-iast-test-command'], noop) | ||
}, 'COMMAND_INJECTION', 1, noop, makeRequestWithHeader) | ||
}) | ||
} | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters