Skip to content

t304: Fix rm -rf on potentially empty variable in setup.sh#1187

Merged
marcusquinn merged 4 commits intomainfrom
feature/t304
Feb 12, 2026
Merged

t304: Fix rm -rf on potentially empty variable in setup.sh#1187
marcusquinn merged 4 commits intomainfrom
feature/t304

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 12, 2026

Summary

Addresses CodeRabbit security finding from PR#762 regarding rm -rf commands on potentially empty variables.

Changes

  • Added ${var:?} parameter expansion for critical variables (old_backup_dir, legacy_state_dir, tmp_preserve)
  • Added [[ -n "$var" ]] validation checks for loop variables (old_backup, path, venv_dir)
  • Added function-level validation for agents_dir in cleanup_deprecated_paths

Safety Improvements

All rm -rf commands with variables in setup.sh now have protection against empty variable expansion:

  • :? expansion causes immediate exit if variable is unset/empty
  • Explicit non-empty checks prevent execution if variable is empty
  • Function-level validation ensures base paths are valid before operations

Testing

  • Manual review of all rm -rf instances in setup.sh
  • Verified protection patterns are consistent and comprehensive
  • All changes preserve existing functionality while adding safety

Protected Instances

  1. Line 278: old_backup - protected with [[ -n "$old_backup" ]]
  2. Line 318: path - protected with [[ -e "$path" && -n "$path" ]]
  3. Lines 871, 900: old_backup_dir - protected with ${old_backup_dir:?}
  4. Line 981: legacy_state_dir - protected with ${legacy_state_dir:?}
  5. Lines 2948, 2958: tmp_preserve - protected with ${tmp_preserve:?}
  6. Line 3409: venv_dir - protected with [[ -n "$venv_dir" ]]

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 47 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t304

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@marcusquinn marcusquinn marked this pull request as ready for review February 12, 2026 00:54
@gemini-code-assist
Copy link

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

- Add validate_plugin_namespace() function to reject:
  - Empty namespaces
  - Absolute paths (starting with /)
  - Path traversal attempts (..)
  - Paths with slashes (must be single directory)
  - Non-alphanumeric characters (except - _ .)
- Validate namespaces when collecting plugin_namespaces array
- Validate disabled_ns before rm -rf in cleanup loop
- Validate pns before using in clone_dir path
- Addresses CodeRabbit security finding from PR#762
- All ShellCheck validations pass
- Manual testing confirms validation function correctly:
  - Accepts: alphanumeric, hyphens, underscores, dots
  - Rejects: empty, absolute paths, path traversal, slashes, special chars
- 13/13 test cases pass
Protect against potential empty variable expansion in rm -rf commands:
- Use ${var:?} expansion for old_backup_dir, legacy_state_dir, tmp_preserve
- Add [[ -n "$var" ]] check for old_backup in while loop
- Add agents_dir validation in cleanup_deprecated_paths

Addresses CodeRabbit security finding from PR#762.
Add validation for remaining rm -rf instances:
- Check path is non-empty in deprecated_paths cleanup loop
- Validate venv_dir before cleanup in error handler

Ensures comprehensive protection against empty variable expansion.
@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 15 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Feb 12 02:40:32 UTC 2026: Code review monitoring started
Thu Feb 12 02:40:32 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 15

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 15
  • VULNERABILITIES: 0

Generated on: Thu Feb 12 02:40:35 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

@marcusquinn marcusquinn merged commit 874bfc1 into main Feb 12, 2026
10 of 11 checks passed
marcusquinn added a commit that referenced this pull request Feb 12, 2026
Add escalating conflict resolution to rebase_sibling_pr():
1. Plain rebase (no conflicts)
2. Rebase with -Xtheirs (feature branch wins on conflicts)
3. AI CLI resolution for complex cases (Strategy 3 fallback)

Also adds:
- resolve_rebase_conflicts() for AI-assisted per-file resolution
- Stale worktree cleanup (abort stuck rebases, fix detached HEAD)
- Temp worktree creation when no worktree exists (avoids dirty tree)
- CONFLICTING added to t298 handler (was only BEHIND/DIRTY)
- Phase 7b: periodic retry of merge-conflict-blocked tasks (30min)

Tested: resolved 4 blocked PRs (#1171, #1187, #1188, #1191) that
were stuck with merge conflicts — all resolved with -Xtheirs.
@marcusquinn marcusquinn deleted the feature/t304 branch February 12, 2026 02:45
marcusquinn added a commit that referenced this pull request Feb 12, 2026
…1203)

Add escalating conflict resolution to rebase_sibling_pr():
1. Plain rebase (no conflicts)
2. Rebase with -Xtheirs (feature branch wins on conflicts)
3. AI CLI resolution for complex cases (Strategy 3 fallback)

Also adds:
- resolve_rebase_conflicts() for AI-assisted per-file resolution
- Stale worktree cleanup (abort stuck rebases, fix detached HEAD)
- Temp worktree creation when no worktree exists (avoids dirty tree)
- CONFLICTING added to t298 handler (was only BEHIND/DIRTY)
- Phase 7b: periodic retry of merge-conflict-blocked tasks (30min)

Tested: resolved 4 blocked PRs (#1171, #1187, #1188, #1191) that
were stuck with merge conflicts — all resolved with -Xtheirs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant