Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c4e9b1f
Model Spring `util`
May 31, 2021
92ebb63
Model Spring AntPath utils
Jun 24, 2021
739b142
Generate tests for Spring util
Jun 24, 2021
fb0e6bf
Fix tests for Spring util
Jun 24, 2021
60db9e1
Rename springframework-5.2.3 to 5.3.8
Jun 24, 2021
bddc88c
Add stubs for Spring util tests
Jun 24, 2021
4012076
fixup! Model spring `util`
Jun 28, 2021
240058b
fixup! Fix tests for Spring util
Jun 28, 2021
dec0123
Autoformat
smowton Jun 29, 2021
f7a4614
Add missing tests for AntPathMatcher's protected methods; fix models …
smowton Jun 29, 2021
659478c
Remove model for protected class
smowton Jun 29, 2021
5769f47
Add missing CollectionUtils model
smowton Jun 29, 2021
f67e9ae
Drop tests for protected inner classes
smowton Jun 29, 2021
b202110
Drop redundant model that can be inherited from java.util.Iterator
smowton Jun 29, 2021
0441098
Amend models of MultiValueMap.addAll overloads
smowton Jun 29, 2021
3d270bb
Drop models for stringifying functions
smowton Jun 29, 2021
1bd01a5
Update java/ql/test/library-tests/frameworks/spring/util/test.ql
aschackmull Jun 29, 2021
d6c4325
Import SpringUtil from ExternalFlow.qll
smowton Jun 29, 2021
60126b4
Clean up test
smowton Jun 29, 2021
71f6d59
Genericise test util functions
smowton Jun 29, 2021
916c7c5
Remove superfluous (Object) casts
smowton Jun 29, 2021
60179ce
Genericise MultiValueMaps; remove non-longer-needed casts
smowton Jun 29, 2021
9551321
Fix LinkedMultiValueMap models and make tests more realistic
smowton Jun 29, 2021
48d4493
Fix test indentation
smowton Jun 29, 2021
ad8bef5
Update java/ql/src/semmle/code/java/frameworks/spring/SpringUtil.qll
aschackmull Jun 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add stubs for Spring util tests
  • Loading branch information
Sauyon Lee committed Jun 28, 2021
commit bddc88c01006aa0235b7d6ea54490a2e0ea18e04
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/springframework-5.3.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Generated automatically from org.springframework.util.AntPathMatcher for testing purposes

package org.springframework.util;

import java.util.Comparator;
import java.util.Map;
import org.springframework.util.PathMatcher;

public class AntPathMatcher implements PathMatcher
{
final Map<String, AntPathMatcher.AntPathStringMatcher> stringMatcherCache = null;
protected AntPathMatcher.AntPathStringMatcher getStringMatcher(String p0){ return null; }
protected String[] tokenizePath(String p0){ return null; }
protected String[] tokenizePattern(String p0){ return null; }
protected boolean doMatch(String p0, String p1, boolean p2, Map<String, String> p3){ return false; }
public AntPathMatcher(){}
public AntPathMatcher(String p0){}
public Comparator<String> getPatternComparator(String p0){ return null; }
public Map<String, String> extractUriTemplateVariables(String p0, String p1){ return null; }
public String combine(String p0, String p1){ return null; }
public String extractPathWithinPattern(String p0, String p1){ return null; }
public boolean isPattern(String p0){ return false; }
public boolean match(String p0, String p1){ return false; }
public boolean matchStart(String p0, String p1){ return false; }
public static String DEFAULT_PATH_SEPARATOR = null;
public void setCachePatterns(boolean p0){}
public void setCaseSensitive(boolean p0){}
public void setPathSeparator(String p0){}
public void setTrimTokens(boolean p0){}
static class AntPathStringMatcher
{
protected AntPathStringMatcher() {}
public AntPathStringMatcher(String p0){}
public AntPathStringMatcher(String p0, boolean p1){}
public boolean matchStrings(String p0, Map<String, String> p1){ return false; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Generated automatically from org.springframework.util.AutoPopulatingList for testing purposes

package org.springframework.util;

import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

public class AutoPopulatingList<E> implements List<E>, Serializable
{
protected AutoPopulatingList() {}
public <T> T[] toArray(T[] p0){ return null; }
public AutoPopulatingList(AutoPopulatingList.ElementFactory<E> p0){}
public AutoPopulatingList(Class<? extends E> p0){}
public AutoPopulatingList(List<E> p0, AutoPopulatingList.ElementFactory<E> p1){}
public AutoPopulatingList(List<E> p0, Class<? extends E> p1){}
public E get(int p0){ return null; }
public E remove(int p0){ return null; }
public E set(int p0, E p1){ return null; }
public Iterator<E> iterator(){ return null; }
public List<E> subList(int p0, int p1){ return null; }
public ListIterator<E> listIterator(){ return null; }
public ListIterator<E> listIterator(int p0){ return null; }
public Object[] toArray(){ return null; }
public boolean add(E p0){ return false; }
public boolean addAll(Collection<? extends E> p0){ return false; }
public boolean addAll(int p0, Collection<? extends E> p1){ return false; }
public boolean contains(Object p0){ return false; }
public boolean containsAll(Collection<? extends Object> p0){ return false; }
public boolean equals(Object p0){ return false; }
public boolean isEmpty(){ return false; }
public boolean remove(Object p0){ return false; }
public boolean removeAll(Collection<? extends Object> p0){ return false; }
public boolean retainAll(Collection<? extends Object> p0){ return false; }
public int hashCode(){ return 0; }
public int indexOf(Object p0){ return 0; }
public int lastIndexOf(Object p0){ return 0; }
public int size(){ return 0; }
public void add(int p0, E p1){}
public void clear(){}
static public class ElementInstantiationException extends RuntimeException
{
protected ElementInstantiationException() {}
public ElementInstantiationException(String p0){}
public ElementInstantiationException(String p0, Throwable p1){}
}
static public interface ElementFactory<E>
{
E createElement(int p0);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Generated automatically from org.springframework.util.Base64Utils for testing purposes

package org.springframework.util;


abstract public class Base64Utils
{
public Base64Utils(){}
public static String encodeToString(byte[] p0){ return null; }
public static String encodeToUrlSafeString(byte[] p0){ return null; }
public static byte[] decode(byte[] p0){ return null; }
public static byte[] decodeFromString(String p0){ return null; }
public static byte[] decodeFromUrlSafeString(String p0){ return null; }
public static byte[] decodeUrlSafe(byte[] p0){ return null; }
public static byte[] encode(byte[] p0){ return null; }
public static byte[] encodeUrlSafe(byte[] p0){ return null; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Generated automatically from org.springframework.util.CollectionUtils for testing purposes

package org.springframework.util;

import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.springframework.util.MultiValueMap;

abstract public class CollectionUtils
{
public CollectionUtils(){}
public static <A, E extends A> A[] toArray(Enumeration<E> p0, A[] p1){ return null; }
public static <E> E findFirstMatch(Collection<? extends Object> p0, Collection<E> p1){ return null; }
public static <E> Iterator<E> toIterator(Enumeration<E> p0){ return null; }
public static <E> void mergeArrayIntoCollection(Object p0, Collection<E> p1){}
public static <K, V> HashMap<K, V> newHashMap(int p0){ return null; }
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap(int p0){ return null; }
public static <K, V> MultiValueMap<K, V> toMultiValueMap(Map<K, List<V>> p0){ return null; }
public static <K, V> MultiValueMap<K, V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> p0){ return null; }
public static <K, V> void mergePropertiesIntoMap(Properties p0, Map<K, V> p1){}
public static <T> T findValueOfType(Collection<? extends Object> p0, Class<T> p1){ return null; }
public static <T> T firstElement(List<T> p0){ return null; }
public static <T> T firstElement(Set<T> p0){ return null; }
public static <T> T lastElement(List<T> p0){ return null; }
public static <T> T lastElement(Set<T> p0){ return null; }
public static Class<? extends Object> findCommonElementType(Collection<? extends Object> p0){ return null; }
public static List<? extends Object> arrayToList(Object p0){ return null; }
public static Object findValueOfType(Collection<? extends Object> p0, Class<? extends Object>[] p1){ return null; }
public static boolean contains(Enumeration<? extends Object> p0, Object p1){ return false; }
public static boolean contains(Iterator<? extends Object> p0, Object p1){ return false; }
public static boolean containsAny(Collection<? extends Object> p0, Collection<? extends Object> p1){ return false; }
public static boolean containsInstance(Collection<? extends Object> p0, Object p1){ return false; }
public static boolean hasUniqueObject(Collection<? extends Object> p0){ return false; }
public static boolean isEmpty(Collection<? extends Object> p0){ return false; }
public static boolean isEmpty(Map<? extends Object, ? extends Object> p0){ return false; }
static float DEFAULT_LOAD_FACTOR = 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Generated automatically from org.springframework.util.CompositeIterator for testing purposes

package org.springframework.util;

import java.util.Iterator;

public class CompositeIterator<E> implements Iterator<E>
{
public CompositeIterator(){}
public E next(){ return null; }
public boolean hasNext(){ return false; }
public void add(Iterator<E> p0){}
public void remove(){}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Generated automatically from org.springframework.util.FastByteArrayOutputStream for testing purposes

package org.springframework.util;

import java.io.InputStream;
import java.io.OutputStream;

public class FastByteArrayOutputStream extends OutputStream
{
public FastByteArrayOutputStream(){}
public FastByteArrayOutputStream(int p0){}
public InputStream getInputStream(){ return null; }
public String toString(){ return null; }
public byte[] toByteArray(){ return null; }
public byte[] toByteArrayUnsafe(){ return null; }
public int size(){ return 0; }
public void close(){}
public void reset(){}
public void resize(int p0){}
public void write(byte[] p0, int p1, int p2){}
public void write(int p0){}
public void writeTo(OutputStream p0){}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Generated automatically from org.springframework.util.FileCopyUtils for testing purposes

package org.springframework.util;

import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;

abstract public class FileCopyUtils
{
public FileCopyUtils(){}
public static String copyToString(Reader p0){ return null; }
public static byte[] copyToByteArray(File p0){ return null; }
public static byte[] copyToByteArray(InputStream p0){ return null; }
public static int BUFFER_SIZE = 0;
public static int copy(File p0, File p1){ return 0; }
public static int copy(InputStream p0, OutputStream p1){ return 0; }
public static int copy(Reader p0, Writer p1){ return 0; }
public static void copy(String p0, Writer p1){}
public static void copy(byte[] p0, File p1){}
public static void copy(byte[] p0, OutputStream p1){}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Generated automatically from org.springframework.util.FileSystemUtils for testing purposes

package org.springframework.util;

import java.io.File;
import java.nio.file.Path;

abstract public class FileSystemUtils
{
public FileSystemUtils(){}
public static boolean deleteRecursively(File p0){ return false; }
public static boolean deleteRecursively(Path p0){ return false; }
public static void copyRecursively(File p0, File p1){}
public static void copyRecursively(Path p0, Path p1){}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Generated automatically from org.springframework.util.LinkedMultiValueMap for testing purposes

package org.springframework.util;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import org.springframework.util.MultiValueMapAdapter;

public class LinkedMultiValueMap<K, V> extends MultiValueMapAdapter<K, V> implements Cloneable, Serializable
{
public LinkedMultiValueMap(){}
public LinkedMultiValueMap(Map<K, List<V>> p0){}
public LinkedMultiValueMap(int p0){}
public LinkedMultiValueMap<K, V> clone(){ return null; }
public LinkedMultiValueMap<K, V> deepCopy(){ return null; }
}
Original file line number Diff line number Diff line change
@@ -1,96 +1,18 @@
/*
* Copyright 2002-2019 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.util.MultiValueMap for testing purposes

package org.springframework.util;

import java.util.List;
import java.util.Map;

import org.springframework.lang.Nullable;

/**
* Extension of the {@code Map} interface that stores multiple values.
*
* @author Arjen Poutsma
* @since 3.0
* @param <K> the key type
* @param <V> the value element type
*/
public interface MultiValueMap<K, V> extends Map<K, List<V>> {

/**
* Return the first value for the given key.
* @param key the key
* @return the first value for the specified key, or {@code null} if none
*/
@Nullable
V getFirst(K key);

/**
* Add the given single value to the current list of values for the given key.
* @param key the key
* @param value the value to be added
*/
void add(K key, @Nullable V value);

/**
* Add all the values of the given list to the current list of values for the given key.
* @param key they key
* @param values the values to be added
* @since 5.0
*/
void addAll(K key, List<? extends V> values);

/**
* Add all the values of the given {@code MultiValueMap} to the current values.
* @param values the values to be added
* @since 5.0
*/
void addAll(MultiValueMap<K, V> values);

/**
* {@link #add(Object, Object) Add} the given value, only when the map does not
* {@link #containsKey(Object) contain} the given key.
* @param key the key
* @param value the value to be added
* @since 5.2
*/
default void addIfAbsent(K key, @Nullable V value) {
if (!containsKey(key)) {
add(key, value);
}
}

/**
* Set the given single value under the given key.
* @param key the key
* @param value the value to set
*/
void set(K key, @Nullable V value);

/**
* Set the given values under.
* @param values the values.
*/
void setAll(Map<K, V> values);

/**
* Return a {@code Map} with the first values contained in this {@code MultiValueMap}.
* @return a single value representation of this map
*/
Map<K, V> toSingleValueMap();

public interface MultiValueMap<K, V> extends Map<K, List<V>>
{
Map<K, V> toSingleValueMap();
V getFirst(K p0);
default void addIfAbsent(K p0, V p1){}
void add(K p0, V p1);
void addAll(K p0, List<? extends V> p1);
void addAll(MultiValueMap<K, V> p0);
void set(K p0, V p1);
void setAll(Map<K, V> p0);
}
Loading