FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pyt/example/vulnerable_code/sql/sqli.py at 8githubScanRefactor · python-security/pyt · GitHub
python-security
pyt
Repository navigation
Code
Issues
26
(26)
Pull requests
2
(2)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
pyt
/
example
/
vulnerable_code
/
sql
/
sqli.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (34 loc) · 1.18 KB
Breadcrumbs
pyt
/
example
/
vulnerable_code
/
sql
/
sqli.py
Copy path
File metadata and controls
42 lines (34 loc) · 1.18 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from
flask
import
Flask
,
request
from
flask_sqlalchemy
import
SQLAlchemy
from
sqlalchemy
.
orm
import
sessionmaker
import
sys
app
=
Flask
(
__name__
)
# SQL Alchemy setup
app
.
config
[
'SQLALCHEMY_DATABASE_URI'
]
=
'sqlite:////tmp/test.db'
db
=
SQLAlchemy
(
app
)
class
User
(
db
.
Model
):
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
username
=
db
.
Column
(
db
.
String
(
80
),
unique
=
True
)
email
=
db
.
Column
(
db
.
String
(
120
),
unique
=
True
)
def
__init__
(
self
,
username
,
email
):
self
.
username
=
username
self
.
email
=
email
def
__repr__
(
self
):
return
'<User %r>'
%
self
.
username
@
app
.
route
(
'/raw'
)
def
index
():
param
=
request
.
args
.
get
(
'param'
,
'not set'
)
result
=
db
.
engine
.
execute
(
param
)
print
(
User
.
query
.
all
(),
file
=
sys
.
stderr
)
return
'Result is displayed in console.'
@
app
.
route
(
'/filtering'
)
def
filtering
():
param
=
request
.
args
.
get
(
'param'
,
'not set'
)
Session
=
sessionmaker
(
bind
=
db
.
engine
)
session
=
Session
()
result
=
session
.
query
(
User
).
filter
(
"username={}"
.
format
(
param
))
for
value
in
result
:
print
(
value
.
username
,
value
.
email
)
return
'Result is displayed in console.'
if
__name__
==
'__main__'
:
app
.
run
(
debug
=
True
)
Back
|
FazBrowse Home
|
New Git URL