Files
codeql/python/ql/lib/experimental/cryptography/utils/Utils.qll
Josh Brown ea63fc03d5 Merge pull request #14289 from microsoft/jb1/16-cryptography-models-libraries-and-queries-migration (#19)
16 cryptography models libraries and queries migration

Co-authored-by: Rasmus Wriedt Larsen <rasmuswl@github.com>
2023-10-04 13:34:09 -04:00

22 lines
778 B
Plaintext

import python
private import semmle.python.ApiGraphs
private import experimental.cryptography.utils.CallCfgNodeWithTarget
/**
* Gets an ultimate local source (not a source in a library)
*/
DataFlow::Node getUltimateSrcFromApiNode(API::Node n) {
result = n.getAValueReachingSink() and
(
// the result is a call to a library only
result instanceof CallCfgNodeWithTarget and
not result.(CallCfgNodeWithTarget).getTarget().asExpr().getEnclosingModule().inSource()
or
// the result is not a call, and not a function signataure or parameter
not result instanceof CallCfgNodeWithTarget and
not result instanceof DataFlow::ParameterNode and
not result.asExpr() instanceof FunctionExpr and
result.asExpr().getEnclosingModule().inSource()
)
}