Skip to content

Commit 8a65dd2

Browse files
committed
Java: Address review comments
1 parent 5a96ee1 commit 8a65dd2

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

java/ql/src/Security/CWE/CWE-020/ExternalAPIsUsedWithUntrustedData.qhelp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<qhelp>
55
<overview>
66
<p>Using unsanitized untrusted data in an external API can cause a variety of security issues. This query reports
7-
all external APIs which are used with untrusted data, along with how frequently the API is used, and how many
7+
all external APIs that are used with untrusted data, along with how frequently the API is used, and how many
88
unique sources of untrusted data flow this API. This query is designed primarily to help identify which APIs
99
may be relevant for security analysis of this application.</p>
1010

11-
<p>An external API is defined as a method call to a method which is not defined in the source code, not overridden
11+
<p>An external API is defined as a method call to a method that is not defined in the source code, not overridden
1212
in the source code, and is not modeled as a taint step in the default taint library. External APIs may be from the
1313
Java standard library, third party dependencies or from internal dependencies. The query will report the method
1414
signature with a fully qualified name, along with either <code>[param x]</code>, where <code>x</code> indicates the

java/ql/src/Security/CWE/CWE-020/ExternalAPIsUsedWithUntrustedData.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* @name Frequency counts for external APIs which are used with untrusted data
3-
* @description This reports the external APIs which are used with untrusted data, along with how
2+
* @name Frequency counts for external APIs that are used with untrusted data
3+
* @description This reports the external APIs that are used with untrusted data, along with how
44
* frequently the API is called, and how many unique sources of untrusted data flow
55
* to it.
66
* @id java/count-untrusted-data-external-api

java/ql/src/Security/CWE/CWE-020/UntrustedDataToExternalAPI.qhelp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ all uses of external APIs with untrusted data for review. This query has a delib
88
and is designed to help security reviews for the application, as well as helping identify external APIs that
99
should be modeled as either taint steps, or sinks for specific problems.</p>
1010

11-
<p>An external API is defined as a method call to a method which is not defined in the source code, not overridden
11+
<p>An external API is defined as a method call to a method that is not defined in the source code, not overridden
1212
in the source code, and is not modeled as a taint step in the default taint library. External APIs may be from the
1313
Java standard library, third party dependencies or from internal dependencies. The query will report uses of
1414
untrusted data in either the qualifier or as one of the arguments of external APIs.</p>
@@ -28,7 +28,7 @@ untrusted data in either the qualifier or as one of the arguments of external AP
2828
</ul>
2929

3030
<p>Otherwise, the result is likely uninteresting. Custom versions of this query can extend the <code>SafeExternalAPIMethod</code>
31-
class to exclude known safe external APIs from future analysis.
31+
class to exclude known safe external APIs from future analysis.</p>
3232

3333
</recommendation>
3434
<example>

java/ql/src/semmle/code/java/security/ExternalAPIs.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import semmle.code.java.dataflow.TaintTracking
99

1010
module ExternalAPIs {
1111
/**
12-
* A `Method` which is considered a "safe" external API from a security perspective.
12+
* A `Method` that is considered a "safe" external API from a security perspective.
1313
*/
1414
abstract class SafeExternalAPIMethod extends Method { }
1515

@@ -24,7 +24,7 @@ module ExternalAPIs {
2424
or
2525
getQualifiedName() = "Objects.equals"
2626
or
27-
getDeclaringType().getQualifiedName() = "java.lang.String" and getName() = "equals"
27+
getDeclaringType() instanceof TypeString and getName() = "equals"
2828
or
2929
getDeclaringType().hasQualifiedName("com.google.common.base", "Preconditions")
3030
or
@@ -76,7 +76,7 @@ module ExternalAPIs {
7676
m.getASourceOverriddenMethod() = call.getCallee().getSourceDeclaration() and
7777
m.fromSource()
7878
) and
79-
// Not already modelled as a taint step
79+
// Not already modeled as a taint step
8080
not exists(DataFlow::Node next | TaintTracking::localTaintStep(this, next)) and
8181
// Not a call to a known safe external API
8282
not call.getCallee() instanceof SafeExternalAPIMethod

0 commit comments

Comments
 (0)