Python: Use Value API for sensitive data analysis.

This commit is contained in:
Mark Shannon
2019-08-22 11:19:43 +01:00
parent 81c65cd37c
commit 6cd0087d9d
5 changed files with 42 additions and 6 deletions

View File

@@ -398,8 +398,11 @@ class AbsentModuleAttributeObjectInternal extends ObjectInternal, TAbsentModuleA
override predicate subscriptUnknown() { any() }
/* We know what this is called, but not its innate name */
override string getName() { none() }
/* We know what this is called, but not its innate name.
* However, if we are looking for things by name, this is a reasonable approximation */
override string getName() {
this = TAbsentModuleAttribute(_, result)
}
override predicate contextSensitiveCallee() { none() }

View File

@@ -110,12 +110,12 @@ module SensitiveData {
override string repr() { result = "a certificate or key" }
}
private SensitiveData fromFunction(FunctionObject f) {
result = HeuristicNames::getSensitiveDataForName(f.getName())
private SensitiveData fromFunction(Value func) {
result = HeuristicNames::getSensitiveDataForName(func.getName())
or
// This is particularly to pick up methods with an argument like "password", which
// may indicate a lookup.
exists(string name | name = f.getFunction().getAnArg().asName().getId() |
exists(string name | name = func.(PythonFunctionValue).getScope().getAnArg().asName().getId() |
result = HeuristicNames::getSensitiveDataForName(name)
)
}
@@ -131,7 +131,7 @@ module SensitiveData {
SensitiveData data;
SensitiveCallSource() {
exists(FunctionObject callee |
exists(Value callee |
callee.getACall() = this |
data = fromFunction(callee)
)