Skip to content
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
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: v8.3.0
_commit: v8.3.1
_src_path: gh:eccenca/cmem-plugin-template
author_mail: cmempy-developer@eccenca.com
author_name: eccenca GmbH
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](https://semver.org/)


## [2.2.3] 2026-01-27

### Changed

- Update template to 8.3.1.
- Relax URN URI validation.

## [2.2.2] 2026-01-27

### Fixed
Expand Down
11 changes: 7 additions & 4 deletions cmem_plugin_reason/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Common constants and functions"""

import json
import re
import shlex
from collections import OrderedDict
from datetime import UTC, datetime
from io import BytesIO
from pathlib import Path
from re import IGNORECASE, match
from secrets import token_hex
from subprocess import CompletedProcess, run
from time import time
Expand Down Expand Up @@ -40,7 +40,7 @@
)

MAX_RAM_PERCENTAGE_DEFAULT = 20

URN_PATTERN = re.compile(r"^urn:[a-zA-Z0-9][a-zA-Z0-9-]*(:.+)?$", re.IGNORECASE)

REASONER_PARAMETER = PluginParameter(
param_type=ChoiceParameterType(REASONERS),
Expand Down Expand Up @@ -273,5 +273,8 @@ def is_valid_uri(uri: str | None) -> bool:
"""Validate URI"""
if not isinstance(uri, str):
return False
urn_pattern = r"^urn:[a-zA-Z0-9][a-zA-Z0-9-]{1,31}:.+$"
return validators.url(uri) is True or bool(match(urn_pattern, uri, IGNORECASE))

if uri.lower().startswith("urn:"):
return bool(URN_PATTERN.match(uri))

return validators.url(uri) is True
237 changes: 118 additions & 119 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ version = ">=24.2.0"
deptry = "^0.24.0"
genbadge = {extras = ["coverage"], version = "^1.1.3"}
mypy = "^1.19.1"
pip = "^26.0"
pip = "^26"
pytest = "^9.0.2"
pytest-cov = "^7.0.0"
pytest-dotenv = "^0.5.2"
pytest-html = "^4.2.0"
pytest-memray = { version = "^1.8.0", markers = "platform_system != 'Windows'" }
ruff = "^0.14.13"
trivy-py-ecc = "^0.68"
ruff = "^0.15.0"
trivy-py-ecc = "^0.68.2.1"

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning"]
Expand Down
21 changes: 18 additions & 3 deletions tests/test_is_valid_uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,25 @@ def test_graph_parameter_url_fail() -> None:


def test_graph_parameter_urn() -> None:
"""Test validation of URN"""
"""Test validation of URN (1)"""
assert is_valid_uri("urn:isbn:9780134685991")


def test_graph_parameter_urn_invalid() -> None:
def test_graph_parameter_urn_2() -> None:
"""Test validation of URN (2)"""
assert is_valid_uri("urn:x:9780134685991")


def test_graph_parameter_urn_3() -> None:
"""Test validation of URN (3)"""
assert is_valid_uri("urn:x")


def test_graph_parameter_empty() -> None:
"""Test validation of URN - fail"""
assert not is_valid_uri("urn:x:9780134685991")
assert not is_valid_uri("")


def test_graph_parameter_none() -> None:
"""Test validation of URN - fail 2"""
assert not is_valid_uri(None)
150 changes: 0 additions & 150 deletions trivy_to_junit.py

This file was deleted.