personal memory agent
0

Configure Feed

Select the types of activity you want to include in your feed.

fix(transparency): strip the minisign trusted-comment prefix

Real minisign signatures store line 3 as "trusted comment: <comment>", so both signer implementations now strip exactly that prefix and fail closed when it is absent.

The fake signer now emits the real four-line format. Previously it wrote an unprefixed line 3, which masked the real-format failure in parse_trusted_comment and the publisher verification path.

+55 -7
+29 -5
scripts/transparency_signing.py
··· 20 20 21 21 REQUIRED_MINISIGN_VERSION = "minisign 0.12" 22 22 MISSING_MINISIGN_MESSAGE = "transparency-minisign: minisign 0.12 is required; install it with: sudo dnf install minisign" 23 + TRUSTED_COMMENT_PREFIX = "trusted comment: " 23 24 24 25 25 26 class TransparencySigner(Protocol): ··· 76 77 ] 77 78 ) 78 79 return version 80 + 81 + 82 + def _extract_trusted_comment(line: str, *, malformed_error: str, repair: str) -> str: 83 + if not line.startswith(TRUSTED_COMMENT_PREFIX): 84 + raise DriverError( 85 + [ 86 + failure( 87 + malformed_error, 88 + expected=f"{TRUSTED_COMMENT_PREFIX}<trusted comment>", 89 + actual=line, 90 + repair=repair, 91 + ) 92 + ] 93 + ) 94 + return line[len(TRUSTED_COMMENT_PREFIX) :] 79 95 80 96 81 97 @dataclass ··· 180 196 text=True, 181 197 check=False, 182 198 ) 183 - comment = result.stdout.strip() 184 199 if result.returncode != 0: 185 200 raise DriverError( 186 201 [ ··· 194 209 ) 195 210 ] 196 211 ) 212 + comment = result.stdout.strip() 197 213 if comment != expected_trusted_comment: 198 214 raise DriverError( 199 215 [ ··· 219 235 ) 220 236 ] 221 237 ) 222 - return lines[2] 238 + return _extract_trusted_comment( 239 + lines[2], 240 + malformed_error="transparency minisign trusted comment line is malformed", 241 + repair="re-sign the transparency object with minisign 0.12", 242 + ) 223 243 224 244 225 245 @dataclass(frozen=True) ··· 244 264 ( 245 265 "untrusted comment: fake transparency signature", 246 266 base64.b64encode(digest).decode("ascii"), 247 - trusted_comment, 267 + f"trusted comment: {trusted_comment}", 248 268 f"trusted comment signature: {hashlib.sha256(digest).hexdigest()}", 249 269 "", 250 270 ) ··· 271 291 ) 272 292 ] 273 293 ) 274 - comment = lines[2] 294 + comment = self.trusted_comment(signature_path) 275 295 if comment != expected_trusted_comment: 276 296 raise DriverError( 277 297 [ ··· 313 333 ) 314 334 ] 315 335 ) 316 - return lines[2] 336 + return _extract_trusted_comment( 337 + lines[2], 338 + malformed_error="fake transparency trusted comment line is malformed", 339 + repair="re-sign the transparency object", 340 + )
+26 -2
tests/test_transparency_signing.py
··· 5 5 import pytest 6 6 7 7 from scripts.release_candidate_driver import DriverError 8 - from scripts.transparency_signing import FakeTransparencySigner 8 + from scripts.transparency_signing import TRUSTED_COMMENT_PREFIX, FakeTransparencySigner 9 9 10 10 11 11 def test_fake_signer_verifies_body_and_trusted_comment(tmp_path: Path) -> None: ··· 39 39 message.write_bytes(b'{"ok":1}\n') 40 40 signer.sign_file(message, signature, trusted_comment=comment) 41 41 lines = signature.read_text(encoding="utf-8").splitlines() 42 - assert lines[2] == comment 42 + assert len(lines) == 4 43 + assert lines[2] == f"{TRUSTED_COMMENT_PREFIX}{comment}" 43 44 assert signer.trusted_comment(signature) == comment 44 45 45 46 ··· 68 69 with pytest.raises(DriverError) as error: 69 70 signer.verify_file(message, signature, expected_trusted_comment="two") 70 71 assert error.value.failures[0].error == "fake transparency trusted comment mismatch" 72 + 73 + 74 + def test_fake_signer_rejects_missing_trusted_comment_prefix(tmp_path: Path) -> None: 75 + signer = FakeTransparencySigner() 76 + signature = tmp_path / "latest.json.minisig" 77 + signature.write_text( 78 + "\n".join( 79 + ( 80 + "untrusted comment: fake transparency signature", 81 + "ZmFrZQ==", 82 + "raw trusted comment", 83 + "trusted comment signature: fake", 84 + "", 85 + ) 86 + ), 87 + encoding="utf-8", 88 + ) 89 + with pytest.raises(DriverError) as error: 90 + signer.trusted_comment(signature) 91 + assert ( 92 + error.value.failures[0].error 93 + == "fake transparency trusted comment line is malformed" 94 + )