Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f10456e

Browse files
committed
Python: Model fabric task decorator (version 2.x)
1 parent c671017 commit f10456e

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

python/ql/src/experimental/semmle/python/frameworks/Fabric.qll

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,5 +357,42 @@ private module FabricV2 {
357357
result.asCfgNode() = [node.getArg(0), node.getArgByName("command")]
358358
}
359359
}
360+
361+
// -------------------------------------------------------------------------
362+
// fabric.tasks
363+
// -------------------------------------------------------------------------
364+
/** Gets a reference to the `fabric.tasks` module. */
365+
DataFlow::Node tasks() { result = fabric_attr("tasks") }
366+
367+
/** Provides models for the `fabric.tasks` module */
368+
module tasks {
369+
/** Gets a reference to the `fabric.tasks.task` decorator. */
370+
private DataFlow::Node task(DataFlow::TypeTracker t) {
371+
t.start() and
372+
result = DataFlow::importNode("fabric.tasks.task")
373+
or
374+
t.startInAttr("task") and
375+
result = tasks()
376+
or
377+
// Handle `fabric.task` alias
378+
t.startInAttr("task") and
379+
result = fabric()
380+
or
381+
exists(DataFlow::TypeTracker t2 | result = task(t2).track(t2, t))
382+
}
383+
384+
/** Gets a reference to the `fabric.tasks.task` decorator. */
385+
DataFlow::Node task() { result = task(DataFlow::TypeTracker::end()) }
386+
}
387+
388+
class FabricTaskFirstParamConnectionInstance extends fabric::connection::Connection::InstanceSource,
389+
DataFlow::ParameterNode {
390+
FabricTaskFirstParamConnectionInstance() {
391+
exists(Function func |
392+
func.getADecorator() = fabric::tasks::task().asExpr() and
393+
this.getParameter() = func.getArg(0)
394+
)
395+
}
396+
}
360397
}
361398
}

python/ql/test/experimental/library-tests/frameworks/fabric/ConceptsTest.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,3 @@
44
| fabric_v2_test.py:41:69:41:94 | Comment # $getCommand="cmd1; cmd2" | Missing result:getCommand="cmd1; cmd2" |
55
| fabric_v2_test.py:44:25:44:50 | Comment # $getCommand="cmd1; cmd2" | Missing result:getCommand="cmd1; cmd2" |
66
| fabric_v2_test.py:47:65:47:90 | Comment # $getCommand="cmd1; cmd2" | Missing result:getCommand="cmd1; cmd2" |
7-
| fabric_v2_test.py:58:26:58:51 | Comment # $getCommand="cmd1; cmd2" | Missing result:getCommand="cmd1; cmd2" |
8-
| fabric_v2_test.py:64:26:64:51 | Comment # $getCommand="cmd1; cmd2" | Missing result:getCommand="cmd1; cmd2" |

0 commit comments

Comments
 (0)