我想创建一个类似下图的页面,尝试使用它tocloft
来列出漏洞,但我找不到生成类似表格的方法。我还创建了一个新环境,该环境会增加一个计数器,每个漏洞风险的计数器都不同,这样我就可以生成饼图。
这个想法是创建一个单独的命令,将漏洞添加到这个表中(增加计数器),并根据风险值改变颜色。
\newcounter{critical}
\newcounter{high}
\newcounter{medium}
\newcounter{low}
\newcounter{info}
\newcounter{total}
\newenvironment{vuln}[2][info]{
\stepcounter{#1}
\addtocounter{total}{1}
Vulnerability: #2
}
{
}
\begin{vuln}[critical]{Vuln name 1}
% Vulnerability description
\end{vuln}
\begin{vuln}[low]{Vuln name 2}
% Vulnerability description
\end{vuln}
\begin{vuln}[high]{Vuln name 3}
% Vulnerability description
\end{vuln}
漏洞页面将简单地包含一个表格,如下图所示,其中包含不同的标签和描述。我已经有了页面几何图形,但没有彩色边框和对表格(漏洞列表)的引用。
总而言之,如果能有类似这样的内容就完美了:
% Automatically lists all the vulnerabilities with the color
% depending on the first parameter of the enviroment [info]
\tableofvulnerabilities
\begin{vuln}[info]{Vulnerability name}
% This adds the name to the list of vulnerabilities table
% Depending on the risk the border color will be different ([info])
\identifier{NCC-007}
\category{Data Validation}
% ..
\end{vuln}
提前致谢
已编辑,当前文件带有饼图:
\documentclass{article}
\usepackage{tikz}
\usepackage{tocloft}
\definecolor{critical}{RGB}{247,147,147}
\definecolor{high}{RGB}{253,104,106}
\definecolor{medium}{RGB}{248,209,148}
\definecolor{low}{RGB}{252,241,152}
\definecolor{info}{RGB}{247,247,247}
\tikzstyle{chart}=[
legend label/.style={font={\scriptsize},anchor=west,align=left},
legend box/.style={rectangle, draw, minimum size=5pt},
axis/.style={black,semithick,->},
axis label/.style={anchor=east,font={\tiny}},
]
\tikzstyle{bar chart}=[
chart,
bar width/.code={
\pgfmathparse{##1/2}
\global\let\bar@w\pgfmathresult
},
bar/.style={very thick, draw=white},
bar label/.style={font={\bf\small},anchor=north},
bar value/.style={font={\footnotesize}},
bar width=.75,
]
\tikzstyle{pie chart}=[
chart,
slice/.style={line cap=round, line join=round, very thick,draw=white},
pie title/.style={font={\bf}},
slice type/.style 2 args={
##1/.style={fill=##1}
}
]
\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}
\newcommand{\pie}[2][]{
\begin{scope}[#1]
\pgfmathsetmacro{\curA}{90}
\pgfmathsetmacro{\r}{1}
\def\c{(0,0)}
\node[pie title] at (90:1.3) {#2};
\foreach \s in{critical,high,medium,low,info}{
\pgfmathsetmacro{\deltaA}{\number\value{\s}/\thetotal*360}
\pgfmathsetmacro{\nextA}{\curA + \deltaA}
\pgfmathsetmacro{\midA}{(\curA+\nextA)/2}
\path[slice,\s] \c
-- +(\curA:\r)
arc (\curA:\nextA:\r)
-- cycle;
\pgfmathsetmacro{\d}{max((\deltaA * -(.5/50) + 1) , .5)}
\begin{pgfonlayer}{foreground}
\path \c -- node[pos=\d]{} +(\midA:\r);
\end{pgfonlayer}
\global\let\curA\nextA
}
\end{scope}
}
\newcommand{\legend}[2][]{
\begin{scope}[#1]
\path
\foreach \n/\s in {#2}
{
++(0,-10pt) node[\s,legend box] {} +(5pt,0) node[legend label] {\n}
}
;
\end{scope}
}
% ENVIROMENT
\newcounter{critical}
\newcounter{high}
\newcounter{medium}
\newcounter{low}
\newcounter{info}
\newcounter{total}
\newenvironment{vuln}[2][info]{
\stepcounter{#1}
\addtocounter{total}{1}
Vulnerability: #2
}
{
}
\begin{document}
\begin{vuln}[critical]{Vuln name 1}
% Vulnerability description
\end{vuln}
\begin{vuln}[low]{Vuln name 2}
% Vulnerability description
\end{vuln}
\begin{vuln}[high]{Vuln name 3}
% Vulnerability description
\end{vuln}
\begin{tikzpicture}
[
pie chart,
% {Type}, {color}
slice type={critical}{critical},
slice type={high}{high},
slice type={medium}{medium},
slice type={low}{low},
slice type={info}{info},
pie values/.style={font={\small}},
scale=2
]
\pie{}
\end{tikzpicture}
\end{document}