Skip to content

Harden internal git profiles against non-standard diff configs#593

Merged
svarlamov merged 3 commits intomainfrom
codex/unified-internal-git-profiles-hardening
Feb 26, 2026
Merged

Harden internal git profiles against non-standard diff configs#593
svarlamov merged 3 commits intomainfrom
codex/unified-internal-git-profiles-hardening

Conversation

@svarlamov
Copy link
Member

@svarlamov svarlamov commented Feb 26, 2026

Summary

  • introduce explicit internal git execution profiles (General, PatchParse, NumstatParse, RawDiffParse) and route parse-sensitive callsites through them
  • remove implicit command-name-based diff rewriting and replace it with explicit profile application at callsites
  • harden patch parsing for +++ headers to handle no-prefix/custom-prefix/mnemonic-style paths
  • add hostile diff.* config integration coverage for simple additions, diff, stats, and status
  • add centralized-spawn guard test to prevent direct internal git spawns outside approved helpers

Hardening fixes added after review

  • profile conflict stripping now only rewrites option tokens after the git subcommand and before --, so pathspec tokens are never dropped
  • NumstatParse now strips short rename/copy variants (-M*, -C*) so --no-renames cannot be overridden later in argv
  • continue_session patch-producing git show now uses PatchParse profile for stable output under hostile diff.* config

Validation

  • cargo test --lib numstat_profile_strips_short_rename_and_copy_flags
  • cargo test --lib profile_rewrite_does_not_strip_pathspec_tokens_after_double_dash
  • cargo test --tests --no-run
  • cargo test --test simple_additions test_simple_additions_with_base_commit_and_custom_diff_config -- --nocapture
  • cargo test --test diff test_diff_parsing_is_stable_under_hostile_diff_config -- --nocapture
  • cargo test --test stats test_stats_cli_range_with_hostile_diff_config -- --nocapture
  • cargo test --test status_ignore test_status_numstat_is_stable_under_hostile_diff_config -- --nocapture
  • cargo test --test internal_spawn_safety direct_git_command_spawns_are_centralized -- --nocapture
  • cargo test --test continue_session -- --nocapture
  • cargo fmt -- --check

Open with Devin

@git-ai-cloud-dev
Copy link

git-ai-cloud-dev bot commented Feb 26, 2026

Stats powered by Git AI

🧠 you    ████████████████████  100%
🤖 ai     ░░░░░░░░░░░░░░░░░░░░  0%
More stats
  • 0.0 lines generated for every 1 accepted
  • 0 seconds waiting for AI

AI code tracked with git-ai

@git-ai-cloud
Copy link

git-ai-cloud bot commented Feb 26, 2026

Stats powered by Git AI

🧠 you    ████████████████████  100%
🤖 ai     ░░░░░░░░░░░░░░░░░░░░  0%
More stats
  • 0.0 lines generated for every 1 accepted
  • 0 seconds waiting for AI

AI code tracked with git-ai

devin-ai-integration[bot]

This comment was marked as resolved.

@svarlamov svarlamov changed the title Harden internal git profiles against hostile diff config Harden internal git profiles against non-standard diff configs Feb 26, 2026
@svarlamov
Copy link
Member Author

Addressed Devin review in eb7fcc3c:

  • replaced PatchParse --default-prefix with portable canonical flags --src-prefix=a/ and --dst-prefix=b/ (works on older Git versions)
  • fixed conflict stripping for split-arg prefix forms (--src-prefix X, --dst-prefix X) so both flag and value are removed before canonical profile flags are applied
  • added/updated unit coverage for both behaviors

Re-running CI on latest head now.

@svarlamov svarlamov merged commit c5b07f9 into main Feb 26, 2026
52 of 63 checks passed
@svarlamov svarlamov deleted the codex/unified-internal-git-profiles-hardening branch February 26, 2026 15:47
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