|
12 | 12 | import python |
13 | 13 | import FluentApiModel |
14 | 14 |
|
15 | | -string callName(AstNode call) { |
| 15 | +// Helper for pretty printer `configName`. |
| 16 | +// This is a consequence of missing pretty priting. |
| 17 | +// We do not want to evaluate our bespoke pretty printer |
| 18 | +// for all `DataFlow::Node`s so we define a sub class of interesting ones. |
| 19 | +class ProtocolConfiguration extends DataFlow::Node { |
| 20 | + ProtocolConfiguration() { |
| 21 | + unsafe_connection_creation_with_context(_, _, this, _) |
| 22 | + or |
| 23 | + unsafe_connection_creation_without_context(this, _) |
| 24 | + or |
| 25 | + unsafe_context_creation(this, _) |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +// Helper for pretty printer `callName`. |
| 30 | +// This is a consequence of missing pretty priting. |
| 31 | +// We do not want to evaluate our bespoke pretty printer |
| 32 | +// for all `AstNode`s so we define a sub class of interesting ones. |
| 33 | +// |
| 34 | +// Note that AstNode is abstract and AstNode_ is a library class, so |
| 35 | +// we have to extend @py_ast_node. |
| 36 | +class Namable extends @py_ast_node { |
| 37 | + Namable() { |
| 38 | + exists(ProtocolConfiguration protocolConfiguration | |
| 39 | + this = protocolConfiguration.asCfgNode().(CallNode).getFunction().getNode() |
| 40 | + ) |
| 41 | + or |
| 42 | + exists(Namable attr | this = attr.(Attribute).getObject()) |
| 43 | + } |
| 44 | + |
| 45 | + string toString() { result = "AstNode" } |
| 46 | +} |
| 47 | + |
| 48 | +string callName(Namable call) { |
16 | 49 | result = call.(Name).getId() |
17 | 50 | or |
18 | 51 | exists(Attribute a | a = call | result = callName(a.getObject()) + "." + a.getName()) |
19 | 52 | } |
20 | 53 |
|
21 | | -string configName(DataFlow::Node protocolConfiguration) { |
| 54 | +string configName(ProtocolConfiguration protocolConfiguration) { |
22 | 55 | result = |
23 | 56 | "call to " + callName(protocolConfiguration.asCfgNode().(CallNode).getFunction().getNode()) |
24 | 57 | or |
|
0 commit comments