Skip to content

Commit 44f0411

Browse files
authored
Merge pull request github#6138 from owen-mc/java/model/apache-commons-collections
Model Apache commons collections MapUtils class and keyvalue package
2 parents 2d24387 + bad3271 commit 44f0411

35 files changed

+1816
-6
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm,codescanning
2+
* Added models for the package `keyvalue` and the classes `KeyValue` and `MapUtils` from Apache Commons Collections. This may lead to more results from any query using data-flow analysis where a relevant path uses one of these container types.

java/documentation/library-coverage/frameworks.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ Framework name,URL,Package prefixes
22
Java Standard Library,,java.*
33
Java extensions,,javax.*
44
Google Guava,https://guava.dev/,com.google.common.*
5+
Apache Commons Collections,https://commons.apache.org/proper/commons-collections/,org.apache.commons.collections org.apache.commons.collections4
56
Apache Commons IO,https://commons.apache.org/proper/commons-io/,org.apache.commons.io
67
Apache Commons Lang,https://commons.apache.org/proper/commons-lang/,org.apache.commons.lang3
78
Apache Commons Text,https://commons.apache.org/proper/commons-text/,org.apache.commons.text
89
Apache HttpComponents,https://hc.apache.org/,org.apache.hc.core5.* org.apache.http
910
Android,,android.*
10-
Spring,https://spring.io/,org.springframework.*
11+
Spring,https://spring.io/,org.springframework.*

java/ql/src/semmle/code/java/dataflow/ExternalFlow.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ private import FlowSummary
7878
private module Frameworks {
7979
private import internal.ContainerFlow
8080
private import semmle.code.java.frameworks.ApacheHttp
81+
private import semmle.code.java.frameworks.apache.Collections
8182
private import semmle.code.java.frameworks.apache.Lang
8283
private import semmle.code.java.frameworks.guava.Guava
8384
private import semmle.code.java.frameworks.jackson.JacksonSerializability

java/ql/src/semmle/code/java/dataflow/NullGuards.qll

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java
66
import SSA
77
private import semmle.code.java.controlflow.internal.GuardsLogic
8+
private import semmle.code.java.frameworks.apache.Collections
89
private import RangeUtils
910
private import IntegerGuards
1011

@@ -144,11 +145,11 @@ predicate nullCheckMethod(Method m, boolean branch, boolean isnull) {
144145
branch = false and
145146
isnull = false
146147
or
147-
(
148-
m.getDeclaringType().hasQualifiedName("org.apache.commons.collections4", "CollectionUtils") or
149-
m.getDeclaringType().hasQualifiedName("org.apache.commons.collections", "CollectionUtils")
150-
) and
151-
m.hasName("isNotEmpty") and
148+
m instanceof MethodApacheCollectionsIsEmpty and
149+
branch = false and
150+
isnull = false
151+
or
152+
m instanceof MethodApacheCollectionsIsNotEmpty and
152153
branch = true and
153154
isnull = false
154155
or

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

Lines changed: 264 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)