Skip to content
This repository was archived by the owner on Sep 3, 2023. It is now read-only.

Commit dd270c8

Browse files
committed
Initial commit
1 parent 58c36ef commit dd270c8

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

main.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def add_report(domain, description, falsepositive: bool, response):
6060
except IndexError:
6161
pass
6262

63+
blacklist_status = blacklist_db.fetch({"blacklisted": True}).items
64+
blacklist_domain = blacklist_db.fetch({"domain": domain}).items
65+
6366
res = requests.get("https://api.stopmodreposts.org/sites.txt")
6467

6568
if domain in res.text:
@@ -75,7 +78,7 @@ def add_report(domain, description, falsepositive: bool, response):
7578
"false-positive": falsepositive
7679
}
7780
}
78-
elif len(blacklist_db.fetch({"domain": domain}).items) != 0:
81+
elif len(blacklist_status) != 0 and len(blacklist_domain) != 0:
7982
response.status_code = status.HTTP_400_BAD_REQUEST
8083
return response, {
8184
"detail": "Failed to report - domain blacklisted",
@@ -263,7 +266,13 @@ def get_api_waitlist():
263266

264267
@app.get("/api/v1/blacklist")
265268
def get_api_blacklist():
266-
return {"detail": "Blacklist (WIP)"}
269+
res = blacklist_db.fetch({"blacklisted": True}).items
270+
final = []
271+
for site in res:
272+
final.append({
273+
"domain": site["domain"]
274+
})
275+
return final
267276

268277
@app.post("/api/v1/report", status_code=201)
269278
def post_api_report(response: Response,
@@ -289,11 +298,16 @@ def post_api_report(response: Response,
289298
"""
290299
Reporting endpoint for reposting sites and false-positives
291300
"""
301+
if falsepositive:
302+
baseURL = "/forms/falsepositive"
303+
else:
304+
baseURL = "/forms/report"
305+
292306
if captcha is None:
293-
return RedirectResponse(url=f"/forms/report?alert=captcha", status_code=status.HTTP_303_SEE_OTHER)
307+
return RedirectResponse(url=f"{baseURL}?alert=captcha", status_code=status.HTTP_303_SEE_OTHER)
294308
else:
295309
if verifycaptcha(captcha) is False:
296-
return RedirectResponse(url=f"/forms/report?alert=captcha", status_code=status.HTTP_303_SEE_OTHER)
310+
return RedirectResponse(url=f"{baseURL}?alert=captcha", status_code=status.HTTP_303_SEE_OTHER)
297311

298312
if domain == None or description == None:
299313
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="Required form fields missing")
@@ -306,11 +320,11 @@ def post_api_report(response: Response,
306320
)
307321

308322
if response.status_code == status.HTTP_409_CONFLICT:
309-
return RedirectResponse("/forms/report?alert=listed", status_code=status.HTTP_303_SEE_OTHER)
323+
return RedirectResponse(f"{baseURL}?alert=listed", status_code=status.HTTP_303_SEE_OTHER)
310324
elif response.status_code == status.HTTP_400_BAD_REQUEST:
311-
return RedirectResponse("/forms/report?alert=blocked", status_code=status.HTTP_303_SEE_OTHER)
325+
return RedirectResponse(f"{baseURL}?alert=blocked", status_code=status.HTTP_303_SEE_OTHER)
312326
else:
313-
return RedirectResponse("/forms/report?alert=success", status_code=status.HTTP_303_SEE_OTHER)
327+
return RedirectResponse(f"{baseURL}?alert=success", status_code=status.HTTP_303_SEE_OTHER)
314328

315329

316330
if __name__ == "__main__":

templates/falsepositive.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h2 class="text-start" style="font-size: 18px;margin-bottom: 3px;color: rgb(193,
3838
<hr>
3939
<h2 class="text-start" style="font-size: 18px;margin-bottom: 10px;color: rgb(33,37,41);">Report False-Positive Form<span class="float-end" style="font-size: 10px;color: rgb(174,174,174);">FPR-01 / API V1</span></h2>
4040
{% autoescape false %} {{ alert_html }} {% endautoescape %}
41-
<form action="/api/v1/formreport" method="post" enctype="multipart/form-data">
41+
<form action="/api/v1/formreport?falsepositive=true" method="post" enctype="multipart/form-data">
4242
<input class="form-control" type="url" style="margin-bottom: 10px;" name="domain" placeholder="Domain" required>
4343
<textarea class="form-control" style="margin-bottom: 10px;" placeholder="Describe the site and its content and why it should be removed from our list..." name="description" required></textarea>
4444
<div style="text-align: left!important;">

templates/progress.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h1 class="text-start mb-0" style="margin-top: 4px;font-size: 20px;">Submission
3030
</div>
3131
<div class="card-body">
3232
<div class="progress" style="background: rgb(247,247,247);border-radius: 5px;border-width: 1px;border-style: none;height: 32px;font-size: 18px;margin-top: 15px;--bs-danger: rgb(193,31,32);--bs-danger-rgb: 193,31,32;">
33-
<div class="progress-bar bg-danger" aria-valuenow="{{ reviewed_percent }}" aria-valuemin="0" aria-valuemax="100" style="width: 42%;">{{ reviewed_percent }}%</div>
33+
<div class="progress-bar bg-danger" aria-valuenow="{{ reviewed_percent }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ reviewed_percent }}%;">{{ reviewed_percent }}%</div>
3434
</div>
3535
<p style="color: rgb(193,31,32);font-size: 14px;margin-bottom: 20px;margin-top: 5px;">{{ len_reviewed }} / {{ len_all }} Submissions marked as reviewed in current batch</p>
3636
<hr>

0 commit comments

Comments
 (0)