Apply code review suggestions

This commit is contained in:
Tony Torralba
2022-01-17 12:02:27 +01:00
parent a23b8a4a43
commit 7beab7cb59
2 changed files with 5 additions and 14 deletions

View File

@@ -22,13 +22,8 @@ class IsValidFragmentMethod extends Method {
*/
predicate isUnsafe() {
this.getDeclaringType().(AndroidActivity).isExported() and
forex(ReturnStmt retStmt, BooleanLiteral bool |
retStmt.getEnclosingCallable() = this and
// Using taint tracking to handle logical expressions, like
// fragmentName.equals("safe") || true
TaintTracking::localExprTaint(bool, retStmt.getResult())
|
bool.getBooleanValue() = true
forex(ReturnStmt retStmt | retStmt.getEnclosingCallable() = this |
retStmt.getResult().(BooleanLiteral).getBooleanValue() = true
)
}
}
@@ -39,15 +34,11 @@ class IsValidFragmentMethod extends Method {
*/
abstract class FragmentInjectionSink extends DataFlow::Node { }
/**
* A unit class for adding additional taint steps.
*
* Extend this class to add additional taint steps that should apply to `FragmentInjectionTaintConf`.
*/
/** An additional taint step for flows related to Fragment injection vulnerabilites. */
class FragmentInjectionAdditionalTaintStep extends Unit {
/**
* Holds if the step from `node1` to `node2` should be considered a taint
* step for the `FragmentInjectionTaintConf` configuration.
* step in flows related to Fragment injection vulnerabilites.
*/
abstract predicate step(DataFlow::Node n1, DataFlow::Node n2);
}

View File

@@ -6,6 +6,6 @@ public class UnsafePreferenceActivity extends PreferenceActivity {
@Override
protected boolean isValidFragment(String fragmentName) { // $ hasPreferenceFragmentInjection
return fragmentName.equals("MySafeClass") || true;
return true;
}
}