mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
Refactor SensitiveKeyboardCacheQuery
This commit is contained in:
@@ -91,16 +91,14 @@ private predicate inputTypeFieldNotCached(Field f) {
|
||||
}
|
||||
|
||||
/** Configuration that finds uses of `setInputType` for non cached fields. */
|
||||
private class GoodInputTypeConf extends DataFlow::Configuration {
|
||||
GoodInputTypeConf() { this = "GoodInputTypeConf" }
|
||||
|
||||
override predicate isSource(DataFlow::Node node) {
|
||||
private module GoodInputTypeConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node node) {
|
||||
inputTypeFieldNotCached(node.asExpr().(FieldAccess).getField())
|
||||
}
|
||||
|
||||
override predicate isSink(DataFlow::Node node) { node.asExpr() = setInputTypeForId(_) }
|
||||
predicate isSink(DataFlow::Node node) { node.asExpr() = setInputTypeForId(_) }
|
||||
|
||||
override predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
|
||||
exists(OrBitwiseExpr bitOr |
|
||||
node1.asExpr() = bitOr.getAChildExpr() and
|
||||
node2.asExpr() = bitOr
|
||||
@@ -108,6 +106,8 @@ private class GoodInputTypeConf extends DataFlow::Configuration {
|
||||
}
|
||||
}
|
||||
|
||||
private module GoodInputTypeFlow = DataFlow::Make<GoodInputTypeConfig>;
|
||||
|
||||
/** Gets a regex indicating that an input field may contain sensitive data. */
|
||||
private string getInputSensitiveInfoRegex() {
|
||||
result =
|
||||
@@ -130,8 +130,8 @@ AndroidEditableXmlElement getASensitiveCachedInput() {
|
||||
result.getId().regexpMatch(getInputSensitiveInfoRegex()) and
|
||||
(
|
||||
not inputTypeNotCached(result.getInputType()) and
|
||||
not exists(GoodInputTypeConf conf, DataFlow::Node sink |
|
||||
conf.hasFlowTo(sink) and
|
||||
not exists(DataFlow::Node sink |
|
||||
GoodInputTypeFlow::hasFlowTo(sink) and
|
||||
sink.asExpr() = setInputTypeForId(result.getId())
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user