Repository navigation
Conversation
tokenize splits RTK_DISABLED=$CI into two tokens (RTK_DISABLED= and $CI), so strip_disabled_prefix_for_analytics mistook $CI for the command word, found it unsupported, and fell back to strip_disabled_prefix, which never peels sudo. Walk coalesced words instead, keeping the whole assignment as one word, exactly as without_rtk_disabled already does. Fixes rtk-ai#4412
📊 Automated PR Analysis
SummaryFixes an undercounting bug in rtk discover where Review Checklist
Linked issues: #4412 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #4412.
rtk discoverundercountedsudo RTK_DISABLED=$VAR …bypasses: withhooks.transparent_prefixes = ["sudo", "sudo -E"],sudo RTK_DISABLED=1 docker psandRTK_DISABLED=1 sudo docker pswere counted as bypasses (#3808), but the same lines with an expanded value were not.Root cause
strip_disabled_prefix_for_analytics(src/discover/registry.rs) walked rawlexer::tokenizetokens, which split one shell word at$:RTK_DISABLED=$CIbecomes two tokens,RTK_DISABLED=and$CI. The walk treated$CIas the command word, found it unsupported, and fell back tostrip_disabled_prefix, which does not peelsudo. The counterfactual was then judged against thesudo-wrapped line, so no savings were reported.Fix
Walk
lexer::coalesce_wordsinstead, exactly aswithout_rtk_disabledinsrc/discover/mod.rsalready does. Coalescing keeps the whole assignment as one word while still splitting on spaces. The existing operator/redirect/shellism boundary logic is preserved via the coalesced-word spans.Tests
test_strip_disabled_prefix_for_analytics: added$CIvariants forsudo-first andsudo-after, plusRTK_DISABLED=$CI docker ps.test_disabled_segment_is_judged_as_typed_without_the_bypass: added end-to-end assertions thatsudo RTK_DISABLED=$CI docker psandRTK_DISABLED=$CI sudo docker pscount as bypasses whensudois transparent.Verification
A missed count, not a wrong one: this only adds lines that were previously omitted from the RTK_DISABLED bucket.