Skip to content

fix(compare): exclude git-ignored files and improve git command security#137

Merged
AmiteK23 merged 1 commit intomainfrom
feat/compare-filter-gitignored-files
Mar 7, 2026
Merged

fix(compare): exclude git-ignored files and improve git command security#137
AmiteK23 merged 1 commit intomainfrom
feat/compare-filter-gitignored-files

Conversation

@AmiteK23
Copy link
Member

@AmiteK23 AmiteK23 commented Mar 7, 2026

Description

Fix false positives in git baseline comparisons where git-ignored .ts / .tsx files (e.g. next-env.d.ts) appeared as added components.

Git-ignored files are now filtered from comparison results, ensuring accurate drift detection when files exist in the working directory but are not tracked by git.

Additional security improvement:

  • execGit() now uses spawn instead of exec
  • Prevents shell interpretation and reduces command injection risk
  • Correctly handles file paths with spaces and special characters

Type of Change

  • Bug fix
  • Feature
  • Breaking change
  • Docs
  • Refactor
  • CI / Tests
  • Performance
  • Other (please describe):

Architectural Impact

  • No contract/output changes
  • Contract/output changed (describe below)

Testing

  • Tested locally
  • Tests added/updated
  • All tests pass

Related Issues

Fixes false positives in git baseline comparison.


Checklist

  • Target branch is main
  • Self-reviewed
  • Docs updated
  • Changelog updated

Additional Notes

Adds isGitIgnored() and filterGitIgnoredFiles() utilities to ensure git-ignored files are excluded from comparison results and summary counts are recalculated correctly.

Security improvement: execGit() now uses spawn instead of exec, avoiding shell interpretation and reducing potential command injection risk when executing git commands with file paths or refs.

- Fix false positives where git-ignored files appeared as "added" components
- Filter git-ignored files from comparison results and recalculate counts
- Add isGitIgnored() and filterGitIgnoredFiles() utilities

Security: Refactor execGit() to use spawn instead of exec to prevent command
injection. spawn executes without shell interpretation and properly handles
file paths with spaces/special characters.
@AmiteK23 AmiteK23 merged commit 37b47fa into main Mar 7, 2026
7 checks passed
@AmiteK23 AmiteK23 deleted the feat/compare-filter-gitignored-files branch March 10, 2026 18:50
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