Answer security round 1: 0 🔴, 0 🟡 (0 misread); run rule-hook's config lookup through guarded git
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import functools
|
||||||
import hashlib
|
import hashlib
|
||||||
import pathlib
|
import pathlib
|
||||||
import subprocess
|
import subprocess
|
||||||
@@ -5,6 +6,7 @@ import sys
|
|||||||
|
|
||||||
from rule_hook.rules import Breach
|
from rule_hook.rules import Breach
|
||||||
from failure import Failure
|
from failure import Failure
|
||||||
|
from git_cli.git_repo import git
|
||||||
from rule_hook.git import guarded_git
|
from rule_hook.git import guarded_git
|
||||||
from project_config.main import located
|
from project_config.main import located
|
||||||
from release_plan import plan_file
|
from release_plan import plan_file
|
||||||
@@ -22,7 +24,7 @@ def todo_breaches(directory: str, own: pathlib.Path = OWN) -> list[Breach]:
|
|||||||
top = guarded_git(directory, "rev-parse", "--show-toplevel")
|
top = guarded_git(directory, "rev-parse", "--show-toplevel")
|
||||||
if isinstance(top, Failure):
|
if isinstance(top, Failure):
|
||||||
return []
|
return []
|
||||||
config = located(top, pathlib.Path.home())
|
config = located(top, pathlib.Path.home(), functools.partial(git, guarded=True))
|
||||||
if isinstance(config, Failure):
|
if isinstance(config, Failure):
|
||||||
# A checkout with a todo.md and no config is one whose config is still to write.
|
# A checkout with a todo.md and no config is one whose config is still to write.
|
||||||
return [Breach("todo-rank-check", config.reason, top)] if (pathlib.Path(top) / "todo.md").is_file() else []
|
return [Breach("todo-rank-check", config.reason, top)] if (pathlib.Path(top) / "todo.md").is_file() else []
|
||||||
|
|||||||
Reference in New Issue
Block a user