mirror of
https://github.com/github/codeql.git
synced 2026-02-28 21:03:50 +01:00
C++/C#/Java/JavaScript/Python: Autoformat set literals.
This commit is contained in:
@@ -56,10 +56,12 @@ private class StringTaintPreservingMethod extends TaintPreservingCallable {
|
||||
StringTaintPreservingMethod() {
|
||||
this.getDeclaringType() instanceof TypeString and
|
||||
this
|
||||
.hasName(["concat", "copyValueOf", "endsWith", "format", "formatted", "getBytes", "indent",
|
||||
"intern", "join", "repeat", "split", "strip", "stripIndent", "stripLeading",
|
||||
"stripTrailing", "substring", "toCharArray", "toLowerCase", "toString", "toUpperCase",
|
||||
"trim"])
|
||||
.hasName([
|
||||
"concat", "copyValueOf", "endsWith", "format", "formatted", "getBytes", "indent",
|
||||
"intern", "join", "repeat", "split", "strip", "stripIndent", "stripLeading",
|
||||
"stripTrailing", "substring", "toCharArray", "toLowerCase", "toString", "toUpperCase",
|
||||
"trim"
|
||||
])
|
||||
}
|
||||
|
||||
override predicate returnsTaintFrom(int arg) {
|
||||
|
||||
@@ -112,8 +112,10 @@ private predicate taintPreservingQualifierToMethod(Method m) {
|
||||
// java.util.Map
|
||||
m
|
||||
.(MapMethod)
|
||||
.hasName(["computeIfAbsent", "entrySet", "get", "getOrDefault", "put", "putIfAbsent",
|
||||
"remove", "replace", "values"])
|
||||
.hasName([
|
||||
"computeIfAbsent", "entrySet", "get", "getOrDefault", "put", "putIfAbsent", "remove",
|
||||
"replace", "values"
|
||||
])
|
||||
or
|
||||
// java.util.Collection
|
||||
m.(CollectionMethod).hasName(["parallelStream", "stream", "toArray"])
|
||||
@@ -138,8 +140,10 @@ private predicate taintPreservingQualifierToMethod(Method m) {
|
||||
// java.util.Deque
|
||||
m
|
||||
.(CollectionMethod)
|
||||
.hasName(["getFirst", "getLast", "peekFirst", "peekLast", "pollFirst", "pollLast",
|
||||
"removeFirst", "removeLast"])
|
||||
.hasName([
|
||||
"getFirst", "getLast", "peekFirst", "peekLast", "pollFirst", "pollLast", "removeFirst",
|
||||
"removeLast"
|
||||
])
|
||||
or
|
||||
// java.util.concurrent.BlockingQueue
|
||||
// covered by Queue: poll(long, TimeUnit)
|
||||
@@ -166,8 +170,10 @@ private predicate taintPreservingQualifierToMethod(Method m) {
|
||||
// covered by SortedMap: headMap(K, boolean), subMap(K, boolean, K, boolean), tailMap(K, boolean)
|
||||
m
|
||||
.(MapMethod)
|
||||
.hasName(["ceilingEntry", "descendingMap", "firstEntry", "floorEntry", "higherEntry",
|
||||
"lastEntry", "lowerEntry", "pollFirstEntry", "pollLastEntry"])
|
||||
.hasName([
|
||||
"ceilingEntry", "descendingMap", "firstEntry", "floorEntry", "higherEntry", "lastEntry",
|
||||
"lowerEntry", "pollFirstEntry", "pollLastEntry"
|
||||
])
|
||||
or
|
||||
// java.util.Dictionary
|
||||
m
|
||||
@@ -273,15 +279,17 @@ private predicate taintPreservingArgumentToMethod(Method method, int arg) {
|
||||
method.getDeclaringType().hasQualifiedName("java.util", "Collections") and
|
||||
(
|
||||
method
|
||||
.hasName(["checkedCollection", "checkedList", "checkedMap", "checkedNavigableMap",
|
||||
"checkedNavigableSet", "checkedSet", "checkedSortedMap", "checkedSortedSet",
|
||||
"enumeration", "list", "max", "min", "singleton", "singletonList",
|
||||
"synchronizedCollection", "synchronizedList", "synchronizedMap",
|
||||
"synchronizedNavigableMap", "synchronizedNavigableSet", "synchronizedSet",
|
||||
"synchronizedSortedMap", "synchronizedSortedSet", "unmodifiableCollection",
|
||||
"unmodifiableList", "unmodifiableMap", "unmodifiableNavigableMap",
|
||||
"unmodifiableNavigableSet", "unmodifiableSet", "unmodifiableSortedMap",
|
||||
"unmodifiableSortedSet"]) and
|
||||
.hasName([
|
||||
"checkedCollection", "checkedList", "checkedMap", "checkedNavigableMap",
|
||||
"checkedNavigableSet", "checkedSet", "checkedSortedMap", "checkedSortedSet",
|
||||
"enumeration", "list", "max", "min", "singleton", "singletonList",
|
||||
"synchronizedCollection", "synchronizedList", "synchronizedMap",
|
||||
"synchronizedNavigableMap", "synchronizedNavigableSet", "synchronizedSet",
|
||||
"synchronizedSortedMap", "synchronizedSortedSet", "unmodifiableCollection",
|
||||
"unmodifiableList", "unmodifiableMap", "unmodifiableNavigableMap",
|
||||
"unmodifiableNavigableSet", "unmodifiableSet", "unmodifiableSortedMap",
|
||||
"unmodifiableSortedSet"
|
||||
]) and
|
||||
arg = 0
|
||||
or
|
||||
method.hasName(["nCopies", "singletonMap"]) and arg = 1
|
||||
|
||||
@@ -264,8 +264,9 @@ private class QueryBuilderAppendMethod extends TaintPreservingCallable {
|
||||
// appendWhereStandalone(CharSequence inWhere)
|
||||
// static appendColumns(StringBuilder s, String[] columns)
|
||||
this
|
||||
.hasName(["setProjectionMap", "setTables", "appendWhere", "appendWhereStandalone",
|
||||
"appendColumns"])
|
||||
.hasName([
|
||||
"setProjectionMap", "setTables", "appendWhere", "appendWhereStandalone", "appendColumns"
|
||||
])
|
||||
}
|
||||
|
||||
override predicate transfersTaint(int src, int sink) {
|
||||
|
||||
@@ -23,8 +23,10 @@ private predicate fileRead(VarAccess fileAccess, Expr fileReadingExpr) {
|
||||
filesMethod.getDeclaringType().hasQualifiedName("java.nio.file", "Files") and
|
||||
fileAccess = ma.getArgument(0) and
|
||||
filesMethod
|
||||
.hasName(["readAllBytes", "readAllLines", "readString", "lines", "newBufferedReader",
|
||||
"newInputStream", "newByteChannel"])
|
||||
.hasName([
|
||||
"readAllBytes", "readAllLines", "readString", "lines", "newBufferedReader",
|
||||
"newInputStream", "newByteChannel"
|
||||
])
|
||||
)
|
||||
)
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user