Skip to content

Commit

Permalink
Remove cwe and cve roles (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria authored Oct 12, 2024
1 parent 1665732 commit 7a2838f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 72 deletions.
17 changes: 5 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@ Use the ``:commit:`` role to link to commits.
Fixed in :commit:`6bb9124d5e9dbb2f7b52864c3d8af7feb1b69403`.
Use the ``:cve:`` role to link to CVEs on https://cve.mitre.org.

.. code-block:: rst
:cve:`CVE-2018-17175` - Addresses possible vulnerability when...
.. code-block:: rst
Thanks to :user:`bitprophet` for the idea!
Expand All @@ -129,12 +123,6 @@ It can be also used in combination with a list:
Fix bad bug :issue:`123, (Duplicate) <199>`
Use the ``:cwe:`` role to link to CWEs on https://cwe.mitre.org.

.. code-block:: rst
:cwe:`CWE-787` - The software writes data past the end, or...
Use the ``:pypi:`` role to link to PyPI on https://pypi.org.

.. code-block:: rst
Expand All @@ -155,6 +143,11 @@ MIT licensed. See the bundled `LICENSE <https://github.com/sloria/sphinx-issues/
Changelog
*********

5.0.0 (unreleased)
------------------

- Remove `:cwe:` and `:cve:` roles, as these are officially included in Sphinx>=8.1.0.

4.1.0 (2024-04-14)
------------------

Expand Down
44 changes: 0 additions & 44 deletions src/sphinx_issues/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,6 @@
from sphinx.config import Config
from sphinx.util.nodes import split_explicit_title


def cve_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a CVE on https://cve.mitre.org.
Examples: ::
:cve:`CVE-2018-17175`
"""
options = options or {}
content = content or []
has_explicit_title, title, target = split_explicit_title(text)

target = utils.unescape(target).strip()
title = utils.unescape(title).strip()
ref = f"https://cve.mitre.org/cgi-bin/cvename.cgi?name={target}"
text = title if has_explicit_title else target
link = nodes.reference(text=text, refuri=ref, **options)
return [link], []


GITHUB_USER_RE = re.compile("^https://github.com/([^/]+)/([^/]+)/.*")


Expand Down Expand Up @@ -165,27 +144,6 @@ def _get_uri(
) from e


def cwe_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a CWE on https://cwe.mitre.org.
Examples: ::
:cwe:`CWE-787`
"""
options = options or {}
content = content or []
has_explicit_title, title, target = split_explicit_title(text)

target = utils.unescape(target).strip()
title = utils.unescape(title).strip()
number = target[4:]
ref = f"https://cwe.mitre.org/data/definitions/{number}.html"
text = title if has_explicit_title else target
link = nodes.reference(text=text, refuri=ref, **options)
return [link], []


def pypi_role(name, rawtext, text, lineno, inliner, options=None, content=None):
"""Sphinx role for linking to a PyPI on https://pypi.org/.
Expand Down Expand Up @@ -402,8 +360,6 @@ def setup(app):
app.add_role("pr", pr_role)
app.add_role("user", user_role)
app.add_role("commit", commit_role)
app.add_role("cve", cve_role)
app.add_role("cwe", cwe_role)
app.add_role("pypi", pypi_role)
return {
"version": importlib.metadata.version("sphinx-issues"),
Expand Down
16 changes: 0 additions & 16 deletions tests/test_sphinx_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

from sphinx_issues import (
commit_role,
cve_role,
cwe_role,
issue_role,
pr_role,
pypi_role,
Expand Down Expand Up @@ -95,20 +93,6 @@ def inliner(app):
"Steven Loria",
"https://github.com/sponsors/sloria",
),
(
cve_role,
"cve",
"CVE-2018-17175",
"CVE-2018-17175",
"https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-17175",
),
(
cwe_role,
"cve",
"CWE-787",
"CWE-787",
"https://cwe.mitre.org/data/definitions/787.html",
),
(
pypi_role,
"pypi",
Expand Down

0 comments on commit 7a2838f

Please sign in to comment.