Open ainar-g opened 2 years ago
Huh, nice case :)
fwiw https://grep.app/search?q=%5C%5B%5C%5Dbyte%20%60.%2Ayaml®exp=true
EDIT: relevant:
@disconnect3d, I think it might work in some libraries if they parse YAML 1.1 as opposed to YAML 1.2. In fact, the link to the !!binary
type is for YAML 1.1, and YAML 1.2 has explicitly dropped it.
I'm not sure semgrep has enough type information to figure this out. Ruleguard might. If you can figure out a way to detect this with one of the tools, so ahead and open a PR.
Consider the code:
Here, the programmer assumed that
[]byte
fields ingopkg.in/yaml.v2
behave the same way as inencoding/json
. But they don't:It seems like you still can use
[]byte
with that module, but only if you actually use a YAML array, which is probably not something most people want: