Skip to content

Commit 7beab7c

Browse files
committed
Apply code review suggestions
1 parent a23b8a4 commit 7beab7c

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

java/ql/lib/semmle/code/java/security/FragmentInjection.qll

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,8 @@ class IsValidFragmentMethod extends Method {
2222
*/
2323
predicate isUnsafe() {
2424
this.getDeclaringType().(AndroidActivity).isExported() and
25-
forex(ReturnStmt retStmt, BooleanLiteral bool |
26-
retStmt.getEnclosingCallable() = this and
27-
// Using taint tracking to handle logical expressions, like
28-
// fragmentName.equals("safe") || true
29-
TaintTracking::localExprTaint(bool, retStmt.getResult())
30-
|
31-
bool.getBooleanValue() = true
25+
forex(ReturnStmt retStmt | retStmt.getEnclosingCallable() = this |
26+
retStmt.getResult().(BooleanLiteral).getBooleanValue() = true
3227
)
3328
}
3429
}
@@ -39,15 +34,11 @@ class IsValidFragmentMethod extends Method {
3934
*/
4035
abstract class FragmentInjectionSink extends DataFlow::Node { }
4136

42-
/**
43-
* A unit class for adding additional taint steps.
44-
*
45-
* Extend this class to add additional taint steps that should apply to `FragmentInjectionTaintConf`.
46-
*/
37+
/** An additional taint step for flows related to Fragment injection vulnerabilites. */
4738
class FragmentInjectionAdditionalTaintStep extends Unit {
4839
/**
4940
* Holds if the step from `node1` to `node2` should be considered a taint
50-
* step for the `FragmentInjectionTaintConf` configuration.
41+
* step in flows related to Fragment injection vulnerabilites.
5142
*/
5243
abstract predicate step(DataFlow::Node n1, DataFlow::Node n2);
5344
}

java/ql/test/query-tests/security/CWE-470/UnsafePreferenceActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ public class UnsafePreferenceActivity extends PreferenceActivity {
66

77
@Override
88
protected boolean isValidFragment(String fragmentName) { // $ hasPreferenceFragmentInjection
9-
return fragmentName.equals("MySafeClass") || true;
9+
return true;
1010
}
1111
}

0 commit comments

Comments
 (0)