Skip to content

Commit 321df82

Browse files
committed
Apply review feedback: comment style, bracketing, and use proper MISSING test annotations
1 parent c700d00 commit 321df82

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

java/ql/src/semmle/code/java/frameworks/apache/Lang.qll

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class ApacheStrBuilderCallable extends Callable {
132132
}
133133

134134
/**
135-
* An Apache Commons Lang StrBuilder method that adds taint to the StrBuilder.
135+
* An Apache Commons Lang `StrBuilder` method that adds taint to the `StrBuilder`.
136136
*/
137137
private class ApacheStrBuilderTaintingMethod extends ApacheStrBuilderCallable,
138138
TaintPreservingCallable {
@@ -178,7 +178,7 @@ private class ApacheStrBuilderTaintingMethod extends ApacheStrBuilderCallable,
178178
}
179179

180180
/**
181-
* An Apache Commons Lang StrBuilder method that returns taint from the StrBuilder.
181+
* An Apache Commons Lang `StrBuilder` method that returns taint from the `StrBuilder`.
182182
*/
183183
private class ApacheStrBuilderTaintGetter extends ApacheStrBuilderCallable, TaintPreservingCallable {
184184
ApacheStrBuilderTaintGetter() {
@@ -196,20 +196,18 @@ private class ApacheStrBuilderTaintGetter extends ApacheStrBuilderCallable, Tain
196196
}
197197

198198
/**
199-
* An Apache Commons Lang StrBuilder method that writes taint from the StrBuilder to some parameter.
199+
* An Apache Commons Lang `StrBuilder` method that writes taint from the `StrBuilder` to some parameter.
200200
*/
201201
private class ApacheStrBuilderTaintWriter extends ApacheStrBuilderCallable, TaintPreservingCallable {
202202
ApacheStrBuilderTaintWriter() { this.hasName(["appendTo", "getChars"]) }
203203

204204
override predicate transfersTaint(int fromArg, int toArg) {
205205
fromArg = -1 and
206-
(
207-
// appendTo(Readable) and getChars(char[])
208-
if this.getNumberOfParameters() = 1
209-
then toArg = 0
210-
else
211-
// getChars(int, int, char[], int)
212-
toArg = 2
213-
)
206+
// appendTo(Readable) and getChars(char[])
207+
if this.getNumberOfParameters() = 1
208+
then toArg = 0
209+
else
210+
// getChars(int, int, char[], int)
211+
toArg = 2
214212
}
215213
}

java/ql/test/library-tests/frameworks/apache-commons-lang3/StrBuilderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ void test() throws Exception {
1818

1919
StrBuilder sb1 = new StrBuilder(); sb1.append(taint().toCharArray()); sink(sb1.toString()); // $hasTaintFlow=y
2020
StrBuilder sb2 = new StrBuilder(); sb2.append(taint().toCharArray(), 0, 0); sink(sb2.toString()); // $hasTaintFlow=y
21-
StrBuilder sb3 = new StrBuilder(); sb3.append(CharBuffer.wrap(taint().toCharArray())); sink(sb3.toString()); // BAD (but not detected because we don't model CharBuffer yet)
22-
StrBuilder sb4 = new StrBuilder(); sb4.append(CharBuffer.wrap(taint().toCharArray()), 0, 0); sink(sb4.toString()); // BAD (but not detected because we don't model CharBuffer yet)
21+
StrBuilder sb3 = new StrBuilder(); sb3.append(CharBuffer.wrap(taint().toCharArray())); sink(sb3.toString()); // $ MISSING: hasTaintFlow=y
22+
StrBuilder sb4 = new StrBuilder(); sb4.append(CharBuffer.wrap(taint().toCharArray()), 0, 0); sink(sb4.toString()); // $ MISSING: hasTaintFlow=y
2323
StrBuilder sb5 = new StrBuilder(); sb5.append((CharSequence)taint()); sink(sb5.toString()); // $hasTaintFlow=y
2424
StrBuilder sb6 = new StrBuilder(); sb6.append((CharSequence)taint(), 0, 0); sink(sb6.toString()); // $hasTaintFlow=y
2525
StrBuilder sb7 = new StrBuilder(); sb7.append((Object)taint()); sink(sb7.toString()); // $hasTaintFlow=y

java/ql/test/library-tests/frameworks/apache-commons-lang3/StrBuilderTextTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ void test() throws Exception {
1818

1919
StrBuilder sb1 = new StrBuilder(); sb1.append(taint().toCharArray()); sink(sb1.toString()); // $hasTaintFlow=y
2020
StrBuilder sb2 = new StrBuilder(); sb2.append(taint().toCharArray(), 0, 0); sink(sb2.toString()); // $hasTaintFlow=y
21-
StrBuilder sb3 = new StrBuilder(); sb3.append(CharBuffer.wrap(taint().toCharArray())); sink(sb3.toString()); // BAD (but not detected because we don't model CharBuffer yet)
22-
StrBuilder sb4 = new StrBuilder(); sb4.append(CharBuffer.wrap(taint().toCharArray()), 0, 0); sink(sb4.toString()); // BAD (but not detected because we don't model CharBuffer yet)
21+
StrBuilder sb3 = new StrBuilder(); sb3.append(CharBuffer.wrap(taint().toCharArray())); sink(sb3.toString()); // $ MISSING: hasTaintFlow=y
22+
StrBuilder sb4 = new StrBuilder(); sb4.append(CharBuffer.wrap(taint().toCharArray()), 0, 0); sink(sb4.toString()); // $ MISSING: hasTaintFlow=y
2323
StrBuilder sb5 = new StrBuilder(); sb5.append((CharSequence)taint()); sink(sb5.toString()); // $hasTaintFlow=y
2424
StrBuilder sb6 = new StrBuilder(); sb6.append((CharSequence)taint(), 0, 0); sink(sb6.toString()); // $hasTaintFlow=y
2525
StrBuilder sb7 = new StrBuilder(); sb7.append((Object)taint()); sink(sb7.toString()); // $hasTaintFlow=y

java/ql/test/library-tests/frameworks/apache-commons-lang3/TextStringBuilderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ void test() throws Exception {
1919

2020
TextStringBuilder sb1 = new TextStringBuilder(); sb1.append(taint().toCharArray()); sink(sb1.toString()); // $hasTaintFlow=y
2121
TextStringBuilder sb2 = new TextStringBuilder(); sb2.append(taint().toCharArray(), 0, 0); sink(sb2.toString()); // $hasTaintFlow=y
22-
TextStringBuilder sb3 = new TextStringBuilder(); sb3.append(CharBuffer.wrap(taint().toCharArray())); sink(sb3.toString()); // BAD (but not detected because we don't model CharBuffer yet)
23-
TextStringBuilder sb4 = new TextStringBuilder(); sb4.append(CharBuffer.wrap(taint().toCharArray()), 0, 0); sink(sb4.toString()); // BAD (but not detected because we don't model CharBuffer yet)
22+
TextStringBuilder sb3 = new TextStringBuilder(); sb3.append(CharBuffer.wrap(taint().toCharArray())); sink(sb3.toString()); // $ MISSING: hasTaintFlow=y
23+
TextStringBuilder sb4 = new TextStringBuilder(); sb4.append(CharBuffer.wrap(taint().toCharArray()), 0, 0); sink(sb4.toString()); // $ MISSING: hasTaintFlow=y
2424
TextStringBuilder sb5 = new TextStringBuilder(); sb5.append((CharSequence)taint()); sink(sb5.toString()); // $hasTaintFlow=y
2525
TextStringBuilder sb6 = new TextStringBuilder(); sb6.append((CharSequence)taint(), 0, 0); sink(sb6.toString()); // $hasTaintFlow=y
2626
TextStringBuilder sb7 = new TextStringBuilder(); sb7.append((Object)taint()); sink(sb7.toString()); // $hasTaintFlow=y

0 commit comments

Comments
 (0)