Skip to content

Commit 9455021

Browse files
fzipizimmerle
authored andcommitted
fix(py3): change to py3 syntax
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
1 parent cee7cc9 commit 9455021

5 files changed

Lines changed: 37 additions & 37 deletions

File tree

apitest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from libinjection import *
88
from words import words
99

10-
print dir(libinjection)
10+
print(dir(libinjection))
1111

1212
def print_token_string(tok):
1313
"""
@@ -55,4 +55,4 @@ def lookup(state, stype, keyword):
5555
sqli_callback(s, lookup)
5656

5757
while sqli_tokenize(s):
58-
print print_token(s.current)
58+
print(print_token(s.current))

json2python.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
def toc(obj):
1313
""" main routine """
1414

15-
print """
15+
print("""
1616
import libinjection
1717
1818
def lookup(state, stype, keyword):
@@ -24,24 +24,24 @@ def lookup(state, stype, keyword):
2424
return chr(0)
2525
return words.get(keyword, chr(0))
2626
27-
"""
27+
""")
2828

2929
words = {}
3030
keywords = obj['keywords']
31-
for k,v in keywords.iteritems():
31+
for k,v in keywords.items():
3232
words[str(k)] = str(v)
3333

34-
print 'words = {'
34+
print('words = {')
3535
for k in sorted(words.keys()):
36-
print "'{0}': '{1}',".format(k, words[k])
37-
print '}\n'
36+
print("'{0}': '{1}',".format(k, words[k]))
37+
print('}\n')
3838

3939

4040
keywords = obj['fingerprints']
41-
print 'fingerprints = set(['
41+
print('fingerprints = set([')
4242
for k in sorted(keywords):
43-
print "'{0}',".format(k.upper())
44-
print '])'
43+
print("'{0}',".format(k.upper()))
44+
print('])')
4545

4646
return 0
4747

pytest.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@
66

77
if False:
88
s = sfilter()
9-
print sqli_fingerprint(s, sqli, CHAR_NULL, COMMENTS_ANSI)
10-
print "----"
9+
print(sqli_fingerprint(s, sqli, CHAR_NULL, COMMENTS_ANSI))
10+
print("----")
1111

1212
if False:
1313
s = sfilter()
1414
current = stoken_t()
1515
sqli_init(s, sqli, CHAR_NULL, COMMENTS_ANSI)
1616
while sqli_tokenize(s, current):
17-
print current.type, current.val
18-
print "----"
17+
print(current.type, current.val)
18+
print("----")
1919

2020
def is_pattern(state):
2121
return sqli_blacklist(state) and sqli_not_whitelist(state)
2222

2323
s = sfilter()
2424

2525
if is_sqli(s, sqli, None):
26-
print "IS SQLI"
27-
print len(s.pat)
28-
print s.current.val
29-
print s.current.type
26+
print("IS SQLI")
27+
print(len(s.pat))
28+
print(s.current.val)
29+
print(s.current.type)
3030
vec = s.tokenvec
3131
for i in range(len(s.pat)):
3232
atoken = vec[i]
33-
print atoken.type, atoken.val
33+
print(atoken.type, atoken.val)
3434
else:
35-
print "IS NOT SQLI"
35+
print("IS NOT SQLI")

speedtest.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,58 +36,58 @@ def main():
3636

3737
t0 = clock()
3838
sfilter = sqli_state()
39-
for i in xrange(imax):
39+
for i in range(imax):
4040
s = inputs[i % 7]
4141
sqli_init(sfilter, s, 0)
4242
is_sqli(sfilter)
4343
t1 = clock()
4444
total = imax / (t1 - t0)
45-
print("python->c TPS = {0}".format(total))
45+
print(("python->c TPS = {0}".format(total)))
4646

4747
t0 = clock()
4848
sfilter = sqli_state()
49-
for i in xrange(imax):
49+
for i in range(imax):
5050
s = inputs[i % 7]
5151
sqli_init(sfilter, s, 0)
5252
sqli_callback(sfilter, lookup_null)
5353
is_sqli(sfilter)
5454
t1 = clock()
5555
total = imax / (t1 - t0)
56-
print("python lookup_null TPS = {0}".format(total))
56+
print(("python lookup_null TPS = {0}".format(total)))
5757

5858
t0 = clock()
5959
sfilter = sqli_state()
60-
for i in xrange(imax):
60+
for i in range(imax):
6161
s = inputs[i % 7]
6262
sqli_init(sfilter, s, 0)
6363
sqli_callback(sfilter, lookup_upcase)
6464
is_sqli(sfilter)
6565
t1 = clock()
6666
total = imax / (t1 - t0)
67-
print("python lookup_upcase TPS = {0}".format(total))
67+
print(("python lookup_upcase TPS = {0}".format(total)))
6868

6969
t0 = clock()
7070
sfilter = sqli_state()
71-
for i in xrange(imax):
71+
for i in range(imax):
7272
s = inputs[i % 7]
7373
sqli_init(sfilter, s, 0)
7474
sqli_callback(sfilter, lookup_c)
7575
is_sqli(sfilter)
7676
t1 = clock()
7777
total = imax / (t1 - t0)
78-
print("python lookup_c TPS = {0}".format(total))
78+
print(("python lookup_c TPS = {0}".format(total)))
7979

8080

8181
t0 = clock()
8282
sfilter = sqli_state()
83-
for i in xrange(imax):
83+
for i in range(imax):
8484
s = inputs[i % 7]
8585
sqli_init(sfilter, s, 0)
8686
sqli_callback(sfilter, lookup)
8787
is_sqli(sfilter)
8888
t1 = clock()
8989
total = imax / (t1 - t0)
90-
print("python lookup TPS = {0}".format(total))
90+
print(("python lookup TPS = {0}".format(total)))
9191

9292

9393
if __name__ == '__main__':

test_driver.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from libinjection import *
99
from words import *
1010

11-
print version()
11+
print(version())
1212

1313
def print_token_string(tok):
1414
"""
@@ -105,11 +105,11 @@ def runtest(testname, flag, sqli_flags):
105105
actual = actual.strip()
106106

107107
if actual != data[2]:
108-
print "INPUT: \n" + toascii(data[1])
109-
print
110-
print "EXPECTED: \n" + toascii(data[2])
111-
print
112-
print "GOT: \n" + toascii(actual)
108+
print("INPUT: \n" + toascii(data[1]))
109+
print()
110+
print("EXPECTED: \n" + toascii(data[2]))
111+
print()
112+
print("GOT: \n" + toascii(actual))
113113
assert actual == data[2]
114114

115115
def test_tokens():

0 commit comments

Comments
 (0)