Conversation
added 10 commits
July 27, 2026 04:50
- Project setup with package.json, tsconfig.json, build config - Config reader module: parse permission.bash and external_directory - Chain detection: unbash AST parsing with segment extraction - Path extraction: word tokens, Fig specs, absolute path resolution - Enforcement: segment resolution, aggregation, dual-hook pattern - 51 unit tests across all modules - README with install, prerequisite, and limitations docs - LICENSE (MIT)
…ehavior; ci: type-check before test
Redirects (2>&1, >/dev/null, > file, etc.) were invisible to the plugin because unbash stores them in cmd.redirects, not cmd.suffix. This meant the reconstructed command text silently dropped redirects, bypassing all security checks. Changes: - chain.ts: include redirects in ChainSegment with wellKnown flag (FD redirects, /dev/null, heredocs are well-known; file redirects are not) - config.ts: add permission.edit rule parsing - enforce.ts: check non-well-known redirect targets against edit rules; if the target is outside cwd, also check external_directory - Tests added for redirect parsing and enforcement
| @@ -97,4 +97,52 @@ describe("parseChain", () => { | |||
| expect(result.segments).toHaveLength(0); | |||
There was a problem hiding this comment.
Consider adding more edge cases to test the parsing of various redirect formats.
| const actions: ChainAction[] = []; | ||
|
|
||
| for (const redir of redirects) { | ||
| if (redir.wellKnown) continue; |
There was a problem hiding this comment.
Ensure 'editRules' are properly populated in all tests; currently it's sometimes empty.
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.
Redirects (
2>&1,>/dev/null,> file, etc.) were invisible to the plugin becauseunbashstores them incmd.redirects, notcmd.suffix. The reconstructed command text silently dropped redirects, bypassing all security checks.Changes
src/chain.ts: AddedRedirectInfointerface andredirectsfield toChainSegment. Redirect operators and targets are now included ingetCommandText. Statement-level redirects ({ echo hi; } > file) are captured too.src/config.ts: AddededitRulestoPluginConfig, parsed frompermission.edit.src/enforce.ts: NewresolveRedirectTargets()function:2>&1,/dev/null, heredocs) → always allowedcwd→ checked againsteditRulesonlycwd→ checked againsteditRulesandexternal_directoryTests
7 new redirect enforcement tests + 6 new chain parsing tests. All 71 tests pass.