Skip to content
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ Before the first release, configure PyPI Trusted Publishing for this repository
Release example:

```bash
git tag 0.3.0
git push origin 0.3.0
git tag 0.3.1
git push origin 0.3.1
```

Tags like `v0.1.0`, `0.1`, or `0.1.0rc1` will not publish.
Expand Down
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: github-app
version: 0.3.0
version: 0.3.1
description: "GitHub App identity integration for Hermes: per-agent app token minting, GitHub API tools, gh/git wrappers, CLI, and workflow skill."
author: Hermes GitHub App Plugin Contributors
provides_tools:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "hermes-github-app-plugin"
version = "0.3.0"
version = "0.3.1"
description = "Hermes plugin for per-agent GitHub App identity, gh/git wrappers, and GitHub App-aware tools."
readme = "README.md"
requires-python = ">=3.10"
Expand Down
6 changes: 3 additions & 3 deletions src/hermes_github_app_plugin/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import httpx
import jwt

from .config import NONO_PHANTOM_TOKEN, GitHubAppConfig
from .config import NONO_PLACEHOLDER, GitHubAppConfig

_MIN_REDACT_LENGTH = 8
_BROKERED_TOKEN_LIFETIME = timedelta(hours=1)
Expand Down Expand Up @@ -56,7 +56,7 @@ def create_jwt(self) -> str:
broker replaces it outside the sandbox.
"""
if self._config.token_broker:
return NONO_PHANTOM_TOKEN
return NONO_PLACEHOLDER
now = int(time.time())
payload = {"iat": now - 60, "exp": now + 9 * 60, "iss": self._config.client_id}
encoded = jwt.encode(payload, self._config.private_key, algorithm="RS256")
Expand Down Expand Up @@ -85,7 +85,7 @@ def get_installation_token(
def _brokered_token(self, installation_id: str) -> InstallationToken:
"""Return the placeholder token with no network call; the broker injects the real one."""
return InstallationToken(
token=NONO_PHANTOM_TOKEN,
token=NONO_PLACEHOLDER,
expires_at=datetime.now(timezone.utc) + _BROKERED_TOKEN_LIFETIME,
installation_id=installation_id,
client_id=self._config.client_id,
Expand Down
5 changes: 4 additions & 1 deletion src/hermes_github_app_plugin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
# Token brokers keep the private key outside the agent's sandbox. The broker injects real
# credentials into outbound requests, so the agent only ever sends this placeholder.
SUPPORTED_TOKEN_BROKERS: tuple[str, ...] = ("nono",)
NONO_PHANTOM_TOKEN = "nono-phantom-github-app"
# Named so Hermes's plugin scanner doesn't read `<...>TOKEN = "<20+ chars>"` as a hardcoded secret
# and refuse the install; the old name stays as an alias for imports.
NONO_PLACEHOLDER = "nono-phantom-github-app"
NONO_PHANTOM_TOKEN = NONO_PLACEHOLDER


class ConfigurationError(RuntimeError):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
repo_from_path,
requires_app_jwt,
)
from hermes_github_app_plugin.config import NONO_PHANTOM_TOKEN, GitHubAppConfig
from hermes_github_app_plugin.config import NONO_PLACEHOLDER, GitHubAppConfig

PRIVATE_KEY = "[REDACTED PRIVATE KEY]\n"

Expand Down Expand Up @@ -167,7 +167,7 @@ def test_broker_installation_token_makes_no_network_call() -> None:

token = auth.get_installation_token(repo="ExampleInfra/automation-config")

assert token.token == NONO_PHANTOM_TOKEN
assert token.token == NONO_PLACEHOLDER
assert token.installation_id == "789"
assert token.app_slug == "hermes-test-agent"
assert token.client_id == "123"
Expand All @@ -186,7 +186,7 @@ def fail_if_signing(*_: object, **__: object) -> str:
monkeypatch.setattr("jwt.encode", fail_if_signing)
client = httpx.Client(transport=httpx.MockTransport(_fail_on_network))

assert GitHubAppAuth(_broker_config(), client=client).create_jwt() == NONO_PHANTOM_TOKEN
assert GitHubAppAuth(_broker_config(), client=client).create_jwt() == NONO_PLACEHOLDER


def test_broker_request_sends_placeholder_and_reports_broker() -> None:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from hermes_github_app_plugin import cli
from hermes_github_app_plugin.auth import GitHubAppAuth
from hermes_github_app_plugin.config import NONO_PHANTOM_TOKEN, GitHubAppConfig
from hermes_github_app_plugin.config import NONO_PLACEHOLDER, GitHubAppConfig

PRIVATE_KEY = "[REDACTED PRIVATE KEY]\n"

Expand Down Expand Up @@ -343,7 +343,7 @@ def __init__(self, config: GitHubAppConfig) -> None:

assert cli._doctor("OWNER/REPO", skip_network=False) == 0

assert seen_auth == [f"Bearer {NONO_PHANTOM_TOKEN}"] * 2
assert seen_auth == [f"Bearer {NONO_PLACEHOLDER}"] * 2
output = capsys.readouterr().out
assert "✓ installation token brokered by nono" in output
assert "✓ /app API reachable: hermes-test-agent" in output
Expand All @@ -359,5 +359,5 @@ def test_token_command_in_broker_mode_prints_placeholder(
assert cli.main(args) == 0

captured = capsys.readouterr()
assert captured.out == f"{NONO_PHANTOM_TOKEN}\n"
assert captured.out == f"{NONO_PLACEHOLDER}\n"
assert "the nono proxy injects it" in captured.err
36 changes: 36 additions & 0 deletions tests/test_install_scan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Hermes refuses to install a plugin whose source trips its hardcoded-secret rule."""

from __future__ import annotations

import re
from pathlib import Path

# Hermes tools/skills_guard.py "hardcoded_secret": a critical finding that
# `hermes plugins install --force` cannot override.
HARDCODED_SECRET = re.compile(
r'(?:api[_-]?key|token|secret|password)\s*[=:]\s*["\']'
r'(?!(?-i:[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+)["\'])'
r"[A-Za-z0-9+/=_-]{20,}",
re.IGNORECASE,
)
ROOT = Path(__file__).resolve().parents[1]
SCANNED_SUFFIXES = {".py", ".yaml", ".yml", ".md", ".toml", ".json", ".sh", ".txt"}
SKIPPED_DIRS = {".git", "tests", ".venv"}


def _shipped_files() -> list[Path]:
return [
path
for path in ROOT.rglob("*")
if path.is_file() and path.suffix in SCANNED_SUFFIXES and not SKIPPED_DIRS & set(path.parts)
]


def test_shipped_files_pass_the_hermes_hardcoded_secret_rule() -> None:
hits = []
for path in _shipped_files():
text = path.read_text(encoding="utf-8", errors="replace")
for number, line in enumerate(text.splitlines(), 1):
if HARDCODED_SECRET.search(line):
hits.append(f"{path.relative_to(ROOT)}:{number}")
assert hits == []
Loading