Skip to content

Commit 639eafb

Browse files
test semgrep for directly-returned-format-string and nan-injection
1 parent 9b576cf commit 639eafb

File tree

4 files changed

+869
-53
lines changed

4 files changed

+869
-53
lines changed

app.py

+1-49
Original file line numberDiff line numberDiff line change
@@ -446,55 +446,7 @@ def megaitemnames():
446446
)
447447
)
448448

449-
450-
@app.route("/petshoppinglist", methods=["GET", "POST"])
451-
def petshoppinglist():
452-
return redirect("https://saddlebagexchange.com/wow/shopping-list")
453-
454-
# DEPRECIATED
455-
if request.method == "GET":
456-
return return_safe_html(render_template("petshoppinglist.html"))
457-
elif request.method == "POST":
458-
json_data = {
459-
"region": request.form.get("region"),
460-
"itemID": int(request.form.get("petID")),
461-
"maxPurchasePrice": int(request.form.get("maxPurchasePrice")),
462-
"connectedRealmIDs": {},
463-
}
464-
465-
response = requests.post(
466-
f"{api_url}/wow/shoppinglistx",
467-
headers={"Accept": "application/json"},
468-
json=json_data,
469-
).json()
470-
471-
if "data" not in response:
472-
logger.error(
473-
f"Error no matching data with given inputs {json_data} response {response}"
474-
)
475-
if NO_RATE_LIMIT:
476-
return f"Error no matching data with given inputs {json_data} response {response}"
477-
# send generic error message to remove XSS potential
478-
return f"error no matching results found matching search inputs"
479-
480-
response = response["data"]
481-
482-
column_order = [
483-
"realmID",
484-
"price",
485-
"quantity",
486-
"realmName",
487-
"realmNames",
488-
"link",
489-
]
490-
response = [{key: item.get(key) for key in column_order} for item in response]
491-
fieldnames = list(response[0].keys())
492-
493-
return return_safe_html(
494-
render_template(
495-
"petshoppinglist.html", results=response, fieldnames=fieldnames, len=len
496-
)
497-
)
449+
498450

499451

500452
@app.route("/petmarketshare", methods=["GET", "POST"])

routes/wow.py

+53
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,57 @@ def wow_outofstock_api():
9090
fieldnames=fieldnames,
9191
len=len,
9292
)
93+
)
94+
95+
@wow_bp.route("/petshoppinglist", methods=["GET", "POST"])
96+
def petshoppinglist():
97+
# return redirect("https://saddlebagexchange.com/wow/shopping-list")
98+
99+
# DEPRECIATED
100+
if request.method == "GET":
101+
return return_safe_html(render_template("petshoppinglist.html"))
102+
elif request.method == "POST":
103+
json_data = {
104+
"region": request.form.get("region"),
105+
"itemID": int(request.form.get("petID")),
106+
"maxPurchasePrice": int(request.form.get("maxPurchasePrice")),
107+
"connectedRealmIDs": {},
108+
}
109+
110+
print(json_data)
111+
112+
response = requests.post(
113+
f"{api_url}/wow/shoppinglistx",
114+
headers={"Accept": "application/json"},
115+
json=json_data,
116+
).json()
117+
118+
print(response)
119+
120+
if "data" not in response:
121+
print(
122+
f"Error no matching data with given inputs {json_data} response {response}"
123+
)
124+
if NO_RATE_LIMIT:
125+
return f"Error no matching data with given inputs {json_data} response {response}"
126+
# send generic error message to remove XSS potential
127+
return f"error no matching results found matching search inputs"
128+
129+
response = response["data"]
130+
131+
column_order = [
132+
"realmID",
133+
"price",
134+
"quantity",
135+
"realmName",
136+
"realmNames",
137+
"link",
138+
]
139+
response = [{key: item.get(key) for key in column_order} for item in response]
140+
fieldnames = list(response[0].keys())
141+
142+
return return_safe_html(
143+
render_template(
144+
"petshoppinglist.html", results=response, fieldnames=fieldnames, len=len
145+
)
93146
)

0 commit comments

Comments
 (0)