Skip to content

Commit 69f329f

Browse files
author
Sebastian Bauersfeld
committed
Java: Add test cases for AbstractMessageSource.getMessage() methods
1 parent 39b6678 commit 69f329f

File tree

10 files changed

+120
-25
lines changed

10 files changed

+120
-25
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import org.springframework.context.support.StaticMessageSource;
2+
import java.util.Locale;
3+
4+
public class Test {
5+
6+
public static String code = "mycode";
7+
public static Locale locale = Locale.US;
8+
9+
String taint() { return "tainted"; }
10+
11+
void sink(Object o) {}
12+
13+
public void test() {
14+
StaticMessageSource sms = new StaticMessageSource();
15+
sms.addMessage(code, locale, "hello {0}");
16+
sink(sms.getMessage(code, new String[]{ taint() }, locale)); // $hasTaintFlow
17+
sink(sms.getMessage(code, new String[]{ taint() }, "", locale)); // $hasTaintFlow
18+
sink(sms.getMessage(code, null, taint(), locale)); // $hasTaintFlow
19+
}
20+
}

java/ql/test/library-tests/frameworks/spring/context/flow.expected

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import java
2+
import TestUtilities.InlineFlowTest
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/springframework-5.3.8:${testdir}/../../../../stubs/apache-commons-logging-1.2/

java/ql/test/stubs/springframework-5.3.8/org/springframework/context/HierarchicalMessageSource.java

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/ql/test/stubs/springframework-5.3.8/org/springframework/context/MessageSource.java

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/ql/test/stubs/springframework-5.3.8/org/springframework/context/MessageSourceResolvable.java

Lines changed: 6 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/ql/test/stubs/springframework-5.3.8/org/springframework/context/support/AbstractMessageSource.java

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/ql/test/stubs/springframework-5.3.8/org/springframework/context/support/MessageSourceSupport.java

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

java/ql/test/stubs/springframework-5.3.8/org/springframework/context/support/StaticMessageSource.java

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)