FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Python: bind captured type-tracking jumps from source by yoff · Pull Request #22407 · github/codeql · GitHub

/ codeql Public
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .expected  (1) .py  (1) .ql  (1) .qll  (1) All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
      • CallTargets.expected
      • CallTargets.ql
      • test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,10 @@ module TypeTrackingInput implements Shared::TypeTrackingInput<Location> {
//
// nodeFrom is `expr`
// nodeTo is entry node for `f`
exists(
SsaImpl::ScopeEntryDefinition e, SsaImpl::SsaSourceVariable var, Cfg::DefinitionNode def
|
e.getSourceVariable() = var and
def.getNode() = var.getVariable().getAStore()
|
exists(SsaImpl::ScopeEntryDefinition e, SsaImpl::SsaSourceVariable var |
nodeTo.(DataFlowPublic::ScopeEntryDefinitionNode).getDefinition() = e and
nodeFrom.asCfgNode() = def and
e.getSourceVariable() = var and
nodeFrom.asCfgNode().(Cfg::DefinitionNode).getNode() = var.getVariable().getAStore() and
var.getVariable().getScope().getScope*() = nodeFrom.getScope()
)
}
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
| test.py:14:13:14:38 | Attribute() | test.py:3:5:3:25 | Function compile | CallTypeStaticMethod |
| test.py:14:13:14:38 | Attribute() | test.py:9:5:9:25 | Function compile | CallTypeStaticMethod |
| test.py:23:16:23:21 | func() | test.py:29:1:29:12 | Function first | CallTypePlainFunction |
| test.py:23:16:23:21 | func() | test.py:34:1:34:13 | Function second | CallTypePlainFunction |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import python
private import semmle.python.controlflow.internal.Cfg as Cfg
private import semmle.python.dataflow.new.internal.DataFlowDispatch as Dispatch

from Call call, Function target, Dispatch::CallType callType
where
exists(Cfg::CallNode cfgCall |
cfgCall.getNode() = call and
Dispatch::resolveCall(cfgCall, target, callType)
) and
call.getLocation().getFile().getRelativePath() = "test.py" and
target.getLocation().getFile().getRelativePath() = "test.py" and
(
call.getFunc().(Name).getId() = "func"
or
call.getFunc().(Attribute).getName() = "compile"
)
select call, target, callType.toString()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
class RegexRule:
@staticmethod
def compile(pattern):
return pattern


class GlobRule:
@staticmethod
def compile(pattern):
return pattern


def compile_rules(rule_type, patterns):
return [rule_type.compile(pattern) for pattern in patterns]


compile_rules(RegexRule, ["x"])
compile_rules(GlobRule, ["*"])


def decorate(func):
def wrapper():
return func()

return wrapper


@decorate
def first():
return 1


@decorate
def second():
return 2


first()
second()

Back | FazBrowse Home | New Git URL