hackagent.attacks.techniques.static.fc.flowchart_renderer
Flowchart image renderer for FC-Attack.
Generates flowchart images from step descriptions using Graphviz DOT format. Supports three layout modes: vertical, horizontal, and tortuous (S-shaped).
Based on: Zhang et al., "FC-Attack: Jailbreaking Multimodal Large Language Models via Auto-Generated Flowcharts" (EMNLP 2025 Findings)
ensure_graphviz_dot_available
def ensure_graphviz_dot_available(
allow_download: bool | None = None) -> str | None
Ensure Graphviz dot is available and return its resolved path.
This function is safe to call during setup flows (e.g. hackagent init).
It may trigger automatic local binary download when enabled.
Arguments:
allow_download- See_resolve_dot_binary.
ensure_graphviz
def ensure_graphviz(allow_download: bool | None = None) -> str | None
Public alias for :func:ensure_graphviz_dot_available.
steps_to_mermaid
def steps_to_mermaid(goal_text: str,
steps: List[str],
layout: str = "vertical") -> str
Serialize steps as a Mermaid flowchart respecting layout direction.
steps_to_tikz
def steps_to_tikz(goal_text: str,
steps: List[str],
layout: str = "vertical") -> str
Serialize steps as a TikZ flowchart (LaTeX) respecting layout direction.
steps_to_plantuml
def steps_to_plantuml(goal_text: str,
steps: List[str],
layout: str = "vertical") -> str
Serialize steps as a PlantUML flowchart respecting layout direction.
steps_to_ascii
def steps_to_ascii(goal_text: str,
steps: List[str],
layout: str = "vertical") -> str
Serialize steps as an ASCII art flowchart respecting layout direction.
steps_to_dot
def steps_to_dot(goal_text: str,
steps: List[str],
layout: str = "vertical") -> str
Serialize steps as a Graphviz DOT source string respecting layout direction.
render_flowchart
def render_flowchart(steps: List[str],
goal_text: str = "",
layout: str = "vertical",
dpi: int = 600,
cache_dir: Path | str | None = None,
**kwargs: Any) -> Dict[str, Any]
Render steps as a flowchart image using Graphviz.
Tries the system dot first. If unavailable, it can auto-download
portable Graphviz binaries (macOS/Windows) from the latest official
release unless HACKAGENT_GRAPHVIZ_AUTO_DOWNLOAD=0 is set.
Arguments:
steps- List of step description strings.goal_text- The original goal/prompt displayed as the first node.layout- One of"vertical","horizontal","tortuous"(or"s_shaped"as alias).dpi- Resolution for Graphviz rendering.**kwargs- Additional params (ignored, for backwards compat).
Returns:
Dict with keys:
- image_data_url: Base64 data URL of the PNG image.
- layout: The layout mode used.
- num_steps: Number of steps rendered.