Skip to content

Commit 2e409c3

Browse files
committed
Adjust CDSUtil to make simpler
rm type tracking that covers rare case
1 parent 9e81393 commit 2e409c3

File tree

3 files changed

+3
-22
lines changed

3 files changed

+3
-22
lines changed

javascript/frameworks/cap/lib/advanced_security/javascript/frameworks/cap/CDSUtils.qll

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,6 @@ class FileWriters extends DataFlow::CallNode {
9696
exists(CdsUtilsModuleAccess utils | utils.getMember(["append", "write"]).getACall() = this)
9797
}
9898

99-
SourceNode fileReaderWriterUtils(TypeTracker t) {
100-
t.start() and
101-
result = this
102-
or
103-
exists(TypeTracker t2 | result = fileReaderWriterUtils(t2).track(t2, t))
104-
}
105-
106-
SourceNode fileReaderWriterUtils() { result = fileReaderWriterUtils(TypeTracker::end()) }
107-
10899
/**
109100
* Gets the arguments to these calls that represent data.
110101
*/
@@ -121,7 +112,7 @@ class FileWriters extends DataFlow::CallNode {
121112
* Includes arguments to chained calls `to`, where that argument also represents a path.
122113
*/
123114
DataFlow::Node getPath() {
124-
fileReaderWriterUtils().getAMemberCall("to").getAnArgument() = result
115+
this.getAMemberCall("to").getAnArgument() = result
125116
or
126117
this.getNumArgument() = 2 and
127118
this.getArgument(0) = result
@@ -137,21 +128,12 @@ class FileReaderWriters extends DataFlow::CallNode {
137128
exists(CdsUtilsModuleAccess utils | utils.getMember(["copy"]).getACall() = this)
138129
}
139130

140-
SourceNode fileReaderWriterUtils(TypeTracker t) {
141-
t.start() and
142-
result = this
143-
or
144-
exists(TypeTracker t2 | result = fileReaderWriterUtils(t2).track(t2, t))
145-
}
146-
147-
SourceNode fileReaderWriterUtils() { result = fileReaderWriterUtils(TypeTracker::end()) }
148-
149131
/**
150132
* Gets the arguments to these calls that represent a path.
151133
* Includes arguments to chained calls `to`, where that argument also represents a path.
152134
*/
153135
DataFlow::Node getPath() {
154-
fileReaderWriterUtils().getAMemberCall("to").getArgument(_) = result
136+
this.getAMemberCall("to").getArgument(_) = result
155137
or
156138
this.getAnArgument() = result
157139
}

javascript/frameworks/cap/test/models/cds/utils/utils.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@
3636
| utils.js:43:24:43:29 | 'data' | 'data': sink |
3737
| utils.js:44:10:44:23 | 'dist/db/data' | 'dist/db/data': sink |
3838
| utils.js:52:20:52:28 | 'db/data' | 'db/data': sink |
39-
| utils.js:57:10:57:23 | 'dist/db/data' | 'dist/db/data': sink |

javascript/frameworks/cap/test/models/cds/utils/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ function wrapperinnermid(temp) {
5454
}
5555

5656
function wrapperinner(a) {
57-
a.to('dist/db/data') // sink
57+
a.to('dist/db/data') // sink - [FALSE_NEGATIVE] - rare case as CAP is a fluent API
5858
}

0 commit comments

Comments
 (0)