1
1
'use strict'
2
2
3
3
const { storage } = require ( '../../../../../datadog-core' )
4
- const { getFirstNonDDPathAndLine } = require ( '../path-line' )
4
+ const { getNonDDPathAndLineFromCallsites } = require ( '../path-line' )
5
5
const { addVulnerability, getVulnerabilityCallSiteList } = require ( '../vulnerability-reporter' )
6
6
const { getIastContext, getIastStackTraceId } = require ( '../iast-context' )
7
7
const overheadController = require ( '../overhead-controller' )
@@ -29,14 +29,19 @@ class Analyzer extends SinkIastPlugin {
29
29
30
30
_reportEvidence ( value , context , evidence ) {
31
31
const callSiteList = getVulnerabilityCallSiteList ( )
32
- const location = this . _getLocation ( value , callSiteList )
32
+ const nonDDCallSiteList = getNonDDPathAndLineFromCallsites ( callSiteList , this . _getExcludedPaths ( ) )
33
+
34
+ const location = this . _getLocation ( value , nonDDCallSiteList )
33
35
34
36
if ( ! this . _isExcluded ( location ) ) {
35
- const locationSourceMap = this . _replaceLocationFromSourceMap ( location )
37
+ const originalCallSiteList = nonDDCallSiteList . map ( callSite => this . _replaceCallsiteFromSourceMap ( callSite ) )
38
+
39
+ const originalLocation = this . _getOriginalLocation ( originalCallSiteList )
36
40
const spanId = context && context . rootSpan && context . rootSpan . context ( ) . toSpanId ( )
37
41
const stackId = getIastStackTraceId ( context )
38
- const vulnerability = this . _createVulnerability ( this . _type , evidence , spanId , locationSourceMap , stackId )
39
- addVulnerability ( context , vulnerability , callSiteList , stackId )
42
+ const vulnerability = this . _createVulnerability ( this . _type , evidence , spanId , originalLocation , stackId )
43
+
44
+ addVulnerability ( context , vulnerability , originalCallSiteList , stackId )
40
45
}
41
46
}
42
47
@@ -53,23 +58,41 @@ class Analyzer extends SinkIastPlugin {
53
58
}
54
59
55
60
_getLocation ( value , callSiteList ) {
56
- return getFirstNonDDPathAndLine ( callSiteList , this . _getExcludedPaths ( ) )
61
+ return callSiteList [ 0 ]
57
62
}
58
63
59
- _replaceLocationFromSourceMap ( location ) {
60
- if ( location ) {
61
- const { path, line, column } = getOriginalPathAndLineFromSourceMap ( location )
64
+ _getOriginalLocation ( originalCallSiteList ) {
65
+ const [ location ] = originalCallSiteList
66
+ const originalLocation = { }
67
+
68
+ if ( location . path ) {
69
+ originalLocation . path = location . path
70
+ }
71
+ if ( location . line ) {
72
+ originalLocation . line = location . line
73
+ }
74
+ if ( location . column ) {
75
+ originalLocation . column = location . column
76
+ }
77
+
78
+ return originalLocation
79
+ }
80
+
81
+ _replaceCallsiteFromSourceMap ( callsite ) {
82
+ if ( callsite ) {
83
+ const { path, line, column } = getOriginalPathAndLineFromSourceMap ( callsite )
62
84
if ( path ) {
63
- location . path = path
85
+ callsite . path = path
64
86
}
65
87
if ( line ) {
66
- location . line = line
88
+ callsite . line = line
67
89
}
68
90
if ( column ) {
69
- location . column = column
91
+ callsite . column = column
70
92
}
71
93
}
72
- return location
94
+
95
+ return callsite
73
96
}
74
97
75
98
_getExcludedPaths ( ) { }
0 commit comments