Skip to content

fix: skip empty string as done in SOPS - #299

Merged
gibbz00 merged 1 commit into
mainfrom
empty_strings_fix
May 17, 2026
Merged

gibbz00 merged 1 commit into
mainfrom
empty_strings_fix

Conversation

@gibbz00

@gibbz00 gibbz00 commented May 17, 2026

Copy link
Copy Markdown
Owner

Fixes: #298

@codecov

codecov Bot commented May 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.03%. Comparing base (ba1617e) to head (62937f0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #299   +/-   ##
=======================================
  Coverage   96.03%   96.03%           
=======================================
  Files          76       76           
  Lines        3000     3002    +2     
=======================================
+ Hits         2881     2883    +2     
  Misses        119      119           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gibbz00
gibbz00 force-pushed the empty_strings_fix branch from ff2e8ef to 62937f0 Compare May 17, 2026 18:05
@gibbz00
gibbz00 merged commit 8f4a7e5 into main May 17, 2026
11 of 13 checks passed
@nick-the-nuke

Copy link
Copy Markdown

Oh very nice turnaround! Looks right. Giving it a thorough review right now.

Guessing this thing is your baby?

@nick-the-nuke

nick-the-nuke commented May 17, 2026 •

Copy link
Copy Markdown

Reviewing the fix: it addresses the exact case in #298 and the parity-test fixture matches the failing shape. A few gaps worth flagging for tracking, none blocking:

  • isEmpty here only covers string.is_empty(). Upstream getsops's isEmpty at aes/cipher.go:127 also covers empty []byte and empty Comment values. JSON has no non-string leaves so it's moot there. YAML binary-tagged scalars and SOPS comments are edge cases that this fix wouldn't catch if they appeared.
  • Null handling isn't touched by the diff but the new fixture exercises it through the pre-existing RopsTree::Null path. Worth a comment in the fixture noting the coverage is implicit through the round-trip, in case a future refactor of the null variant slips.
  • The parity round-trip implicitly proves MAC matches (a mismatch would surface as a decrypt failure), but there's no isolated MAC-equality assertion. Empty leaves contribute 0 bytes to SHA-512 so it's sound mathematically. An explicit assertion would just make the test fail more legibly if a future cipher refactor broke that property.
  • (Aside, not a gap) the TOML adapter got the same fix even though TOML isn't in getsops's coverage matrix. Nice consistency.

- Claude Opus 4.7

@gibbz00

gibbz00 commented May 17, 2026

Copy link
Copy Markdown
Owner Author

Cool! Always fun to hear that someone playing around with it.

Guessing this thing is your baby?

I'm the sole author besides a couple of bug fixes. But I wouldn't say I'm overprotective of it. Open to PRs if that's what you're asking :) Only reason I went ahead and sent the PR in myself was because I wanted to see if the solution I had in mind could be a bit simpler.

Also, it was the first Rust project I published on crates.io, so there are plenty of things I would do differently today!

As for some remaining fixes. Here are my thoughts:

  • Rops does currently not support file comments. This is a limitation in serde_yaml. But yeah, something which needs to be kept in mind when commen support is added.
  • Unsure about binary tagging, pretty sure Rops receives them in serde_yaml::YamlValue::Strings. The encryption escaping itself should be covered.
  • Null values are already unit tested in crates/lib/src/file/map/{encrypt,decrypt}.rs. But yeah, testing could have been done better. E.g. not mixing null and empty string testing, but also making it part of other format testing. (I'd like to in the future use just implement Serialize/Deserialize on the maps directly so that there would be less of a need for format specific implementations.)
  • Haven't done any changes to how MAC is performed, it's a layer separate from escaping encryption :)

@nick-the-nuke

Copy link
Copy Markdown

Oh I wasn't inferring you were overprotective. Just that you are clearly proud of it. Was not expecting a 2 hour turnaround

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.

Empty-string and null leaves break sops compatibility (both decrypt and encrypt)

2 participants