Commit c9cc33e
fix: validate zi repository identity before destructive git operations; automate checksum generation (#176)
* fix: validate zi repository identity before destructive git operations
- Add zi repository validation (zi.zsh sentinel + z-shell/zi remote URL check)
before git clean/reset/pull in the update path of install.sh
- Add BOPT validation to reject branch names containing '|', '\', or '&'
to prevent sed delimiter injection when updating init.zsh
- Update fake git test double to handle '-C <dir>' prefix and 'remote get-url'
- Add tests: valid zi clone update, foreign repo rejection, wrong-remote rejection
- Update public/checksum.txt to match modified install.sh
Fixes: #175
* fix: address code review feedback on security validation
- Fix BOPT backslash case pattern: *'\\'* → *\\* to correctly match
a single backslash (not two)
- Anchor the remote URL grep to 'github.com[/:]z-shell/zi' to prevent
spoofing via URLs like 'evil.com/fake-z-shell/zi'
- Validate remote subcommand args in the fake git test double
- Capture and assert specific error messages in rejection tests
- Update checksum for modified install.sh
* fix: address remaining code review issues
- Revert *'\''* (wrong: matches single-quote) back to *\\* (correct: matches
single backslash) and add clarifying comment explaining *\\* semantics
- Change test double error message from '$*' to a fixed descriptive string
- Update checksum for modified install.sh
* fix: strengthen URL matching with exact case pattern instead of grep
Replace partial grep match 'github.com[/:]z-shell/zi' with an exact
shell case pattern that accepts only the four canonical zi remote URLs:
- https://github.com/z-shell/zi
- https://github.com/z-shell/zi.git
- git@github.com:z-shell/zi
- git@github.com:z-shell/zi.git
This prevents spoofing via URLs like 'evil.com/github.com/z-shell/zi'
and eliminates false-positive risk on empty _zi_remote values.
* fix: add clarity improvements from code review
- Add actual args to test double error message for debuggability
- Add comment on canonical URL block pointing to z-shell/zi on GitHub
- Update checksum for modified install.sh
* fix: clarify test double error message for remote subcommand validation
Remove positional parameters from error message and add comment
explaining argument state after -C strip and cmd shift.
* chore: add automated checksum generation script and integrate into CI
- Add public/sh/generate-checksums.sh for local and CI use
- Update check-linux.yml and check-macos.yml to regenerate checksums
before the test run, keeping public/checksum.txt in sync automatically
* feat: automate checksum generation with generate-checksums.sh
Add public/sh/generate-checksums.sh that regenerates public/checksum.txt
using sha256sum (Linux) or shasum -a 256 (macOS). Integrate it into the
CI pipelines so checksums are never stale:
- check-linux.yml: run generate-checksums.sh before tests/installers.sh
- check-macos.yml: run generate-checksums.sh before tests/installers.sh
- checksum.yml: replace jmgilman/actions-generate-checksum action with
the new script; add generate-checksums.sh to trigger paths
Developers can now run `sh public/sh/generate-checksums.sh` locally
instead of manually updating public/checksum.txt after editing scripts.
* refactor: address code review feedback - minor clarity improvements
- tests/installers.sh: remove _sub/_arg temp variables in remote handler;
use $1/$2 directly in the condition (simpler, reviewer preference)
- public/sh/install.sh: reformat case pattern continuation so each line
ends with the | pipe rather than beginning with \; add comment naming
the four canonical URL forms (HTTPS/SSH, with/without .git suffix)
- public/sh/generate-checksums.sh: add comment on bare > redirection
explaining that it clears/creates the checksum file
- public/checksum.txt: regenerate after install.sh formatting change
* refactor: address second code review round - inline _zi_remote, rename _exit_code
- public/sh/install.sh: inline _zi_remote command substitution directly
into the case statement; eliminates the temporary variable
- tests/installers.sh: rename _exit_code to exit_code in two test
functions to match the no-leading-underscore convention used elsewhere
- public/checksum.txt: regenerate after install.sh change
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sal <59910950+ss-o@users.noreply.github.com>
* Checksum 83d3f57
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sal <59910950+ss-o@users.noreply.github.com>
* fix: satisfy shellcheck in checksum generator
* fix: remove remaining shellcheck warning
* chore: refresh installer checksum
* test: clarify fake git remote errors
* chore: address validation feedback
---------
Signed-off-by: Sal <59910950+ss-o@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Sal <59910950+ss-o@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: digital-teams[bot] <actions@zshell.dev> 196e21c1 parent b2ec0a0 commit c9cc33e
3 files changed
Lines changed: 71 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
39 | 50 | | |
40 | 51 | | |
41 | 52 | | |
| |||
147 | 158 | | |
148 | 159 | | |
149 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
150 | 175 | | |
151 | 176 | | |
152 | 177 | | |
| |||
0 commit comments