Fix GitHub advisory YAML indentation#1092
Conversation
Signed-off-by: Matthew Stanton <stantonmatthewj@gmail.com>
|
Is it needed to reinvent the yaml lint/format? Can't we use some existing tooling to make it happen? |
|
Good question. I did check the existing path before going this route: the repo currently has related:
url:
- https://example.test/a
patched_versions:
- ">= 3.0.1"So this PR is not trying to replace a formatter that is already wired in; it is a narrow post-process around Psych output, with a round-trip guard before writing it. That said, I agree that a real formatter would be preferable if the project is comfortable adding one. I can look for a small existing tool that fits the repo and rework this, or keep this limited to generated GitHub advisory output if avoiding another dependency is the priority. |
|
@StantonMatt - Thanks for your contribution.I will defer to the other @rubysec/maintainers to comment on @simi's comment and merge it if it is ready. Saw this a couple days ago: https://rubygems.org/gems/rapidyaml |
|
Thanks, I checked rapidyaml. It can emit the block-style sequence indentation this PR is after, so it is a real option. The tradeoff is dependency fit: current rapidyaml declares Ruby I can rework it in that direction if that is the preference. |
I would wait for others' feedback but do any further work in a separate PR. |
If you're happy with this for now @jasnow, let's merge it to keep it consistent. We can check around YAML formatter/linter later. |
Agree |
Fixes #1091.
This updates the GitHub advisory sync output so generated sequence values under advisory keys are indented under their parent key, including:
patched_versionsrelated.urlThe formatter validates that reindented YAML parses back to the same data before using it, so nested raw GitHub payloads and multiline scalar text do not get silently rewritten if a shape is not safe to reformat.
Verification: