Files
AnilAltinayandgVisor bot b798569599 Add a tool and skill for updating the gVisor CVE track record YAML.
This change introduces a Go binary `update_cve_track_record` that can parse, update/insert, sort, and re-encode entries in the website's `_data/cve-track-record.yml`. The tool ensures proper formatting and sorting of CVE entries.

A new `SKILL.md` file is also added, providing a step-by-step guide on how to use this tool to manage CVE entries, including gathering necessary details and running validation tests after updating the YAML file.

PiperOrigin-RevId: 944802032
2026-07-08 17:57:20 -07:00

54 lines
1.7 KiB
Python

"""Tools for testing yaml files against schemas."""
def _yaml_test_impl(ctx):
"""Implementation for yaml_test."""
runner = ctx.actions.declare_file(ctx.label.name)
ctx.actions.write(runner, "\n".join([
"#!/bin/bash",
"set -euo pipefail",
"%s '-schema=%s' -strict=%s -disallow_comments=%s -- %s" % (
ctx.files._tool[0].short_path,
ctx.files.schema[0].short_path,
"true" if ctx.attr.strict else "false",
"true" if ctx.attr.disallow_comments else "false",
" ".join([f.short_path for f in ctx.files.srcs]),
),
]), is_executable = True)
return [DefaultInfo(
runfiles = ctx.runfiles(files = ctx.files._tool + ctx.files.schema + ctx.files.srcs),
executable = runner,
)]
yaml_test = rule(
implementation = _yaml_test_impl,
doc = "Tests a yaml file against a schema.",
attrs = {
"srcs": attr.label_list(
doc = "The input yaml files.",
mandatory = True,
allow_files = True,
),
"schema": attr.label(
doc = "The schema file in JSON schema format.",
allow_single_file = True,
mandatory = True,
),
"strict": attr.bool(
doc = "Whether to use strict mode for YAML decoding.",
mandatory = False,
default = True,
),
"disallow_comments": attr.bool(
doc = "Whether to disallow comments in the YAML file.",
mandatory = False,
default = False,
),
"_tool": attr.label(
executable = True,
cfg = "target",
default = Label("//tools/yamltest:yamltest"),
),
},
test = True,
)