sops icon indicating copy to clipboard operation
sops copied to clipboard

`sops` rewrites YAML tree containing references

Open yingzong opened this issue 9 years ago • 5 comments

Something like: a: &a something b: *a

Will rewrite the file without references to: a: something b: something

I think the parser does this, but is there a way to turn that off?

yingzong avatar Jun 20 '17 22:06 yingzong

You can't use YAML references in sops, because we calculate a MAC on the entire tree. If you want to treat this as a string, you could protect it with quotes.

jvehent avatar Jun 20 '17 22:06 jvehent

References are not strings but they are part of the non-key portions in a YAML. I may be missing something, but why can't the MAC be calculated on the whole tree, even without dereferencing?

yingzong avatar Jun 20 '17 22:06 yingzong

I'm reopening this because, now that I think of it, I wonder if we could work around the parser to make this work. @autrilla : what do you think?

jvehent avatar Jun 21 '17 15:06 jvehent

MAC computation would require either dereferencing, or some sort of special case. In the end, we're hashing bytes for the MAC, so as an example we could just have anchors hashed as "reference to X", but then we'd have to protect against the reference being replaced by just "reference to X", so imo we should dereference.

Dereferencing while keeping the anchor in the output document would probably require some serious modification to go-yaml, which I don't expect would ever be merged. And at this point, maybe we should consider operating at the YAML token level instead of at the data level.

autrilla avatar Jun 21 '17 17:06 autrilla

Closing as there are no plans to make this work. If anything, a PR would have to be filed against go-yaml to add this functionality. Once that is done, support for it in SOPS could be considered.

autrilla avatar Apr 19 '18 17:04 autrilla