From a04f178bb85438201937a5f7bfb44d80be7cec70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Bonhomme?= Date: Wed, 11 Dec 2024 11:27:03 +0100 Subject: [PATCH] chg: [RELEASE] Bumped version to 0.5.5. Templates are now in the configuration file. --- fedivuln/conf_sample.py | 11 +++++++++++ fedivuln/config.py | 1 + fedivuln/publish.py | 14 +------------- pyproject.toml | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fedivuln/conf_sample.py b/fedivuln/conf_sample.py index a96ca33..43ae38f 100644 --- a/fedivuln/conf_sample.py +++ b/fedivuln/conf_sample.py @@ -11,3 +11,14 @@ vulnerability_lookup_base_url = "https://vulnerability.circl.lu/" vulnerability_auth_token = "" + + +# Templates used when publishing status +templates = { + "vulnerability": "You can now share your thoughts on vulnerability " + " in Vulnerability-Lookup:\n\n\n#VulnerabilityLookup #Vulnerability #Cybersecurity #bot", + "comment": "Vulnerability has received a comment on " + "Vulnerability-Lookup:\n\n\n<LINK>\n\n#VulnerabilityLookup #Vulnerability #Cybersecurity #bot", + "bundle": "A new bundle, <BUNDLETITLE>, has been published " + "on Vulnerability-Lookup:\n<LINK>\n\n#VulnerabilityLookup #Vulnerability #Cybersecurity #bot", +} diff --git a/fedivuln/config.py b/fedivuln/config.py index 5dffb60..8670466 100644 --- a/fedivuln/config.py +++ b/fedivuln/config.py @@ -32,6 +32,7 @@ def load_config(path): app_name = conf.app_name mastodon_clientcred = conf.mastodon_clientcred mastodon_usercred = conf.mastodon_usercred + templates = conf.templates # For PyVulnerabilityLookup vulnerability_lookup_base_url = conf.vulnerability_lookup_base_url diff --git a/fedivuln/publish.py b/fedivuln/publish.py index 1a089c8..59fe932 100644 --- a/fedivuln/publish.py +++ b/fedivuln/publish.py @@ -22,22 +22,10 @@ ) -# ### Templates - -TEMPLATES = { - "vulnerability": "You can now share your thoughts on vulnerability " - "<VULNID> in Vulnerability-Lookup:\n<LINK>\n\n#VulnerabilityLookup #Vulnerability", - "comment": "Vulnerability <VULNID> has received a comment on " - "Vulnerability-Lookup:\n\n<TITLE>\n<LINK>\n\n#VulnerabilityLookup #Vulnerability", - "bundle": "A new bundle, <BUNDLETITLE>, has been published " - "on Vulnerability-Lookup:\n<LINK>\n\n#VulnerabilityLookup #Vulnerability", -} - - def create_status_content(event_data: str, topic: str) -> str: """Generates a status update for posting based on the monitored topic.""" event_dict = json.loads(event_data) - status = TEMPLATES.get(topic, "") + status = config.templates.get(topic, "") match topic: case "vulnerability": status = status.replace("<VULNID>", event_dict["payload"]["vulnerability"]) diff --git a/pyproject.toml b/pyproject.toml index 9da04f9..088f6ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "FediVuln" -version = "0.5.4" +version = "0.5.5" description = "A client to gather vulnerability-related information from the Fediverse." authors = ["Cédric Bonhomme <cedric@cedricbonhomme.org>"] license = "GPL-3.0-or-later"