Keep the report and private permissions in roller-security case folders - start saves the report it is given as original-report.md (0600) and never overwrites an existing copy. - Folders the runner writes to are made 0700 with 0600 files, including ones created by hand or by an earlier version. - SKILL.md says what a case folder holds at each stage.
diff --git a/skills/roller-security/SKILL.md b/skills/roller-security/SKILL.md index f8acf3e..36ada1f 100644 --- a/skills/roller-security/SKILL.md +++ b/skills/roller-security/SKILL.md
@@ -130,6 +130,14 @@ - Reconcile `CVE_FORM.md` (including the generated draft the CLI appends) before using the CVE portal or drafting an advisory. +- Keep the report in the case folder as `original-report.md`. The runner saves + the text it was given; for a case recorded by hand, save the text or a summary + with the mail-thread link. Keep the case folder 0700 and its files 0600. The + runner tightens the folders it writes to; check folders created by hand. +- A case folder grows with the workflow: `original-report.md`, `IMPLEMENTATION.md` + and the case record at triage; `REPRODUCTION.md` once it is reproduced; + `CVE_FORM.md` after acceptance; reporter and advisory drafts when requested. + ## References and helpers - [ASF process](references/asf-process.md): policy sources and project decisions.
diff --git a/skills/roller-security/src/roller_security/graph.py b/skills/roller-security/src/roller_security/graph.py index af2f45f..fe83dd1 100644 --- a/skills/roller-security/src/roller_security/graph.py +++ b/skills/roller-security/src/roller_security/graph.py
@@ -44,6 +44,7 @@ read_skill_ref, run_check_private, run_maven_tests, + save_original_report, scaffold_case_dir, verify_archive_urls, verify_fix_commit_ancestor, @@ -264,6 +265,8 @@ report_path = state.get("raw_report_path", "") if not raw_text and report_path and Path(report_path).is_file(): raw_text = Path(report_path).read_text(encoding="utf-8") + if case_dir: + save_original_report(case_dir, raw_text, source=Path(report_path).name, dry_run=dry_run) extract_prompt = ( "Extract structured provenance facts from this private Apache Roller security report.\n"
diff --git a/skills/roller-security/src/roller_security/markdown_views.py b/skills/roller-security/src/roller_security/markdown_views.py index 4b10308..033bcc1 100644 --- a/skills/roller-security/src/roller_security/markdown_views.py +++ b/skills/roller-security/src/roller_security/markdown_views.py
@@ -26,6 +26,7 @@ from roller_security.state import ALL_MILESTONES, PROGRESS_STAGES, TERMINAL_STAGES from roller_security.store import derive_stage, stage_rank +from roller_security.tools import make_private GENERATED_BANNER = "<!-- Generated from SQLite by roller-security; do not edit manually -->" DISPLAY_STAGES: list[str] = PROGRESS_STAGES[:-1] + ["rejected", "complete"] @@ -173,6 +174,7 @@ case_dir = Path(case_dir_raw) if not case_dir.is_dir(): return None + make_private(case_dir) out_path = case_dir / "CASE.md" out_path.write_text(render_case_markdown(case), encoding="utf-8") out_path.chmod(0o600) @@ -352,7 +354,8 @@ ) -> Path: """Write <triage_dir>/SUMMARY_BOARD.md and return its path.""" root = Path(triage_dir) - root.mkdir(parents=True, exist_ok=True) + root.mkdir(mode=0o700, parents=True, exist_ok=True) + make_private(root, recursive=False) out_path = root / "SUMMARY_BOARD.md" out_path.write_text(render_board_markdown(cases, warnings), encoding="utf-8") out_path.chmod(0o600)
diff --git a/skills/roller-security/src/roller_security/tools.py b/skills/roller-security/src/roller_security/tools.py index 70e30cb..2bb5a04 100644 --- a/skills/roller-security/src/roller_security/tools.py +++ b/skills/roller-security/src/roller_security/tools.py
@@ -376,6 +376,7 @@ """Create ``case_dir`` and copy ``IMPLEMENTATION.md`` and ``CVE_FORM.md`` if absent. Intentionally omits ``TRACKING.md`` because SQLite + ``CASE.md`` replace it. + Existing folders are made private too (see ``make_private``). Returns the list of created file paths (or paths that would be created in dry-run). """ template_dir = _resolve_skill_root(repo_dir) / _SKILL_TEMPLATES_REL @@ -384,6 +385,8 @@ created: list[str] = [] if not dry_run: target_dir.mkdir(mode=0o700, parents=True, exist_ok=True) + make_private(target_dir.parent, recursive=False) + make_private(target_dir) for name in _SCAFFOLD_TEMPLATES: src = template_dir / name @@ -399,6 +402,47 @@ return created +def make_private(path: str | Path, *, recursive: bool = True) -> None: + """Make a private workspace folder 0700 and, when ``recursive``, its files 0600. + + ``mkdir(mode=...)`` and the umask only cover new paths, so folders created + by hand or by an earlier version stay readable by other users until this runs. + """ + root = Path(path) + if not root.is_dir(): + return + root.chmod(0o700) + if not recursive: + return + for item in root.rglob("*"): + if item.is_symlink(): + continue + item.chmod(0o700 if item.is_dir() else 0o600) + + +def save_original_report( + case_dir: str | Path, + raw_text: str, + *, + source: str = "", + dry_run: bool = False, +) -> str: + """Keep the report as received in ``<case_dir>/original-report.md`` (0600). + + Never overwrites: the PMC may have replaced the copy with a summary. + """ + if not case_dir or not raw_text.strip(): + return "" + dest = Path(case_dir) / "original-report.md" + if dest.exists() or dry_run: + return str(dest) + header = "# Original report\n\n> **PRIVATE.** As received" + header += f" from `{source}`.\n\n" if source else ".\n\n" + dest.write_text(header + "```text\n" + raw_text.rstrip("\n") + "\n```\n", encoding="utf-8") + dest.chmod(0o600) + return str(dest) + + def append_case_section( case_dir: str | Path, filename: str,
diff --git a/skills/roller-security/tests/test_cli_store_tools.py b/skills/roller-security/tests/test_cli_store_tools.py index b9b49ba..30b565a 100644 --- a/skills/roller-security/tests/test_cli_store_tools.py +++ b/skills/roller-security/tests/test_cli_store_tools.py
@@ -130,3 +130,38 @@ subprocess.run(["git", "-C", str(repo), "checkout", "-q", "-b", "main"], check=True) ok, log = tools.run_maven_tests(str(repo), [], branch="fix-branch") assert not ok and "not fix-branch" in log + + +def test_scaffold_makes_an_existing_case_folder_private(tmp_path): + triage = tmp_path / "triage" + case = triage / "01-example" + case.mkdir(parents=True) + triage.chmod(0o755) + case.chmod(0o755) + (case / "TRACKING.md").write_text("x", encoding="utf-8") + (case / "TRACKING.md").chmod(0o644) + tools.scaffold_case_dir(str(REPO), case) + assert triage.stat().st_mode & 0o777 == 0o700 + assert case.stat().st_mode & 0o777 == 0o700 + assert {f.name: f.stat().st_mode & 0o777 for f in case.iterdir()} == { + "TRACKING.md": 0o600, "IMPLEMENTATION.md": 0o600, "CVE_FORM.md": 0o600 + } + + +def test_original_report_is_kept_once_and_private(tmp_path): + path = tools.save_original_report(tmp_path, "line one\nline two", source="report.eml") + saved = Path(path) + assert saved.stat().st_mode & 0o777 == 0o600 + assert "line two" in saved.read_text(encoding="utf-8") + saved.write_text("PMC summary", encoding="utf-8") + tools.save_original_report(tmp_path, "different", source="report.eml") + assert saved.read_text(encoding="utf-8") == "PMC summary" + + +def test_start_saves_the_report_in_the_case_folder(tmp_path): + args = _start_args(tmp_path) + args.dry_run = False + cli.cmd_start(args) + reports = list((tmp_path / "triage").glob("*/original-report.md")) + assert len(reports) == 1 + assert "synthetic report" in reports[0].read_text(encoding="utf-8")