feat: add Graphviz DOT output writer - #658
Open
stark256-spec wants to merge 1 commit into
Open
Conversation
Add a write_sbom plugin (short name 'dot') that renders the SBOM as a Graphviz DOT digraph: each software entry becomes a node labeled with its file name (falling back to a recorded name, then its UUID), and each logical relationship becomes a directed edge labeled with the relationship type. Edge selection mirrors the logical-relationship filtering used when writing relationships to the SBOM JSON: symlink edges and edges touching filesystem path nodes are omitted, so the graph reflects software relationships rather than the filesystem tree. Registers the writer with the internal plugin manager and adds unit tests covering node/edge emission, the UUID label fallback, and empty SBOMs. Closes llnl#71 Signed-off-by: stark256-spec <stark256-spec@users.noreply.github.com>
✅ No SBOM Changes DetectedFor commit 3302785 (Run 31562187067) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
If merged this pull request will add a Graphviz DOT output writer, so an SBOM can be exported as a graph showing how files tie together.
Closes #71.
Proposed changes
surfactant/output/dot_writer.pyimplementing thewrite_sbomhook with short namedot. It emits adigraph:to_dict_override):symlinkedges and any edge touching a filesystempathnode are skipped, so the graph reflects software relationships rather than the filesystem tree. Node/edge IDs and labels are escaped for DOT.tests/output/test_dot_writer.pycovering node/edge emission, the UUID label fallback, and empty SBOMs.Usage:
then e.g.
dot -Tsvg sbom.dot -o sbom.svg.Testing
pytest tests/output/test_dot_writer.py— 4 passed.pytest tests/cmd/test_plugin.py— plugin registration still passes with the new writer.tests/data/sample_sboms/helics_binaries_sbom.json) through the plugin manager: validdigraphwith 6 nodes and 5 edges.ruff checkandruff format --checkclean.Notes
@theStache mentioned back in 2023 that they were looking at a
.DOToutput; I did not find a PR for it, so I picked this up. Happy to adjust the node/edge styling or labeling if maintainers prefer a different convention.