Skip to content

Commit 42ce94b

Browse files
watsonuurien
andauthored
Fix detection of stacks originating from dd-trace (#5773)
When an error is logged, its message is redacted unless it's originating from with the tracer. Previously it would only detect it as coming from within the tracer if the filepath was within the `packages` directory. This meant that some errors originating from the tracer would be redacted even though they shouldn't. This problem can be traced back to the following PR: #3593 Co-authored-by: Ugaitz Urien <ugaitz.urien@datadoghq.com>
1 parent f7ab851 commit 42ce94b

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

packages/dd-trace/src/util.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,10 @@ function globMatch (pattern, subject) {
6161
return true
6262
}
6363

64-
// TODO: this adds stack traces relative to packages/
65-
// shouldn't paths be relative to the root of dd-trace?
6664
function calculateDDBasePath (dirname) {
6765
const dirSteps = dirname.split(path.sep)
6866
const packagesIndex = dirSteps.lastIndexOf('packages')
69-
return dirSteps.slice(0, packagesIndex + 1).join(path.sep) + path.sep
67+
return dirSteps.slice(0, packagesIndex).join(path.sep) + path.sep
7068
}
7169

7270
function normalizeProfilingEnabledValue (configValue) {

packages/dd-trace/test/appsec/iast/analyzers/vulnerability-analyzer.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('vulnerability-analyzer', () => {
77
const VULNERABLE_VALUE = 'VULNERABLE_VALUE'
88
const VULNERABILITY = 'VULNERABILITY'
99
const VULNERABILITY_LOCATION_FROM_SOURCEMAP = {
10-
path: 'VULNERABILITY_LOCATION_FROM_SOURCEMAP', line: 42, method: 'callFn'
10+
path: 'VULNERABILITY_LOCATION_FROM_SOURCEMAP', line: 42, class: 'process', method: 'processImmediate'
1111
}
1212
const ANALYZER_TYPE = 'TEST_ANALYZER'
1313
const SPAN_ID = '123456'

packages/dd-trace/test/appsec/iast/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ function testInRequest (app, tests) {
6565

6666
function testOutsideRequestHasVulnerability (fnToTest, vulnerability, plugins, timeout) {
6767
beforeEach(async () => {
68+
vulnerabilityReporter.clearCache()
6869
await agent.load(plugins)
6970
})
7071
afterEach(() => {

0 commit comments

Comments
 (0)