Skip to content

Commit f93d4a0

Browse files
committed
fix Fabric query library
1 parent 3a52cd1 commit f93d4a0

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

python/ql/lib/semmle/python/frameworks/Fabric.qll

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ module FabricV2 {
100100
* calls, or a special parameter that will be set when functions are called by an external
101101
* library.
102102
*/
103-
abstract class Instance extends DataFlow::LocalSourceNode { }
103+
abstract class Instance extends API::Node {
104+
override string toString() { result = "a fabric connection instance" }
105+
}
104106

105107
/**
106108
* A reference to the `fabric.connection.Connection` class.
@@ -111,7 +113,7 @@ module FabricV2 {
111113
[
112114
fabric().getMember("Connection"), connection().getMember("Connection"),
113115
ModelOutput::getATypeNode("fabric.connection.Connection~Subclass").getASubclass*()
114-
].getACall()
116+
].getReturn()
115117
}
116118
}
117119

@@ -125,7 +127,7 @@ module FabricV2 {
125127
* - https://docs.fabfile.org/en/2.5/api/connection.html#fabric.connection.Connection.local
126128
*/
127129
API::CallNode instanceRunMethods() {
128-
result = any(Instance is).getAMethodCall(["run", "sudo", "local"])
130+
result = any(Instance is).getMember(["run", "sudo", "local"]).getACall()
129131
}
130132
}
131133
}
@@ -155,7 +157,11 @@ module FabricV2 {
155157
*/
156158
private class FabricConnectionProxyCommand extends SystemCommandExecution::Range, API::CallNode {
157159
FabricConnectionProxyCommand() {
158-
this instanceof Fabric::Connection::ConnectionClass::Instance and
160+
this =
161+
[
162+
fabric().getMember("Connection"), connection().getMember("Connection"),
163+
ModelOutput::getATypeNode("fabric.connection.Connection~Subclass").getASubclass*()
164+
].getACall() and
159165
// we want to make sure that the connection is established otherwise the command of proxy_command won't run.
160166
exists(
161167
this.getAMethodCall([
@@ -185,14 +191,10 @@ module FabricV2 {
185191
API::Node test() { result in [tasks().getMember("task"), fabric().getMember("task")] }
186192
}
187193

188-
class FabricTaskFirstParamConnectionInstance extends Fabric::Connection::ConnectionClass::Instance,
189-
DataFlow::ParameterNode
194+
class FabricTaskFirstParamConnectionInstance extends Fabric::Connection::ConnectionClass::Instance
190195
{
191196
FabricTaskFirstParamConnectionInstance() {
192-
exists(Function func |
193-
func.getADecorator() = Fabric::Tasks::task().getAValueReachableFromSource().asExpr() and
194-
this.getParameter() = func.getArg(0)
195-
)
197+
this = Fabric::Tasks::task().getParameter(0).getParameter(0)
196198
}
197199
}
198200

python/ql/src/meta/ClassHierarchy/Find.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class FabricConnection extends FindSubclassesSpec {
328328
FabricConnection() { this = "fabric.connection.Connection~Subclass" }
329329

330330
override API::Node getAlreadyModeledClass() {
331-
result = FabricV2::Fabric::Connection::ConnectionClass::classRef()
331+
result = any(FabricV2::Fabric::Connection::ConnectionClass::Instance i)
332332
}
333333
}
334334

0 commit comments

Comments
 (0)