mirror of
https://github.com/github/codeql.git
synced 2026-04-25 16:55:19 +02:00
Java: Add test cases for AbstractMessageSource.getMessage() methods
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import org.springframework.context.support.StaticMessageSource;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Test {
|
||||
|
||||
public static String code = "mycode";
|
||||
public static Locale locale = Locale.US;
|
||||
|
||||
String taint() { return "tainted"; }
|
||||
|
||||
void sink(Object o) {}
|
||||
|
||||
public void test() {
|
||||
StaticMessageSource sms = new StaticMessageSource();
|
||||
sms.addMessage(code, locale, "hello {0}");
|
||||
sink(sms.getMessage(code, new String[]{ taint() }, locale)); // $hasTaintFlow
|
||||
sink(sms.getMessage(code, new String[]{ taint() }, "", locale)); // $hasTaintFlow
|
||||
sink(sms.getMessage(code, null, taint(), locale)); // $hasTaintFlow
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
import java
|
||||
import TestUtilities.InlineFlowTest
|
||||
@@ -0,0 +1 @@
|
||||
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/springframework-5.3.8:${testdir}/../../../../stubs/apache-commons-logging-1.2/
|
||||
11
java/ql/test/stubs/springframework-5.3.8/org/springframework/context/HierarchicalMessageSource.java
generated
Normal file
11
java/ql/test/stubs/springframework-5.3.8/org/springframework/context/HierarchicalMessageSource.java
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
// Generated automatically from org.springframework.context.HierarchicalMessageSource for testing purposes
|
||||
|
||||
package org.springframework.context;
|
||||
|
||||
import org.springframework.context.MessageSource;
|
||||
|
||||
public interface HierarchicalMessageSource extends MessageSource
|
||||
{
|
||||
MessageSource getParentMessageSource();
|
||||
void setParentMessageSource(MessageSource p0);
|
||||
}
|
||||
@@ -1,3 +1,13 @@
|
||||
// Generated automatically from org.springframework.context.MessageSource for testing purposes
|
||||
|
||||
package org.springframework.context;
|
||||
|
||||
public interface MessageSource {}
|
||||
import java.util.Locale;
|
||||
import org.springframework.context.MessageSourceResolvable;
|
||||
|
||||
public interface MessageSource
|
||||
{
|
||||
String getMessage(MessageSourceResolvable p0, Locale p1);
|
||||
String getMessage(String p0, Object[] p1, Locale p2);
|
||||
String getMessage(String p0, Object[] p1, String p2, Locale p3);
|
||||
}
|
||||
|
||||
@@ -1,29 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Generated automatically from org.springframework.context.MessageSourceResolvable for testing purposes
|
||||
|
||||
package org.springframework.context;
|
||||
|
||||
public interface MessageSourceResolvable {
|
||||
String[] getCodes();
|
||||
|
||||
default Object[] getArguments() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default String getDefaultMessage() {
|
||||
return null;
|
||||
}
|
||||
public interface MessageSourceResolvable
|
||||
{
|
||||
String[] getCodes();
|
||||
default Object[] getArguments(){ return null; }
|
||||
default String getDefaultMessage(){ return null; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// Generated automatically from org.springframework.context.support.AbstractMessageSource for testing purposes
|
||||
|
||||
package org.springframework.context.support;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import org.springframework.context.HierarchicalMessageSource;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.MessageSourceResolvable;
|
||||
import org.springframework.context.support.MessageSourceSupport;
|
||||
|
||||
abstract public class AbstractMessageSource extends MessageSourceSupport implements HierarchicalMessageSource
|
||||
{
|
||||
protected Object[] resolveArguments(Object[] p0, Locale p1){ return null; }
|
||||
protected Properties getCommonMessages(){ return null; }
|
||||
protected String getDefaultMessage(MessageSourceResolvable p0, Locale p1){ return null; }
|
||||
protected String getDefaultMessage(String p0){ return null; }
|
||||
protected String getMessageFromParent(String p0, Object[] p1, Locale p2){ return null; }
|
||||
protected String getMessageInternal(String p0, Object[] p1, Locale p2){ return null; }
|
||||
protected String resolveCodeWithoutArguments(String p0, Locale p1){ return null; }
|
||||
protected abstract MessageFormat resolveCode(String p0, Locale p1);
|
||||
protected boolean isUseCodeAsDefaultMessage(){ return false; }
|
||||
public AbstractMessageSource(){}
|
||||
public MessageSource getParentMessageSource(){ return null; }
|
||||
public final String getMessage(MessageSourceResolvable p0, Locale p1){ return null; }
|
||||
public final String getMessage(String p0, Object[] p1, Locale p2){ return null; }
|
||||
public final String getMessage(String p0, Object[] p1, String p2, Locale p3){ return null; }
|
||||
public void setCommonMessages(Properties p0){}
|
||||
public void setParentMessageSource(MessageSource p0){}
|
||||
public void setUseCodeAsDefaultMessage(boolean p0){}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Generated automatically from org.springframework.context.support.MessageSourceSupport for testing purposes
|
||||
|
||||
package org.springframework.context.support;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
abstract public class MessageSourceSupport
|
||||
{
|
||||
protected MessageFormat createMessageFormat(String p0, Locale p1){ return null; }
|
||||
protected Object[] resolveArguments(Object[] p0, Locale p1){ return null; }
|
||||
protected String formatMessage(String p0, Object[] p1, Locale p2){ return null; }
|
||||
protected String renderDefaultMessage(String p0, Object[] p1, Locale p2){ return null; }
|
||||
protected boolean isAlwaysUseMessageFormat(){ return false; }
|
||||
protected final Log logger = null;
|
||||
public MessageSourceSupport(){}
|
||||
public void setAlwaysUseMessageFormat(boolean p0){}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// Generated automatically from org.springframework.context.support.StaticMessageSource for testing purposes
|
||||
|
||||
package org.springframework.context.support;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.springframework.context.support.AbstractMessageSource;
|
||||
|
||||
public class StaticMessageSource extends AbstractMessageSource
|
||||
{
|
||||
protected MessageFormat resolveCode(String p0, Locale p1){ return null; }
|
||||
protected String resolveCodeWithoutArguments(String p0, Locale p1){ return null; }
|
||||
public StaticMessageSource(){}
|
||||
public String toString(){ return null; }
|
||||
public void addMessage(String p0, Locale p1, String p2){}
|
||||
public void addMessages(Map<String, String> p0, Locale p1){}
|
||||
}
|
||||
Reference in New Issue
Block a user