image-generation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImage Generation Skill
图像生成Skill
Create diagrams, charts, and visual assets for security documentation with support for network diagrams, data visualizations, and flowcharts.
为安全文档创建图表、图形和可视化资产,支持生成网络拓扑图、数据可视化图表和流程图。
Capabilities
功能特性
- Diagrams: Generate network topology and architecture diagrams
- Charts: Create data visualizations (bar, pie, line, heatmaps)
- Flowcharts: Build process and workflow diagrams
- Risk Matrices: Generate risk assessment visualizations
- Timelines: Create incident and event timelines
- Export: Save to PNG, SVG, and PDF formats
- 图表生成:生成网络拓扑图和架构图
- 数据图表:创建数据可视化图表(柱状图、饼图、折线图、热力图)
- 流程图:构建流程和工作流图
- 风险矩阵:生成风险评估可视化图
- 时间线:创建安全事件和事件时间线
- 导出功能:支持保存为PNG、SVG和PDF格式
Quick Start
快速开始
python
import matplotlib.pyplot as pltpython
import matplotlib.pyplot as pltCreate a simple bar chart
Create a simple bar chart
severities = ['Critical', 'High', 'Medium', 'Low']
counts = [3, 8, 15, 22]
plt.figure(figsize=(10, 6))
plt.bar(severities, counts, color=['#e74c3c', '#e67e22', '#f1c40f', '#3498db'])
plt.title('Findings by Severity')
plt.savefig('severity_chart.png', dpi=150)
undefinedseverities = ['Critical', 'High', 'Medium', 'Low']
counts = [3, 8, 15, 22]
plt.figure(figsize=(10, 6))
plt.bar(severities, counts, color=['#e74c3c', '#e67e22', '#f1c40f', '#3498db'])
plt.title('Findings by Severity')
plt.savefig('severity_chart.png', dpi=150)
undefinedUsage
使用指南
Bar Charts
柱状图
Create bar charts for comparisons.
Example:
python
import matplotlib.pyplot as plt
from typing import Dict
def create_severity_chart(data: Dict[str, int], output_path: str = 'chart.png'):
"""Create a severity distribution bar chart."""
colors = {
'Critical': '#e74c3c', 'High': '#e67e22',
'Medium': '#f1c40f', 'Low': '#3498db'
}
severities = list(data.keys())
counts = list(data.values())
bar_colors = [colors.get(s, '#333') for s in severities]
plt.figure(figsize=(10, 6))
plt.bar(severities, counts, color=bar_colors)
plt.title('Findings by Severity', fontsize=14, fontweight='bold')
plt.savefig(output_path, dpi=150, bbox_inches='tight')
plt.close()创建用于对比分析的柱状图。
示例:
python
import matplotlib.pyplot as plt
from typing import Dict
def create_severity_chart(data: Dict[str, int], output_path: str = 'chart.png'):
"""Create a severity distribution bar chart."""
colors = {
'Critical': '#e74c3c', 'High': '#e67e22',
'Medium': '#f1c40f', 'Low': '#3498db'
}
severities = list(data.keys())
counts = list(data.values())
bar_colors = [colors.get(s, '#333') for s in severities]
plt.figure(figsize=(10, 6))
plt.bar(severities, counts, color=bar_colors)
plt.title('Findings by Severity', fontsize=14, fontweight='bold')
plt.savefig(output_path, dpi=150, bbox_inches='tight')
plt.close()Usage
Usage
create_severity_chart({'Critical': 3, 'High': 8, 'Medium': 15, 'Low': 22})
undefinedcreate_severity_chart({'Critical': 3, 'High': 8, 'Medium': 15, 'Low': 22})
undefinedNetwork Diagrams
网络拓扑图
Create network topology diagrams using Graphviz.
Example:
python
from graphviz import Digraph
def create_network_diagram(nodes: list, edges: list, output_path: str = 'network'):
"""Create a network topology diagram."""
dot = Digraph()
dot.attr(rankdir='TB')
shapes = {'firewall': 'box3d', 'server': 'box', 'database': 'cylinder'}
for node in nodes:
dot.node(node['id'], node['label'],
shape=shapes.get(node.get('type', 'server'), 'box'),
style='filled', fillcolor=node.get('color', 'lightblue'))
for edge in edges:
dot.edge(edge['from'], edge['to'], label=edge.get('label', ''))
dot.render(output_path, format='png', cleanup=True)使用Graphviz创建网络拓扑图。
示例:
python
from graphviz import Digraph
def create_network_diagram(nodes: list, edges: list, output_path: str = 'network'):
"""Create a network topology diagram."""
dot = Digraph()
dot.attr(rankdir='TB')
shapes = {'firewall': 'box3d', 'server': 'box', 'database': 'cylinder'}
for node in nodes:
dot.node(node['id'], node['label'],
shape=shapes.get(node.get('type', 'server'), 'box'),
style='filled', fillcolor=node.get('color', 'lightblue'))
for edge in edges:
dot.edge(edge['from'], edge['to'], label=edge.get('label', ''))
dot.render(output_path, format='png', cleanup=True)Usage
Usage
nodes = [
{'id': 'fw', 'label': 'Firewall', 'type': 'firewall', 'color': 'lightcoral'},
{'id': 'web', 'label': 'Web Server', 'type': 'server'},
{'id': 'db', 'label': 'Database', 'type': 'database'}
]
edges = [{'from': 'fw', 'to': 'web'}, {'from': 'web', 'to': 'db'}]
create_network_diagram(nodes, edges)
undefinednodes = [
{'id': 'fw', 'label': 'Firewall', 'type': 'firewall', 'color': 'lightcoral'},
{'id': 'web', 'label': 'Web Server', 'type': 'server'},
{'id': 'db', 'label': 'Database', 'type': 'database'}
]
edges = [{'from': 'fw', 'to': 'web'}, {'from': 'web', 'to': 'db'}]
create_network_diagram(nodes, edges)
undefinedFlowcharts
流程图
Create process flowcharts.
Example:
python
from graphviz import Digraph
def create_flowchart(steps: list, output_path: str = 'flowchart'):
"""Create a process flowchart."""
dot = Digraph()
dot.attr(rankdir='TB')
shapes = {'start': 'ellipse', 'end': 'ellipse',
'process': 'box', 'decision': 'diamond'}
colors = {'start': 'lightgreen', 'end': 'lightcoral',
'process': 'lightblue', 'decision': 'lightyellow'}
for step in steps:
dot.node(step['id'], step['label'],
shape=shapes.get(step.get('type', 'process'), 'box'),
style='filled',
fillcolor=colors.get(step.get('type', 'process'), 'white'))
if 'next' in step:
for n in (step['next'] if isinstance(step['next'], list) else [step['next']]):
if isinstance(n, dict):
dot.edge(step['id'], n['to'], label=n.get('label', ''))
else:
dot.edge(step['id'], n)
dot.render(output_path, format='png', cleanup=True)创建流程流程图。
示例:
python
from graphviz import Digraph
def create_flowchart(steps: list, output_path: str = 'flowchart'):
"""Create a process flowchart."""
dot = Digraph()
dot.attr(rankdir='TB')
shapes = {'start': 'ellipse', 'end': 'ellipse',
'process': 'box', 'decision': 'diamond'}
colors = {'start': 'lightgreen', 'end': 'lightcoral',
'process': 'lightblue', 'decision': 'lightyellow'}
for step in steps:
dot.node(step['id'], step['label'],
shape=shapes.get(step.get('type', 'process'), 'box'),
style='filled',
fillcolor=colors.get(step.get('type', 'process'), 'white'))
if 'next' in step:
for n in (step['next'] if isinstance(step['next'], list) else [step['next']]):
if isinstance(n, dict):
dot.edge(step['id'], n['to'], label=n.get('label', ''))
else:
dot.edge(step['id'], n)
dot.render(output_path, format='png', cleanup=True)Risk Heatmaps
风险热力图
Create risk assessment heatmaps.
Example:
python
import matplotlib.pyplot as plt
import numpy as np
def create_risk_heatmap(data: list, x_labels: list, y_labels: list, output_path: str):
"""Create a risk assessment heatmap."""
fig, ax = plt.subplots(figsize=(10, 8))
im = ax.imshow(data, cmap='RdYlGn_r')
ax.set_xticks(np.arange(len(x_labels)))
ax.set_yticks(np.arange(len(y_labels)))
ax.set_xticklabels(x_labels)
ax.set_yticklabels(y_labels)
for i in range(len(y_labels)):
for j in range(len(x_labels)):
ax.text(j, i, data[i][j], ha='center', va='center',
color='white' if data[i][j] > 5 else 'black')
ax.set_title('Risk Matrix')
plt.colorbar(im)
plt.savefig(output_path, dpi=150)
plt.close()创建风险评估热力图。
示例:
python
import matplotlib.pyplot as plt
import numpy as np
def create_risk_heatmap(data: list, x_labels: list, y_labels: list, output_path: str):
"""Create a risk assessment heatmap."""
fig, ax = plt.subplots(figsize=(10, 8))
im = ax.imshow(data, cmap='RdYlGn_r')
ax.set_xticks(np.arange(len(x_labels)))
ax.set_yticks(np.arange(len(y_labels)))
ax.set_xticklabels(x_labels)
ax.set_yticklabels(y_labels)
for i in range(len(y_labels)):
for j in range(len(x_labels)):
ax.text(j, i, data[i][j], ha='center', va='center',
color='white' if data[i][j] > 5 else 'black')
ax.set_title('Risk Matrix')
plt.colorbar(im)
plt.savefig(output_path, dpi=150)
plt.close()Configuration
配置说明
Environment Variables
环境变量
| Variable | Description | Required | Default |
|---|---|---|---|
| Output directory | No | |
| Default DPI | No | |
| 环境变量 | 描述 | 是否必填 | 默认值 |
|---|---|---|---|
| 输出目录 | 否 | |
| 默认DPI | 否 | |
Limitations
限制说明
- Interactive: Static images only
- 3D: Limited 3D support
- Graphviz: Required for diagrams
- 交互性:仅支持生成静态图像
- 3D支持:仅提供有限的3D功能
- Graphviz依赖:生成拓扑图需要安装Graphviz
Troubleshooting
问题排查
Graphviz Not Found
找不到Graphviz
Install the system package:
bash
apt-get install graphviz # Ubuntu
brew install graphviz # macOS安装系统包:
bash
apt-get install graphviz # Ubuntu
brew install graphviz # macOSRelated Skills
相关技能
- pptx: Embed images in presentations
- docx: Include visuals in reports
- pdf: Add charts to PDF reports
- pptx:在演示文稿中嵌入图像
- docx:在报告中插入可视化内容
- pdf:在PDF报告中添加图表
References
参考资料
- Detailed API Reference
- Matplotlib Documentation
- Graphviz Documentation
- 详细API参考文档
- Matplotlib官方文档
- Graphviz官方文档