Harden M9: Ed25519 attestation, full SHA-256 integrity, locked-by-default, prompt improvements, registry verification
This commit is contained in:
+31
-7
@@ -44,12 +44,14 @@ class TestIntegrityChain:
|
||||
)
|
||||
chain = build_integrity_chain(tool)
|
||||
assert "missing-dep" not in chain.nodes
|
||||
# Chain is still valid because the dependency hash is "unresolved"
|
||||
# and there's no node to compare against
|
||||
assert chain.is_valid
|
||||
assert not chain.is_valid
|
||||
assert chain.errors == ["Unresolved dependency: missing-dep"]
|
||||
|
||||
def test_chain_valid_with_resolved_dep(self, tmp_path):
|
||||
with patch("cmdforge.tool.TOOLS_DIR", tmp_path / ".cmdforge"):
|
||||
with (
|
||||
patch("cmdforge.tool.TOOLS_DIR", tmp_path / ".cmdforge"),
|
||||
patch("cmdforge.tool.BIN_DIR", tmp_path / "bin"),
|
||||
):
|
||||
from cmdforge.tool import save_tool
|
||||
|
||||
child = Tool(name="child", version="1.0.0")
|
||||
@@ -67,13 +69,35 @@ class TestIntegrityChain:
|
||||
assert "child" in chain.nodes
|
||||
assert chain.is_valid
|
||||
|
||||
def test_child_change_changes_root_identity(self, tmp_path):
|
||||
with (
|
||||
patch("cmdforge.tool.TOOLS_DIR", tmp_path / ".cmdforge"),
|
||||
patch("cmdforge.tool.BIN_DIR", tmp_path / "bin"),
|
||||
):
|
||||
from cmdforge.tool import save_tool
|
||||
child = Tool(name="child", version="1.0.0", output="one")
|
||||
save_tool(child)
|
||||
parent = Tool(
|
||||
name="parent", version="1.0.0",
|
||||
steps=[ToolStep(tool="child", output_var="x")], output="{x}",
|
||||
)
|
||||
first = build_integrity_chain(parent).root.content_hash
|
||||
child.output = "two"
|
||||
save_tool(child)
|
||||
second = build_integrity_chain(parent).root.content_hash
|
||||
assert first != second
|
||||
|
||||
|
||||
class TestVerifyIntegrity:
|
||||
def test_valid_chain(self):
|
||||
chain = IntegrityChain(
|
||||
root=IntegrityNode(name="root", content_hash="abc"),
|
||||
nodes={"root": IntegrityNode(name="root", content_hash="abc")},
|
||||
from cmdforge.integrity import compute_content_identity
|
||||
definition_hash = "sha256:" + "a" * 64
|
||||
content_hash = compute_content_identity(definition_hash, {})
|
||||
node = IntegrityNode(
|
||||
name="root", definition_hash=definition_hash,
|
||||
content_hash=content_hash,
|
||||
)
|
||||
chain = IntegrityChain(root=node, nodes={"root": node})
|
||||
assert verify_integrity(chain)
|
||||
|
||||
def test_tampered_chain(self):
|
||||
|
||||
Reference in New Issue
Block a user