Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed33a6e

Browse files
committed
JS: Add explicit model of .join()
1 parent fa7ad03 commit ed33a6e

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

  • javascript/ql/lib/semmle/javascript/internal/flow_summaries

javascript/ql/lib/semmle/javascript/internal/flow_summaries/Arrays.qll

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* Contains a summary for relevant methods on arrays, except Array.prototype.join which is currently special-cased in StringConcatenation.qll.
2+
* Contains a summary for relevant methods on arrays.
33
*
4-
* Note that some of Array methods are modelled in `AmbiguousCoreMethods.qll`, and `join` and `toString` are special-cased elsewhere.
4+
* Note that some of Array methods are modelled in `AmbiguousCoreMethods.qll`, and `toString` is special-cased elsewhere.
55
*/
66

77
private import javascript
@@ -116,6 +116,26 @@ class ArrayConstructorSummary extends SummarizedCallable {
116116
}
117117
}
118118

119+
/**
120+
* A call to `join` with a separator argument.
121+
*
122+
* Calls without separators are modelled in `StringConcatenation.qll`.
123+
*/
124+
class Join extends SummarizedCallable {
125+
Join() { this = "Array#join" }
126+
127+
override InstanceCall getACallSimple() {
128+
result.getMethodName() = "join" and
129+
result.getNumArgument() = [0, 1]
130+
}
131+
132+
override predicate propagatesFlowExt(string input, string output, boolean preservesValue) {
133+
preservesValue = false and
134+
input = "Argument[this].ArrayElement" and
135+
output = "ReturnValue"
136+
}
137+
}
138+
119139
class CopyWithin extends SummarizedCallable {
120140
CopyWithin() { this = "Array#copyWithin" }
121141

0 commit comments

Comments
 (0)