Add apm_cli to pyproject.toml and fix apm module url validation

This commit is contained in:
danielmeppiel
2025-09-17 14:31:54 +02:00
parent f9dc5f63b9
commit f6cae496a9
2 changed files with 9 additions and 1 deletions

View File

@@ -41,4 +41,4 @@ requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/specify_cli"]
packages = ["src/specify_cli", "src/apm_cli"]

View File

@@ -75,6 +75,10 @@ class DependencyReference:
if not dependency_str.strip():
raise ValueError("Empty dependency string")
# Check for control characters (newlines, tabs, etc.)
if any(ord(c) < 32 for c in dependency_str):
raise ValueError("Dependency string contains invalid control characters")
# Handle SSH URLs first (before @ processing) to avoid conflict with alias separator
original_str = dependency_str
if dependency_str.startswith("git@github.com:"):
@@ -192,6 +196,10 @@ class DependencyReference:
if not re.match(r'^[a-zA-Z0-9._-]+/[a-zA-Z0-9._-]+$', repo_url):
raise ValueError(f"Invalid repository format: {repo_url}. Expected 'user/repo'")
# Validate alias characters if present
if alias and not re.match(r'^[a-zA-Z0-9._-]+$', alias):
raise ValueError(f"Invalid alias: {alias}. Aliases can only contain letters, numbers, dots, underscores, and hyphens")
return cls(repo_url=repo_url, reference=reference, alias=alias)
def to_github_url(self) -> str: