From: Michael Tremer Date: Tue, 30 Dec 2025 12:09:48 +0000 (+0000) Subject: dnsbl: Add a simple page to view a report X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ed02a86a35b52b6e37172709fe154c41d500c1c;p=ipfire.org.git dnsbl: Add a simple page to view a report Signed-off-by: Michael Tremer --- diff --git a/Makefile.am b/Makefile.am index a6f3ff7b..e2f8cef0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -187,6 +187,7 @@ templates_dnsbl_DATA = \ src/templates/dnsbl/index.html \ src/templates/dnsbl/list.html \ src/templates/dnsbl/report.html \ + src/templates/dnsbl/report-submit.html \ src/templates/dnsbl/report-submitted.html templates_dnsbldir = $(templatesdir)/dnsbl diff --git a/src/backend/dnsbl.py b/src/backend/dnsbl.py index 8ce3274a..fee08242 100644 --- a/src/backend/dnsbl.py +++ b/src/backend/dnsbl.py @@ -6,6 +6,7 @@ import logging import pydantic import tornado.httpclient import urllib.parse +import uuid from . import accounts from . import base @@ -69,6 +70,25 @@ class DNSBL(Object): # Return the list return List(self.backend, **response) + # Reports + + async def get_report(self, id): + """ + Fetches a report + """ + try: + response = await self._fetch("/reports/%s" % id) + + # Return nothing if we received 404 + except tornado.httpclient.HTTPClientError as e: + if e.code == 404: + return + + raise e + + # Return the report + return Report(self.backend, **response) + class Model(pydantic.BaseModel): """ @@ -210,8 +230,11 @@ class Report(Model): """ Represents a report """ + def __str__(self): + return self.name + # ID - id : int + id : uuid.UUID # Name name : str diff --git a/src/templates/dnsbl/report-submit.html b/src/templates/dnsbl/report-submit.html new file mode 100644 index 00000000..93a623c6 --- /dev/null +++ b/src/templates/dnsbl/report-submit.html @@ -0,0 +1,162 @@ +{% extends "../base.html" %} + +{% block title %} + {{ _("IPFire DNSBL") }} {{ _("Report A Domain") }} +{% end block %} + +{% block head %} + {% module OpenGraph( + title=_("Report A Domain"), + description=_("Help Us To Improve IPFire DNSBL"), + ) %} +{% end block %} + +{% block container %} +
+
+
+

+ {{ _("Help Us To Improve IPFire DNSBL") }} +

+ +

+ {{ _("Report anything that we have missed") }} +

+
+
+
+ +
+
+ {# Show a note to users that are not logged in #} + {% if not current_user %} +
+ {{ _("Please log in to submit a report") }} + +
+ + To keep the IPFire DNSBL accurate and trustworthy, domain reports + can only be submitted by logged-in users. + This helps us prevent spam and abuse, and ensures that every report + comes from a real, accountable community member. +
+ {% end %} + +
+ {% raw xsrf_form_html() %} + +
+ {# List #} +
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+ + {# Name #} +
+
+ +
+ +
+
+

+ +

+
+
+
+ + {# Block? #} +
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+ + {# Comment #} +
+
+ +
+ +
+
+

+ +

+ +

+ Please provide any additional context that may help us review this domain. + For example, where you encountered it or why you believe it should be (de-)listed. +

+ +

+ By submitting your report, you grant the IPFire Project the right to store, + process, and publish this information as part of its security services, + including the IPFire DNSBL under the terms of the respective list. + Submissions may be reviewed, modified, or removed at our discretion. +

+
+
+
+ + {# Submit! #} +
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+
+
+{% end block %} diff --git a/src/templates/dnsbl/report.html b/src/templates/dnsbl/report.html index 93a623c6..d1913561 100644 --- a/src/templates/dnsbl/report.html +++ b/src/templates/dnsbl/report.html @@ -1,162 +1,41 @@ {% extends "../base.html" %} {% block title %} - {{ _("IPFire DNSBL") }} {{ _("Report A Domain") }} + {{ _("IPFire DNSBL") }} {{ _("Report %s") % report }} {% end block %} {% block head %} {% module OpenGraph( - title=_("Report A Domain"), - description=_("Help Us To Improve IPFire DNSBL"), + title=_("Report %s") % report, ) %} {% end block %} {% block container %} -
+
-
-

- {{ _("Help Us To Improve IPFire DNSBL") }} -

- -

- {{ _("Report anything that we have missed") }} -

-
-
-
- -
-
- {# Show a note to users that are not logged in #} - {% if not current_user %} -
- {{ _("Please log in to submit a report") }} - -
- - To keep the IPFire DNSBL accurate and trustworthy, domain reports - can only be submitted by logged-in users. - This helps us prevent spam and abuse, and ensures that every report - comes from a real, accountable community member. -
- {% end %} - -
- {% raw xsrf_form_html() %} - -
- {# List #} -
-
- -
- -
-
-
-
- -
-
-
-
-
- - {# Name #} -
-
- -
- -
-
-

- -

-
-
-
- - {# Block? #} -
-
- -
- -
-
-
-
- -
-
-
+
+
+
+
+

+ {{ report.name }} +

+ +

+ {{ _("Submitted %(when)s by %(who)s") % { + "when" : locale.format_date(report.reported_at), + "who" : report.reported_by, + } }} +

+ + {# Comment #} + {% if report.comment %} +
{{ report.comment }}
+ {% end %}
- - {# Comment #} -
-
- -
- -
-
-

- -

- -

- Please provide any additional context that may help us review this domain. - For example, where you encountered it or why you believe it should be (de-)listed. -

- -

- By submitting your report, you grant the IPFire Project the right to store, - process, and publish this information as part of its security services, - including the IPFire DNSBL under the terms of the respective list. - Submissions may be reviewed, modified, or removed at our discretion. -

-
-
-
- - {# Submit! #} -
-
- -
- -
-
-
- -
-
-
-
-
-
+
+
{% end block %} diff --git a/src/web/__init__.py b/src/web/__init__.py index 725c038b..67b25f08 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -216,7 +216,8 @@ class Application(tornado.web.Application): # DNSBL (r"/dnsbl/?", dnsbl.IndexHandler), (r"/dnsbl/lists/(\w+)", dnsbl.ListHandler), - (r"/dnsbl/report", dnsbl.ReportHandler), + (r"/dnsbl/report", dnsbl.SubmitReportHandler), + (r"/dnsbl/reports/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})", dnsbl.ReportHandler), # Single-Sign-On for Discourse (r"/sso/discourse", auth.SSODiscourse), diff --git a/src/web/dnsbl.py b/src/web/dnsbl.py index 12dd9eac..85f66a4f 100644 --- a/src/web/dnsbl.py +++ b/src/web/dnsbl.py @@ -35,13 +35,13 @@ class ListHandler(base.AnalyticsMixin, BaseHandler): self.render("dnsbl/list.html", list=list, sources=sources) -class ReportHandler(base.AnalyticsMixin, BaseHandler): +class SubmitReportHandler(base.AnalyticsMixin, BaseHandler): async def get(self): # Fetch all lists lists = await self.backend.dnsbl.get_lists() # Render the page - self.render("dnsbl/report.html", lists=lists) + self.render("dnsbl/report-submit.html", lists=lists) @tornado.web.authenticated #@base.ratelimit(minutes=60, requests=10) @@ -61,6 +61,16 @@ class ReportHandler(base.AnalyticsMixin, BaseHandler): self.render("dnsbl/report-submitted.html", report=report) +class ReportHandler(base.AnalyticsMixin, BaseHandler): + async def get(self, id): + # Fetch the report + report = await self.backend.dnsbl.get_report(id) + if not report: + raise tornado.web.HTTPError(404, "Could not find report '%s'" % id) + + self.render("dnsbl/report.html", report=report) + + class ListsModule(ui_modules.UIModule): def render(self, lists): return self.render_string("dnsbl/modules/lists.html", lists=lists)