Fix unescaped quotes/newlines in YAML and gitconfig emitters #276

Merged
didericis merged 1 commits from fix/yaml-gitconfig-escape-special-chars into main 2026-06-25 04:32:25 -04:00
Collaborator

Closes #258.

Summary

  • egress.py: Added _yaml_str_escape helper and applied it to every manifest string interpolated into a double-quoted YAML scalar in egress_render_routes and _render_match_entry (host, auth_scheme, token_env, path values, header names/values, method names). A stray " no longer corrupts routes.yaml; a newline no longer splits a scalar across lines.
  • git_gate.py: Added _gitconfig_validate_value and called it on each Upstream value (and the derived host alias) before writing the insteadOf line. A newline in Upstream is rejected with a clear error rather than silently injecting arbitrary gitconfig keys.
  • Both fixes are covered by new unit tests in test_egress.py and test_provision_git.py.
Closes #258. ## Summary - **`egress.py`**: Added `_yaml_str_escape` helper and applied it to every manifest string interpolated into a double-quoted YAML scalar in `egress_render_routes` and `_render_match_entry` (host, auth_scheme, token_env, path values, header names/values, method names). A stray `"` no longer corrupts `routes.yaml`; a newline no longer splits a scalar across lines. - **`git_gate.py`**: Added `_gitconfig_validate_value` and called it on each `Upstream` value (and the derived host alias) before writing the `insteadOf` line. A newline in `Upstream` is rejected with a clear error rather than silently injecting arbitrary gitconfig keys. - Both fixes are covered by new unit tests in `test_egress.py` and `test_provision_git.py`.
didericis added 1 commit 2026-06-25 04:23:20 -04:00
fix: escape quotes/newlines in YAML and gitconfig emitters
test / unit (pull_request) Successful in 35s
test / integration (pull_request) Successful in 17s
lint / lint (push) Successful in 1m48s
test / unit (push) Successful in 32s
test / integration (push) Successful in 16s
Update Quality Badges / update-badges (push) Successful in 1m18s
515a95a79d
Closes #258.

`egress_render_routes` and `_render_match_entry` now pass all manifest
strings (host, auth_scheme, token_env, path/header values) through
`_yaml_str_escape` before interpolating into double-quoted YAML scalars,
preventing stray `"` or newlines from corrupting routes.yaml.

`git_gate_render_gitconfig` now calls `_gitconfig_validate_value` on
each Upstream value (and the derived alias) before writing the
`insteadOf` line, rejecting any value containing a newline that would
inject arbitrary gitconfig keys.
didericis force-pushed fix/yaml-gitconfig-escape-special-chars from 43e8c5244c to 515a95a79d 2026-06-25 04:23:20 -04:00 Compare
didericis merged commit 515a95a79d into main 2026-06-25 04:32:25 -04:00
didericis deleted branch fix/yaml-gitconfig-escape-special-chars 2026-06-25 04:32:25 -04:00
Sign in to join this conversation.