Skip to content

Linters test 1 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/bandit-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"problemMatcher": [
{
"owner": "bandit",
"pattern": [
{
"regexp": "^(.*):(\\d+):\\s*(\\d+):\\s*(.*)$",
"file": 1,
"line": 2,
"message": 4
}
]
}
]
}
14 changes: 14 additions & 0 deletions .github/black-matcher.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"problemMatcher": [
{
"owner": "black",
"pattern": [
{
"regexp": "^(.+):\\s*(error|warning)\\s*(.+)$",
"file": 1,
"message": 3
}
]
}
]
}
13 changes: 8 additions & 5 deletions .github/workflows/linters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@ name: Linters
on:
workflow_dispatch:
pull_request:
branches:
- main
push:
branches:
- main

jobs:
# TODO: Fix Bandit Vulns
"Bandit":
runs-on: ubuntu-latest
container: python:3.11

steps:
- uses: actions/checkout@v2

- name: Enable Bandit problem matcher
run: echo "::add-matcher::$(pwd)/.github/bandit-matcher.json"

- name: Bandit check
uses: jpetrucciani/bandit-check@master
with:
path: "app.py"
bandit_flags: "-lll"
continue-on-error: true # Allow this step to fail but continue

"Black":
runs-on: ubuntu-latest
Expand All @@ -35,5 +34,9 @@ jobs:
- name: Install dependencies
run: pip install black

- name: Add Black problem matcher
run: echo "::add-matcher::$(pwd)/.github/black-matcher.json"

- name: Run black check
run: black --check .
continue-on-error: true # Allow this step to fail but continue
50 changes: 1 addition & 49 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,55 +446,7 @@ def megaitemnames():
)
)


@app.route("/petshoppinglist", methods=["GET", "POST"])
def petshoppinglist():
return redirect("https://saddlebagexchange.com/wow/shopping-list")

# DEPRECIATED
if request.method == "GET":
return return_safe_html(render_template("petshoppinglist.html"))
elif request.method == "POST":
json_data = {
"region": request.form.get("region"),
"itemID": int(request.form.get("petID")),
"maxPurchasePrice": int(request.form.get("maxPurchasePrice")),
"connectedRealmIDs": {},
}

response = requests.post(
f"{api_url}/wow/shoppinglistx",
headers={"Accept": "application/json"},
json=json_data,
).json()

if "data" not in response:
logger.error(
f"Error no matching data with given inputs {json_data} response {response}"
)
if NO_RATE_LIMIT:
return f"Error no matching data with given inputs {json_data} response {response}"
# send generic error message to remove XSS potential
return f"error no matching results found matching search inputs"

response = response["data"]

column_order = [
"realmID",
"price",
"quantity",
"realmName",
"realmNames",
"link",
]
response = [{key: item.get(key) for key in column_order} for item in response]
fieldnames = list(response[0].keys())

return return_safe_html(
render_template(
"petshoppinglist.html", results=response, fieldnames=fieldnames, len=len
)
)



@app.route("/petmarketshare", methods=["GET", "POST"])
Expand Down
53 changes: 53 additions & 0 deletions routes/wow.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,57 @@ def wow_outofstock_api():
fieldnames=fieldnames,
len=len,
)
)

@wow_bp.route("/petshoppinglist", methods=["GET", "POST"])
def petshoppinglist():
# return redirect("https://saddlebagexchange.com/wow/shopping-list")

# DEPRECIATED
if request.method == "GET":
return return_safe_html(render_template("petshoppinglist.html"))
elif request.method == "POST":
json_data = {
"region": request.form.get("region"),
"itemID": int(request.form.get("petID")),
"maxPurchasePrice": int(request.form.get("maxPurchasePrice")),
"connectedRealmIDs": {},
}

print(json_data)

response = requests.post(
f"{api_url}/wow/shoppinglistx",
headers={"Accept": "application/json"},
json=json_data,
).json()

print(response)

if "data" not in response:
print(
f"Error no matching data with given inputs {json_data} response {response}"
)
if NO_RATE_LIMIT:
return f"Error no matching data with given inputs {json_data} response {response}"
# send generic error message to remove XSS potential
return f"error no matching results found matching search inputs"

response = response["data"]

column_order = [
"realmID",
"price",
"quantity",
"realmName",
"realmNames",
"link",
]
response = [{key: item.get(key) for key in column_order} for item in response]
fieldnames = list(response[0].keys())

return return_safe_html(
render_template(
"petshoppinglist.html", results=response, fieldnames=fieldnames, len=len
)
)
Loading
Loading