Skip to content

Commit f8fd2ea

Browse files
committed
Add qldoc and autoformat query
1 parent c89ebee commit f8fd2ea

File tree

3 files changed

+49
-24
lines changed

3 files changed

+49
-24
lines changed

java/ql/src/experimental/Security/CWE/CWE-532/SensitiveInfoLog.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ import PathGraph
1616
/**
1717
* Gets a regular expression for matching names of variables that indicate the value being held may contain sensitive information
1818
*/
19-
private string getACredentialRegex() {
20-
result = "(?i)(.*username|url).*"
21-
}
19+
private string getACredentialRegex() { result = "(?i)(.*username|url).*" }
2220

2321
/** Variable keeps sensitive information judging by its name * */
2422
class CredentialExpr extends Expr {
2523
CredentialExpr() {
26-
exists(Variable v | this = v.getAnAccess() | v.getName().regexpMatch([getCommonSensitiveInfoRegex(), getACredentialRegex()]))
24+
exists(Variable v | this = v.getAnAccess() |
25+
v.getName().regexpMatch([getCommonSensitiveInfoRegex(), getACredentialRegex()])
26+
)
2727
}
2828
}
2929

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,50 @@
1-
<!DOCTYPE qhelp PUBLIC
2-
"-//Semmle//qhelp//EN"
3-
"qhelp.dtd">
1+
<!DOCTYPE qhelp PUBLIC "-//Semmle//qhelp//EN" "qhelp.dtd">
42
<qhelp>
53

6-
<overview>
7-
<p>Broadcast intents in an Android application are visible to all applications installed on the same mobile device, exposing all sensitive information they contain.</p>
8-
<p>Broadcasts are vulnerable to passive eavesdropping or active denial of service attacks when an intent is broadcast without specifying any receiver permission or receiver application.</p>
9-
</overview>
4+
<overview>
5+
<p>Broadcast intents in an Android application are visible to all applications installed on the same mobile device, exposing all sensitive information they contain.</p>
6+
<p>Broadcasts are vulnerable to passive eavesdropping or active denial of service attacks when an intent is broadcast without specifying any receiver permission or receiver application.</p>
7+
</overview>
108

11-
<recommendation>
12-
<p>Specify a receiver permission or application when broadcasting intents, or switch to <code>LocalBroadcastManager</code> or the latest <code>LiveData</code> library.</p>
13-
</recommendation>
9+
<recommendation>
10+
<p>
11+
Specify a receiver permission or application when broadcasting intents, or switch to
12+
<code>LocalBroadcastManager</code>
13+
or the latest
14+
<code>LiveData</code>
15+
library.
16+
</p>
17+
</recommendation>
1418

15-
<example>
16-
<p>The following example shows two ways of broadcasting intents. In the 'BAD' case, no "receiver permission" is specified. In the 'GOOD' case, "receiver permission" or "receiver application" is specified.</p>
17-
<sample src="SensitiveBroadcast.java" />
18-
</example>
19+
<example>
20+
<p>The following example shows two ways of broadcasting intents. In the 'BAD' case, no "receiver permission" is specified. In the 'GOOD' case, "receiver permission" or "receiver application" is specified.</p>
21+
<sample src="SensitiveBroadcast.java" />
22+
</example>
1923

20-
<references>
21-
<li>
22-
<a href="https://cwe.mitre.org/data/definitions/927.html">CWE-927: Use of Implicit Intent for Sensitive Communication</a>
23-
</li>
24-
</references>
24+
<references>
25+
<li>
26+
CWE:
27+
<a href="https://cwe.mitre.org/data/definitions/927.html">CWE-927: Use of Implicit Intent for Sensitive Communication</a>
28+
</li>
29+
<li>
30+
Android Developers:
31+
<a href="https://developer.android.com/guide/components/broadcasts">Security considerations and best practices for sending and receiving broadcasts</a>
32+
</li>
33+
<li>
34+
sonarsource:
35+
<a href="https://rules.sonarsource.com/java/type/Security%20Hotspot/RSPEC-5320">Broadcasting intents is security-sensitive</a>
36+
</li>
37+
<li>
38+
Android Developer Fundamentals:
39+
<a href="https://google-developer-training.github.io/android-developer-fundamentals-course-concepts-v2/unit-3-working-in-the-background/lesson-7-background-tasks/7-3-c-broadcasts/7-3-c-broadcasts.html">Restricting broadcasts</a>
40+
</li>
41+
<li>
42+
Carnegie Mellon University:
43+
<a href="https://wiki.sei.cmu.edu/confluence/display/android/DRD03-J.+Do+not+broadcast+sensitive+information+using+an+implicit+intent">DRD03-J. Do not broadcast sensitive information using an implicit intent</a>
44+
</li>
45+
<li>
46+
Android Developers:
47+
<a href="https://developer.android.com/topic/libraries/architecture/livedata">Android LiveData Overview</a>
48+
</li>
49+
</references>
2550
</qhelp>

java/ql/src/experimental/Security/CWE/CWE-927/SensitiveBroadcast.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class SensitiveInfoExpr extends Expr {
5252
}
5353

5454
/**
55-
* A method access of the `context.sendBroadcast` family.
55+
* A method access of the `Context.sendBroadcast` family.
5656
*/
5757
class SendBroadcastMethodAccess extends MethodAccess {
5858
SendBroadcastMethodAccess() {

0 commit comments

Comments
 (0)