mirror of
https://github.com/github/codeql.git
synced 2026-06-15 01:41:08 +02:00
Convert selected Python inline expectation tests
This commit is contained in:
committed by
GitHub
parent
93898f5ee1
commit
e25418f436
@@ -1 +1,2 @@
|
||||
query: Exceptions/CatchingBaseException.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
query: Exceptions/EmptyExcept.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
query: Exceptions/IllegalExceptionHandlerType.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
query: Exceptions/IllegalRaise.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
query: Exceptions/NotImplementedIsNotAnException.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
def ee1(val):
|
||||
try:
|
||||
val.attr
|
||||
except:
|
||||
except: # $ Alert[py/empty-except] Alert[py/catch-base-exception]
|
||||
pass
|
||||
|
||||
def ee1(val):
|
||||
try:
|
||||
val.attr()
|
||||
except TypeError:
|
||||
except TypeError: # $ Alert[py/empty-except]
|
||||
pass
|
||||
|
||||
def ee2(val):
|
||||
@@ -37,21 +37,21 @@ class NotException2(object):
|
||||
pass
|
||||
|
||||
def illegal_raise_type():
|
||||
raise NotException1
|
||||
raise NotException1 # $ Alert[py/illegal-raise]
|
||||
|
||||
def illegal_raise_value1():
|
||||
raise "Exception"
|
||||
raise "Exception" # $ Alert[py/illegal-raise]
|
||||
|
||||
def illegal_raise_value2():
|
||||
raise NotException2()
|
||||
raise NotException2() # $ Alert[py/illegal-raise]
|
||||
|
||||
def illegal_handler():
|
||||
try:
|
||||
illegal_raise()
|
||||
except NotException1:
|
||||
except NotException1: # $ Alert[py/useless-except]
|
||||
#Must do something
|
||||
print("NotException1")
|
||||
except NotException2:
|
||||
except NotException2: # $ Alert[py/useless-except]
|
||||
#Must do something
|
||||
print("NotException2")
|
||||
|
||||
@@ -69,7 +69,7 @@ class MyExc(ValueError):
|
||||
|
||||
try:
|
||||
pass
|
||||
except ValueError:
|
||||
except ValueError: # $ Alert[py/empty-except]
|
||||
pass
|
||||
except MyExc: # $ MISSING:Alert[py/unreachable-except] # Missing due to dataflow limitiation preventing MyExc from being tracked here.
|
||||
pass
|
||||
@@ -82,11 +82,11 @@ class MySubExc(MyBaseExc):
|
||||
|
||||
try:
|
||||
pass
|
||||
except MyBaseExc:
|
||||
except MyBaseExc: # $ Alert[py/empty-except]
|
||||
pass
|
||||
except MySubExc: # $ MISSING:Alert[py/unreachable-except] # Missing due to dataflow limitation preventing MyExc from being tracked here.
|
||||
pass
|
||||
except Exception:
|
||||
except Exception: # $ Alert[py/empty-except]
|
||||
pass
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ except Exception:
|
||||
def catch_base_exception():
|
||||
try:
|
||||
illegal_raise()
|
||||
except BaseException:
|
||||
except BaseException: # $ Alert[py/catch-base-exception]
|
||||
#Consumes KeyboardInterrupt
|
||||
pass
|
||||
|
||||
@@ -135,7 +135,7 @@ def a_number():
|
||||
def illegal_handler2():
|
||||
try:
|
||||
illegal_raise()
|
||||
except a_number():
|
||||
except a_number(): # $ Alert[py/useless-except]
|
||||
print ("Caught exception")
|
||||
|
||||
def stop_iter_ok(seq):
|
||||
@@ -193,7 +193,7 @@ def ee8(x):
|
||||
|
||||
#These are so common, we give warnings not errors.
|
||||
def foo():
|
||||
raise NotImplemented
|
||||
raise NotImplemented # $ Alert[py/raise-not-implemented]
|
||||
|
||||
def bar():
|
||||
raise NotImplemented()
|
||||
raise NotImplemented() # $ Alert[py/raise-not-implemented]
|
||||
|
||||
@@ -11,10 +11,9 @@ def test():
|
||||
try:
|
||||
a = A()
|
||||
raise a
|
||||
except 42:
|
||||
except 42: # $ Alert[py/useless-except]
|
||||
#Some comment
|
||||
pass
|
||||
except A:
|
||||
#Another comment
|
||||
pass
|
||||
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
query: Functions/IncorrectlyOverriddenMethod.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
query: Functions/IncorrectlySpecifiedOverriddenMethod.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
query: Expressions/WrongNameForArgumentInCall.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
query: Expressions/WrongNumberArgumentsInCall.ql
|
||||
postprocess: utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
class Base(object):
|
||||
|
||||
def meth1(self):
|
||||
def meth1(self): # $ Alert[py/inheritance/incorrect-overridden-signature]
|
||||
pass
|
||||
|
||||
def meth2(self, spam):
|
||||
def meth2(self, spam): # $ Alert[py/inheritance/incorrect-overridden-signature]
|
||||
pass
|
||||
|
||||
def meth3(self):
|
||||
@@ -13,10 +13,10 @@ class Base(object):
|
||||
|
||||
def foo(self):
|
||||
self.meth1()
|
||||
self.meth1(0)
|
||||
self.meth2()
|
||||
self.meth1(0) # $ Alert[py/call/wrong-arguments]
|
||||
self.meth2() # $ Alert[py/call/wrong-arguments]
|
||||
self.meth2(0)
|
||||
self.meth1(spam="eggs")
|
||||
self.meth1(spam="eggs") # $ Alert[py/call/wrong-named-argument]
|
||||
self.meth2(spam="eggs")
|
||||
|
||||
class Derived(Base):
|
||||
@@ -44,7 +44,7 @@ d.meth1
|
||||
|
||||
class Abstract(object):
|
||||
|
||||
def meth(self):
|
||||
def meth(self): # $ Alert[py/inheritance/incorrect-overridden-signature]
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ class Base2:
|
||||
self.meth1()
|
||||
self.meth1(x=2)
|
||||
self.meth3()
|
||||
self.meth3(x=2)
|
||||
self.meth3(x=2) # $ Alert[py/call/wrong-named-argument]
|
||||
self.meth6(2, 3, 4)
|
||||
self.meth7()
|
||||
self.meth8(1,y=3)
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
query: Security/CWE-089/SqlInjection.ql
|
||||
postprocess: utils/test/PrettyPrintModels.ql
|
||||
postprocess:
|
||||
- utils/test/PrettyPrintModels.ql
|
||||
- utils/test/InlineExpectationsTestQuery.ql
|
||||
|
||||
@@ -3,4 +3,4 @@ import sys
|
||||
import psycopg
|
||||
|
||||
conn = psycopg.connect(...)
|
||||
conn.execute(sys.argv[1])
|
||||
conn.execute(sys.argv[1]) # $ Alert
|
||||
|
||||
Reference in New Issue
Block a user