Repository navigation
Conversation
rstrip(".git") strips the trailing character SET {'.','g','i','t'}, not
the literal ".git" suffix, so any repo whose name ends in '.', 'g', 'i'
or 't' is silently mangled (e.g. audit->aud, rustkit->rustk, my-bot->my-bo,
toolkit->toolki). repo_name feeds report["repo_name"] which is hashed into
the BCOS commitment and cert_id, so the attestation certifies the wrong
repository identity for a large class of real repos.
Fix: rstrip('/') then remove an exact '.git' suffix. Add regression test
covering names ending in the .git charset (fails on main, passes here);
existing bcos suite stays green (19 passed).
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
|
/claim Fixes the |
|
Maintainer validation: all 19 focused BCOS tests pass locally. Replacing |
RTC RewardThis merged PR earned 5 RTC — sent to |
…epo_name (#7955) (#7998) * test(bcos): add regression test for .git suffix stripping Add test_detect_repo_name_strips_dotgit_suffix_not_chars to verify that repos like audit, test, gigi are not truncated by the old rstrip('.git') bug which stripped individual characters instead of the exact suffix. Refs #7955 * test(bcos): add no-suffix and SSH coverage for _detect_repo_name regression Address @elianguitarra review feedback: - Add no-suffix URL cases ending in t/i/g (my-bot, toolkit) to ensure rstrip('/') + exact-suffix matching is preserved. - Add SSH remote cases (git@github.com:owner/repo.git) to confirm both URL branches are protected by the fix. Refs #7955
Problem
BCOSEngine._detect_repo_name()(tools/bcos_engine.py) derives the repo name from the git remote with:str.rstrip(".git")does not remove the.gitsuffix — it strips every trailing character that is a member of the set{'.', 'g', 'i', 't'}, greedily. So any repository whose name ends in.,g,i, ortis silently mangled:github.com/acme/audit.gitacme/audacme/auditgithub.com/scottcjn/rustkit.gitscottcjn/rustkscottcjn/rustkitgithub.com/acme/my-botacme/my-boacme/my-botgithub.com/acme/toolkitacme/toolkiacme/toolkitgithub.com/acme/rustchain-clientacme/rustchain-clienacme/rustchain-clientThe trigger class is broad (
-kit,-bot,-client,-agent,-test,audit,commit,unit,circuit,orbit,toolkit, …).Impact
_detect_repo_name()setsreport["repo_name"]inrun_all(), and the full report is serialized and hashed into the on-chain commitment and certificate id:So a BCOS trust attestation certifies a repository under a corrupted name, and the wrong name is bound into the commitment /
cert_idfor a large fraction of real repos.Fix
Tests
Added
test_repo_name_detection_preserves_names_ending_in_git_charsetcovering names ending in the.gitcharset. It fails onmain(assert 'acme/aud' == 'acme/audit') and passes with the fix. The existing bcos suite stays green: