1
1
'use strict'
2
2
3
3
const { storage } = require ( '../../../../../datadog-core' )
4
- const { getFirstNonDDPathAndLine } = require ( '../path-line' )
5
- const { addVulnerability, getVulnerabilityCallSiteList } = require ( '../vulnerability-reporter' )
4
+ const { getNonDDPathAndLineCallsites } = require ( '../path-line' )
5
+ const { addVulnerability, getVulnerabilityCallSiteFrames } = require ( '../vulnerability-reporter' )
6
6
const { getIastContext, getIastStackTraceId } = require ( '../iast-context' )
7
7
const overheadController = require ( '../overhead-controller' )
8
8
const { SinkIastPlugin } = require ( '../iast-plugin' )
@@ -28,15 +28,17 @@ class Analyzer extends SinkIastPlugin {
28
28
}
29
29
30
30
_reportEvidence ( value , context , evidence ) {
31
- const callSiteList = getVulnerabilityCallSiteList ( )
32
- const location = this . _getLocation ( value , callSiteList )
31
+ const callSiteFrames = getVulnerabilityCallSiteFrames ( )
32
+ const nonDDCallSiteFrames = getNonDDPathAndLineCallsites ( callSiteFrames , this . _getExcludedPaths ( ) )
33
+
34
+ const location = this . _getLocation ( null , nonDDCallSiteFrames )
33
35
34
36
if ( ! this . _isExcluded ( location ) ) {
35
- const locationSourceMap = this . _replaceLocationFromSourceMap ( location )
37
+ const originalCallSiteFrames = nonDDCallSiteFrames . map ( callSite => this . _replaceLocationFromSourceMap ( callSite ) )
36
38
const spanId = context && context . rootSpan && context . rootSpan . context ( ) . toSpanId ( )
37
39
const stackId = getIastStackTraceId ( context )
38
- const vulnerability = this . _createVulnerability ( this . _type , evidence , spanId , locationSourceMap , stackId )
39
- addVulnerability ( context , vulnerability , callSiteList , stackId )
40
+ const vulnerability = this . _createVulnerability ( this . _type , evidence , spanId , originalCallSiteFrames [ 0 ] , stackId )
41
+ addVulnerability ( context , vulnerability , originalCallSiteFrames , stackId )
40
42
}
41
43
}
42
44
@@ -52,15 +54,16 @@ class Analyzer extends SinkIastPlugin {
52
54
return { value }
53
55
}
54
56
55
- _getLocation ( value , callSiteList ) {
56
- return getFirstNonDDPathAndLine ( callSiteList , this . _getExcludedPaths ( ) )
57
+ _getLocation ( value , callSiteFrames ) {
58
+ return callSiteFrames [ 0 ]
57
59
}
58
60
59
61
_replaceLocationFromSourceMap ( location ) {
60
62
if ( location ) {
61
63
const { path, line, column } = getOriginalPathAndLineFromSourceMap ( location )
62
64
if ( path ) {
63
65
location . path = path
66
+ location . file = path
64
67
}
65
68
if ( line ) {
66
69
location . line = line
0 commit comments