Skip to content

Commit ca02e1d

Browse files
authored
[DI] Sanitize instanceof class in probe conditions (#5520)
1 parent 1db78a6 commit ca02e1d

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

packages/dd-trace/src/debugger/devtools_client/condition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function compile (node) {
5757
}
5858
})()`
5959
} else if (type === 'instanceof') {
60-
return `Function.prototype[Symbol.hasInstance].call(${value[1]}, ${compile(value[0])})`
60+
return `Function.prototype[Symbol.hasInstance].call(${assertIdentifier(value[1])}, ${compile(value[0])})`
6161
} else if (type === 'ref') {
6262
if (value === '@it') {
6363
return '$dd_it'

packages/dd-trace/test/debugger/devtools_client/condition-test-cases.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,11 @@ const typeAndDefinitionChecks = [
629629
{ bar: new HasInstanceSideEffect(), HasInstanceSideEffect },
630630
true
631631
],
632+
{
633+
ast: { instanceof: [{ ref: 'foo' }, 'foo.bar'] },
634+
expected: new SyntaxError('Illegal identifier: foo.bar'),
635+
execute: false
636+
},
632637

633638
[{ isDefined: { ref: 'foo' } }, { bar: 42 }, false],
634639
[{ isDefined: { ref: 'bar' } }, { bar: 42 }, true],

0 commit comments

Comments
 (0)