Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Classes/InconsistentMRO.ql
query: Classes/InconsistentMRO.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class X(object):
class Y(X):
pass

class Z(X, Y):
class Z(X, Y): # $ Alert
pass

class O:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Classes/PropertyInOldStyleClass.ql
query: Classes/PropertyInOldStyleClass.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Classes/SlotsInOldStyleClass.ql
query: Classes/SlotsInOldStyleClass.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Classes/SuperInOldStyleClass.ql
query: Classes/SuperInOldStyleClass.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#Only works for Python2

class OldStyle1:
class OldStyle1: # $ Alert[py/slots-in-old-style-class]

__slots__ = [ 'a', 'b' ]

Expand All @@ -12,7 +12,7 @@ def __init__(self, a, b):
class OldStyle2:

def __init__(self, x):
super().__init__(x)
super().__init__(x) # $ Alert[py/super-in-old-style]

class NewStyle1(object):

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ class OldStyle:
def __init__(self, x):
self._x = x

@property
@property # $ Alert[py/property-in-old-style-class]
def piosc(self):
return self._x
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Classes/MaybeUndefinedClassAttribute.ql
query: Classes/MaybeUndefinedClassAttribute.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Classes/UndefinedClassAttribute.ql
query: Classes/UndefinedClassAttribute.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Exceptions/CatchingBaseException.ql
query: Exceptions/CatchingBaseException.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Exceptions/EmptyExcept.ql
query: Exceptions/EmptyExcept.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Exceptions/IllegalExceptionHandlerType.ql
query: Exceptions/IllegalExceptionHandlerType.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Exceptions/IllegalRaise.ql
query: Exceptions/IllegalRaise.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Exceptions/IncorrectExceptOrder.ql
query: Exceptions/IncorrectExceptOrder.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ def raise_tuple(cond):
raise (Exception, "bananas", 17)
else:
#This is an error
raise (17, "bananas", Exception)
raise (17, "bananas", Exception) # $ Alert[py/illegal-raise]
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Exceptions/UnguardedNextInGenerator.ql
query: Exceptions/UnguardedNextInGenerator.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
4 changes: 2 additions & 2 deletions python/ql/test/2/query-tests/Exceptions/generators/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

def bad1(it):
while True:
yield next(it)
yield next(it) # $ Alert

def bad2(seq):
it = iter(seq)
#Not OK as seq may be empty
raise KeyError(next(it))
raise KeyError(next(it)) # $ Alert
yield 0

def ok1(seq):
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Exceptions/RaisingTuple.ql
query: Exceptions/RaisingTuple.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
6 changes: 3 additions & 3 deletions python/ql/test/2/query-tests/Exceptions/raising/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ def ok():

def bad1():
ex = Exception, "message"
raise ex
raise ex # $ Alert

def bad2():
raise (Exception, "message")
raise (Exception, "message") # $ Alert

def bad3():
ex = Exception,
raise ex, "message"
raise ex, "message" # $ Alert
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Expressions/TruncatedDivision.ql
query: Expressions/TruncatedDivision.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ def halve(x):
# This case is bad, and is a minimal obvious case that should be bad. It
# SHOULD be found by the query.

print(3 / 2)
print(3 / 2) # $ Alert[py/truncated-division]



# This case is bad. It uses indirect returns of integers through function calls
# to produce the problem. I

print(return_three() / return_two())
print(return_three() / return_two()) # $ Alert[py/truncated-division]



Expand Down
2 changes: 1 addition & 1 deletion python/ql/test/2/query-tests/Expressions/UseofApply.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def foo():

# This use of `apply` is a reference to the builtin function and so SHOULD be
# caught by the query.
apply(foo, [1])
apply(foo, [1]) # $ Alert[py/use-of-apply]



Expand Down
3 changes: 2 additions & 1 deletion python/ql/test/2/query-tests/Expressions/UseofApply.qlref
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Expressions/UseofApply.ql
query: Expressions/UseofApply.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
3 changes: 2 additions & 1 deletion python/ql/test/2/query-tests/Expressions/UseofInput.qlref
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Expressions/UseofInput.ql
query: Expressions/UseofInput.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
def use_of_apply(func, args):
apply(func, args)
apply(func, args) # $ Alert[py/use-of-apply]


def use_of_input():
return input() # NOT OK
return input() # $ Alert[py/use-of-input] # NOT OK


def not_use_of_input():
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Functions/DeprecatedSliceMethod.ql
query: Functions/DeprecatedSliceMethod.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Imports/EncodingError.ql
query: Imports/EncodingError.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Imports/EncodingError.ql
query: Imports/EncodingError.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Imports/SyntaxError.ql
query: Imports/SyntaxError.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
# encoding:shift-jis

def f():
print "Python の開発は、1990 年ごろから開始されています"
print "Python の開発は、1990 年ごろから開始されています" # $ Alert[py/encoding-error]
"""
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
`Twas brillig, and the slithy toves
`Twas brillig, and the slithy toves # $ Alert[py/syntax-error]
Did gyre and gimble in the wabe:
All mimsy were the borogoves,
And the mome raths outgrabe.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Lexical/OldOctalLiteral.ql
query: Lexical/OldOctalLiteral.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
2 changes: 1 addition & 1 deletion python/ql/test/2/query-tests/Lexical/lexical_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#Bad Octal literal
017
017 # $ Alert
#Good Octal literal
0o17
#Special case file permissions
Expand Down
3 changes: 2 additions & 1 deletion python/ql/test/2/query-tests/Statements/ExecUsed.qlref
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Statements/ExecUsed.ql
query: Statements/ExecUsed.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Statements/IterableStringOrSequence.ql
query: Statements/IterableStringOrSequence.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Statements/TopLevelPrint.ql
query: Statements/TopLevelPrint.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
2 changes: 1 addition & 1 deletion python/ql/test/2/query-tests/Statements/module.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Top level prints in modules are bad
print ("Side effect on import")
print ("Side effect on import") # $ Alert[py/print-during-import]
4 changes: 2 additions & 2 deletions python/ql/test/2/query-tests/Statements/statements_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


def exec_used(val):
exec (val)
exec (val) # $ Alert[py/use-of-exec]

#Top level print
import module
Expand All @@ -18,7 +18,7 @@ def f(x):
s = u"Hello World"
else:
s = [ u'Hello', u'World']
for thing in s:
for thing in s: # $ Alert[py/iteration-string-and-sequence]
print (thing)

import fake_six
Expand Down
2 changes: 1 addition & 1 deletion python/ql/test/2/query-tests/Summary/LinesOfCode.qlref
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Summary/LinesOfCode.ql
query: Summary/LinesOfCode.ql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Summary/LinesOfUserCode.ql
query: Summary/LinesOfUserCode.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Variables/LeakingListComprehension.ql
query: Variables/LeakingListComprehension.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
4 changes: 2 additions & 2 deletions python/ql/test/2/query-tests/Variables/LeakyComp/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

def undefined_in_3():
[x for x in range(3)]
print(x)
print(x) # $ Alert

def different_in_3():
y = 10
[y for y in range(3)]
print(y)
print(y) # $ Alert

def ok():
[z for z in range(4)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


__all__ = [ "x", "y", "z", "module" ]
__all__ = [ "x", "y", "z", "module" ] # $ Alert[py/undefined-export]

x = 1
if 0:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Variables/UndefinedExport.ql
query: Variables/UndefinedExport.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Variables/UndefinedGlobal.ql
query: Variables/UndefinedGlobal.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Variables/UninitializedLocal.ql
query: Variables/UninitializedLocal.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__all__ = [ "module", "not_exists" ]
__all__ = [ "module", "not_exists" ] # $ Alert[py/undefined-export]
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Classes/DefineEqualsWhenAddingAttributes.ql
query: Classes/DefineEqualsWhenAddingAttributes.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
2 changes: 1 addition & 1 deletion python/ql/test/3/query-tests/Classes/equals-attr/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class RedefineEquals:
def __eq__(self, other):
return other is "Tuesday"

class C(RedefineEquals):
class C(RedefineEquals): # $ Alert

def __init__(self, args):
self.a, self.b = args
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Classes/InconsistentMRO.ql
query: Classes/InconsistentMRO.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class X(object):
class Y(X):
pass

class Z(X, Y):
class Z(X, Y): # $ Alert
pass

class O:
pass

#This is OK in Python 2
class N(object, O):
class N(object, O): # $ Alert
pass
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Classes/MaybeUndefinedClassAttribute.ql
query: Classes/MaybeUndefinedClassAttribute.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Classes/UndefinedClassAttribute.ql
query: Classes/UndefinedClassAttribute.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Expressions/WrongNameForArgumentInCall.ql
query: Expressions/WrongNameForArgumentInCall.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Expressions/WrongNumberArgumentsInCall.ql
query: Expressions/WrongNumberArgumentsInCall.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def f(a, *varargs, kw1, kw2="has-default"):
f(1, 2, kw1=1, kw2=2)

#Not OK
f(1, 2, 3, kw1=1, kw3=3)
f(1, 2, 3, kw3=3)
f(1, 2, 3, kw1=1, kw3=3) # $ Alert[py/call/wrong-named-argument]
f(1, 2, 3, kw3=3) # $ Alert[py/call/wrong-named-argument]


#ODASA-5897
Expand All @@ -21,4 +21,4 @@ def ok():
return analyze_member_access(msg, original=original, chk=chk)

def bad():
return analyze_member_access(msg, original, chk=chk)
return analyze_member_access(msg, original, chk=chk) # $ Alert[py/call/wrong-arguments]
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Expressions/WrongNumberArgumentsForFormat.ql
query: Expressions/WrongNumberArgumentsForFormat.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Expressions/TruncatedDivision.ql
query: Expressions/TruncatedDivision.ql
postprocess: utils/test/InlineExpectationsTestQuery.ql
Loading
Loading