Answer security round 1: 0 🔴, 0 🟡 (0 misread); refuse a malformed epic key and a comment that starts with a dash
CI / tests (pull_request) Successful in 3m44s

This commit is contained in:
Lilleman
2026-11-20 19:44:52 +01:00
parent 72a4d346d7
commit 9f367e90ca
4 changed files with 9 additions and 2 deletions
+3
View File
@@ -120,6 +120,7 @@ from git_cli.git_repo import CHUNK_BASE
from git_cli import epic_branch
from failure import Failure
from forge.commands import Forge, forge_of, gitea, Run, runner
from atlassian.jira import ISSUE_KEY
from project_config.main import located
from project_config.settings import ProjectConfig
from plan_store.plans import says_no_item
@@ -385,6 +386,8 @@ def review_asked(forge: Forge, number: str, run: Run, config: Config) -> str | N
def epic_opened(epic: str, title: str, body: str, run: Run, config: Config) -> str | Failure:
"""Bring the working branch of the epic with the key epic level with origin's default branch, then open its pull request into that branch, ready, for a person to merge."""
if not ISSUE_KEY.fullmatch(epic):
return Failure(f"{epic!r} is no epic's key, such as ABC-123")
loaded = config()
if isinstance(loaded, Failure):
return loaded
+2
View File
@@ -1150,6 +1150,8 @@ class EpicBranch(unittest.TestCase):
checkout = self.epic()
self.assertEqual(step(["open-epic", "ABC-1", "Ship\nit"], checkout, checkout.config), Failure("give a title of one line"))
self.assertEqual(step(["open-epic", "ABC-1"], checkout, checkout.config), Failure(USAGE))
self.assertEqual(step(["open-epic", "abc/../1", "Ship it"], checkout, checkout.config), Failure("'abc/../1' is no epic's key, such as ABC-123"))
self.assertEqual(checkout.ran, [])
self.assertEqual(checkout.ran, [])
+2 -2
View File
@@ -368,8 +368,8 @@ def language_fault(value: object) -> str | None:
def comment_fault(value: object) -> str | None:
"""Why value is no comment to post on a pull request; None where it is one."""
return None if isinstance(value, str) and value.strip() and "\n" not in value else 'not one line of text, such as "@coderabbitai review"'
"""Why value is no comment to post on a pull request; None where it is one. A forge's CLI would read one that starts with `-` as an option."""
return None if isinstance(value, str) and value.strip() and "\n" not in value and not value.startswith("-") else 'not one line of text that doesn\'t start with `-`, such as "@coderabbitai review"'
# Each one-value setting, in the order `project-config` lists them.
@@ -288,6 +288,8 @@ class LoadTest(ConfigCase):
self.assertIn("`review-request-comment` is set, so `epic-branch` must be set", self.failure())
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "{epic}"\nreview-request-comment = " "\n')
self.assertIn("`review-request-comment` is ' ', not one line of text", self.failure())
(self.home / ".claude-projects" / "acme" / "config.toml").write_text(CLIENT + 'epic-branch = "{epic}"\nreview-request-comment = "--help"\n')
self.assertIn("`review-request-comment` is '--help', not one line of text that doesn't start with `-`", self.failure())
def test_a_jira_plan_may_name_the_transition_and_status_that_finish_an_item(self) -> None:
self.write("acme", JIRA_CLIENT)