output

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package output - styles.go provides centralized graph visualization styles. All graph colors, shapes, and edge styles for DOT/Mermaid output are defined here.

Index

Constants

This section is empty.

Variables

View Source
var DefaultEdgeStyle = EdgeStyle{
	LineStyle:  "solid",
	Color:      "gray",
	ArrowStyle: "-->",
}

DefaultEdgeStyle is returned when edge type is unknown

View Source
var DefaultNodeStyle = NodeStyle{
	FillColor:   "#f9f9f9",
	StrokeColor: "#333",
	TextColor:   "black",
	Shape:       "box",
}

DefaultNodeStyle is returned when node type is unknown

View Source
var EdgeStyles = map[GraphEdgeType]EdgeStyle{
	GraphEdgeAssignment: {LineStyle: "solid", Color: "black", ArrowStyle: "-->"},
	GraphEdgeCall:       {LineStyle: "dashed", Color: "blue", ArrowStyle: "-.->|call|"},
	GraphEdgeReturn:     {LineStyle: "dotted", Color: "green", ArrowStyle: "==>|return|"},
	GraphEdgeTaint:      {LineStyle: "bold", Color: "red", ArrowStyle: "-->|taint|"},
	GraphEdgeParameter:  {LineStyle: "dashed", Color: "purple", ArrowStyle: "-.->"},
	GraphEdgeProperty:   {LineStyle: "solid", Color: "gray", ArrowStyle: "-->"},
}

EdgeStyles maps edge types to their visual styles

View Source
var NodeStyles = map[GraphNodeType]NodeStyle{
	GraphNodeSource:    {FillColor: "#ff6b6b", StrokeColor: "#333", TextColor: "white", Shape: "ellipse"},
	GraphNodeVariable:  {FillColor: "#4ecdc4", StrokeColor: "#333", TextColor: "white", Shape: "box"},
	GraphNodeFunction:  {FillColor: "#45b7d1", StrokeColor: "#333", TextColor: "white", Shape: "box"},
	GraphNodeParameter: {FillColor: "#96ceb4", StrokeColor: "#333", TextColor: "white", Shape: "box"},
	GraphNodeCarrier:   {FillColor: "#4ecdc4", StrokeColor: "#333", TextColor: "white", Shape: "box"},
	GraphNodeProperty:  {FillColor: "#f9f9f9", StrokeColor: "#333", TextColor: "black", Shape: "box"},
	GraphNodeReturn:    {FillColor: "#f9f9f9", StrokeColor: "#333", TextColor: "black", Shape: "box"},
}

NodeStyles maps node types to their visual styles

Functions

func ExportDOT

func ExportDOT(graph *tracer.FlowGraph) string

ExportDOT exports the flow graph in Graphviz DOT format. The output is structured in four phases: header, nodes, edges, footer.

func ExportJSON

func ExportJSON(graph *tracer.FlowGraph, pretty bool) (string, error)

ExportJSON exports the flow graph as JSON.

func ExportMermaid

func ExportMermaid(graph *tracer.FlowGraph) string

ExportMermaid exports the flow graph in Mermaid format.

Types

type EdgeStyle

type EdgeStyle struct {
	LineStyle  string // "solid", "dashed", "dotted", "bold"
	Color      string // Hex color
	ArrowStyle string // Mermaid arrow style
	Label      string // Optional label
}

EdgeStyle defines visual styling for graph edges

type FileStatistic

type FileStatistic struct {
	FilePath     string `json:"file_path"`
	SourceCount  int    `json:"source_count"`
	TaintedVars  int    `json:"tainted_variables"`
	TaintedFuncs int    `json:"tainted_functions"`
}

FileStatistic represents statistics for a single file

type GraphEdgeType

type GraphEdgeType string

GraphEdgeType represents edge types in flow graphs

const (
	GraphEdgeAssignment GraphEdgeType = "assignment"
	GraphEdgeCall       GraphEdgeType = "call"
	GraphEdgeReturn     GraphEdgeType = "return"
	GraphEdgeTaint      GraphEdgeType = "taint"
	GraphEdgeParameter  GraphEdgeType = "parameter"
	GraphEdgeProperty   GraphEdgeType = "property"
)

type GraphNodeType

type GraphNodeType string

GraphNodeType represents node types in flow graphs

const (
	GraphNodeSource    GraphNodeType = "source"
	GraphNodeVariable  GraphNodeType = "variable"
	GraphNodeFunction  GraphNodeType = "function"
	GraphNodeParameter GraphNodeType = "parameter"
	GraphNodeCarrier   GraphNodeType = "carrier"
	GraphNodeProperty  GraphNodeType = "property"
	GraphNodeReturn    GraphNodeType = "return"
)

type JSONExporter

type JSONExporter struct {
	PrettyPrint bool
	Indent      string
}

JSONExporter exports trace results to JSON format

func NewJSONExporter

func NewJSONExporter(prettyPrint bool) *JSONExporter

NewJSONExporter creates a new JSON exporter

func (*JSONExporter) Export

func (e *JSONExporter) Export(result *tracer.TraceResult) (string, error)

Export exports the trace result to JSON string

func (*JSONExporter) ExportSummary

func (e *JSONExporter) ExportSummary(result *tracer.TraceResult) (string, error)

ExportSummary exports just the summary report

func (*JSONExporter) ExportToFile

func (e *JSONExporter) ExportToFile(result *tracer.TraceResult, filePath string) error

ExportToFile exports the trace result to a file

func (*JSONExporter) ExportToWriter

func (e *JSONExporter) ExportToWriter(result *tracer.TraceResult, w io.Writer) error

ExportToWriter exports the trace result to an io.Writer

type NodeStyle

type NodeStyle struct {
	FillColor   string // Hex color for fill
	StrokeColor string // Hex color for stroke/border
	TextColor   string // Hex color for text
	Shape       string // DOT shape name
}

NodeStyle defines visual styling for graph nodes

type PathFinder

type PathFinder struct {
	// contains filtered or unexported fields
}

PathFinder finds paths between nodes in the flow graph.

func NewPathFinder

func NewPathFinder(graph *tracer.FlowGraph, maxDepth int) *PathFinder

NewPathFinder creates a new PathFinder for the given graph.

func (*PathFinder) FindAllPaths

func (pf *PathFinder) FindAllPaths(sourceID string) [][]string

FindAllPaths finds all paths from a source node to all reachable leaf nodes.

func (*PathFinder) FindPathsToFunction

func (pf *PathFinder) FindPathsToFunction(funcID string) [][]string

FindPathsToFunction finds all paths from any source node to a specific function node.

type SummaryReport

type SummaryReport struct {
	TotalFiles           int             `json:"total_files"`
	TotalSources         int             `json:"total_sources"`
	TotalTaintedVars     int             `json:"total_tainted_variables"`
	TotalTaintedFuncs    int             `json:"total_tainted_functions"`
	SourcesByType        map[string]int  `json:"sources_by_type"`
	SourcesByLanguage    map[string]int  `json:"sources_by_language"`
	TaintedByLanguage    map[string]int  `json:"tainted_by_language"`
	MostTaintedFiles     []FileStatistic `json:"most_tainted_files"`
	PropagationDepthDist map[int]int     `json:"propagation_depth_distribution"`
}

SummaryReport generates a summary report of the trace

func GenerateSummary

func GenerateSummary(result *tracer.TraceResult) *SummaryReport

GenerateSummary generates a summary report from trace results

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL