Repository navigation
Conversation
Render escaped artifact and native-object metadata in Markdown. Preserve the Markdown flag when automatically routing artifacts from the scan command, with the same output-format precedence as other commands. Fixes git-pkgs#180. Signed-off-by: Alexandre Rodrigues <alexandre3ylf@gmail.com>
andrew
left a comment
There was a problem hiding this comment.
Thanks for this. The flag wiring and precedence match the other commands, and the subprocess tests covering both brief inspect --markdown and the auto-routed path are what I'd want. A few changes before it goes in.
report/artifact.go:21 prints the Entries line unconditionally, so a bare binary (brief --markdown build/tool) reports **Entries:** 0 files, 1 native objects. ArtifactHuman only prints it when a.Entries > 0. Please add the same guard and update TestArtifactMarkdownEmpty, which currently asserts the 0 files, 0 native objects string.
Producer, Needed and Go dependencies each get one bold paragraph per value, so a Go binary with 150 module deps renders 150 **Go dependency:** ... paragraphs per object. The rest of the Markdown output uses a **Header:** line followed by - item bullets capped at maxDisplayItems (mdTruncatedList in report/markdown.go). Please use that shape for these three, with the values still going through the escaping.
ArtifactMarkdown is in a new report/artifact.go, while ArtifactJSON and ArtifactHuman are in report/report.go and every other *Markdown function is in report/markdown.go. Please move it into markdown.go, and rename escapeCitationMarkdown to escapeMarkdown now that it has a caller outside the citation code.
sanitizeLine strips control characters but not Unicode format characters such as bidi overrides. The citation path strips unicode.Cf as well (report/citation.go). Paths, SONAMEs and producer strings from an untrusted archive should get the same treatment in the Markdown output, so please strip unicode.Cf in the text closure and add a case to the escaping test.
Closes #180.
brief inspect --markdown artifactrejects the output flag, whilebrief --markdown artifactdrops it when automatically routing to inspection and produces JSON or human-readable output instead.Add a Markdown artifact report and carry the flag through automatic inspection. Include archive counts, each native object's metadata, Go build information, and low-confidence static-library hints. Escape metadata and flatten embedded line breaks. Markdown takes precedence over JSON and human output, matching the other reporting commands.
Validation on Linux/amd64 with Go 1.27.3:
go test -race ./...,go vet ./..., and the CLI build pass.Summary by CodeRabbit
--markdownoption tobrief inspectand direct artifact inspection to display artifact reports in Markdown.