X Tutup
Skip to content

Commit 562d959

Browse files
committed
Python examples: Modernize snippets.
1 parent fc4bb02 commit 562d959

File tree

9 files changed

+14
-16
lines changed

9 files changed

+14
-16
lines changed

python/ql/examples/snippets/builtin_object.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
import python
1111

12-
from Expr e
13-
where e.refersTo(builtin_object(_))
12+
from Expr e, string name
13+
where e.pointsTo(Value::named(name)) and not name.charAt(_) = "."
1414
select e

python/ql/examples/snippets/call.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
import python
1010

11-
from FunctionObject len, CallNode call
11+
from Value len, CallNode call
1212
where len.getName() = "len" and len.getACall() = call
1313
select call

python/ql/examples/snippets/catch_exception.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
import python
1111

12-
from ExceptStmt ex, ClassObject cls
12+
from ExceptStmt ex, ClassValue cls
1313
where
1414
cls.getName() = "MyExceptionClass" and
15-
ex.getType().refersTo(cls)
15+
ex.getType().pointsTo(cls)
1616
select ex

python/ql/examples/snippets/method_call.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import python
1010

11-
from AstNode call, FunctionObject method
11+
from AstNode call, PythonFunctionValue method
1212
where
1313
method.getQualifiedName() = "MyClass.methodName" and
1414
method.getACall().getNode() = call

python/ql/examples/snippets/new_instance.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
import python
1111

12-
from Call new, ClassObject cls
12+
from Call new, ClassValue cls
1313
where
1414
cls.getName() = "MyClass" and
15-
new.getFunc().refersTo(cls)
15+
new.getFunc().pointsTo(cls)
1616
select new

python/ql/examples/snippets/print.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ where
1313
print instanceof Print
1414
or
1515
/* Python 3 or with `from __future__ import print_function` */
16-
print.(Call).getFunc().refersTo(thePrintFunction())
16+
print.(Call).getFunc().pointsTo(Value::named("print"))
1717
select print

python/ql/examples/snippets/raise_exception.ql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99

1010
import python
1111

12-
from Raise raise, ClassObject ex
12+
from Raise raise, ClassValue ex
1313
where
1414
ex.getName() = "AnException" and
1515
(
16-
raise.getException().refersTo(ex.getAnImproperSuperType())
17-
or
18-
raise.getException().refersTo(_, ex.getAnImproperSuperType(), _)
16+
raise.getException().pointsTo(ex.getASuperType())
1917
)
2018
select raise, "Don't raise instances of 'AnException'"

python/ql/examples/snippets/recursion.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
import python
1010

11-
from FunctionObject f
12-
where f.getACallee() = f
11+
from PythonFunctionValue f
12+
where f.getACall().getScope() = f.getScope()
1313
select f

python/ql/examples/snippets/store_none.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ import python
1414
from SubscriptNode store
1515
where
1616
store.isStore() and
17-
store.getIndex().refersTo(theNoneObject())
17+
store.getIndex().pointsTo(Value::named("None"))
1818
select store

0 commit comments

Comments
 (0)
X Tutup