This repository has been archived by the owner on Dec 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuswdwms.sty
308 lines (279 loc) · 9.89 KB
/
uswdwms.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
% Packages imported by the style with some configuration for certain packages
\usepackage{fontspec}
\usepackage[T1]{fontenc}
\usepackage[UKenglish]{babel}
\usepackage[useregional]{datetime2}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[a4paper, margin=0.75in]{geometry}
\usepackage{enumitem}
\usepackage[bottom]{footmisc}
\usepackage[colorlinks=true, linkcolor=black, citecolor=black, urlcolor=blue]{hyperref}
\usepackage[nottoc,numbib]{tocbibind}
\usepackage[round]{natbib}
\usepackage{fancyvrb}
\usepackage{fancyhdr}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{float}
\usepackage{tabularx, makecell}
\usepackage[table]{xcolor}
\usepackage{colortbl}
\usepackage{pdfpages}
\usepackage{caption}
\usepackage{textcomp}
\usepackage{latexsym}
\usepackage[newfloat]{minted}
\usepackage{environ}
% \usepackage{fontawesome}
\usepackage[fixed]{fontawesome5}
\usepackage{layouts}
\usepackage{tikz}
% -
% Configuration
% Set some custom lengths
\newlength{\skiplistingcaptionlen}
\setlength{\skiplistingcaptionlen}{0pt}
\newlength{\skipfigurecaptionlen}
\setlength{\skipfigurecaptionlen}{5pt}
% Hack some nicer URL-breaking - force breaks at dashes/hyphens in URLS!
% \def\UrlBreaks{\do\/\do\-}
\makeatletter \g@addto@macro{\UrlBreaks}{\do\/\do\-} \makeatother
% Configure colours
\definecolor{terminalbg-gray}{gray}{0.95}
\definecolor{ultralight-gray}{gray}{0.9}
\definecolor{light-gray}{gray}{0.75}
\definecolor{fader-gray}{gray}{0.5}
\definecolor{deep-gray}{gray}{0.4}
\definecolor{nicer-blue}{HTML}{005cc5}
% Configure vuln colours
\definecolor{critical-red}{HTML}{cc0500}
\definecolor{high-red}{HTML}{df3d03}
\definecolor{medium-amber}{HTML}{f9a009}
\definecolor{low-amber}{HTML}{ffcb0d}
% Reconfigure hyperref
\hypersetup{colorlinks=true, linkcolor=nicer-blue, citecolor=black, urlcolor=nicer-blue}
% Set the default graphicx path
\graphicspath{{images/}}
% Modify fonts
% \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
\setmainfont{Palatino Linotype}
% \setmonofont{Courier New}
% \renewcommand{\rmdefault}{ppl}
% Change the list item spacing
% \setlist{noitemsep}
\setlist{itemsep=0.2em}
% Set the bibliography style
\bibliographystyle{usw}
% Configure fancyhdr
\renewcommand{\headrulewidth}{0.1mm}
\renewcommand{\footrulewidth}{0.1mm}
\renewcommand{\headrule}{
\vspace{0.8mm}\vspace{-\baselineskip}
\textcolor{light-gray}{\rule{\linewidth}{\headrulewidth}}
}
\renewcommand{\footrule}{
% \vspace*{0.8mm}\vspace*{\baselineskip}
\textcolor{light-gray}{\rule{\linewidth}{\footrulewidth}}
}
% Set the default minted style
\usemintedstyle{rainbow_dash}
\setminted{autogobble,breaklines,fontsize=\small,frame=leftline,framerule=0.2pt,framesep=2mm,linenos,numbersep=3pt,python3,rulecolor=ultralight-gray}
% -
% Custom functions
% Set up an inline todo command
\newcommand{\todo}[1]{\textcolor{red}{todo: #1}}
% Set up a todo environment
\newenvironment{todoenv}
{\color{red}todo:}
{\color{black}}
% Set up a terminal command block
\newcommand{\term}[1]{\colorbox{terminalbg-gray}{\texttt{#1}}}
% Make fancy headers and footers for reports
\newcommand{\makeheadersandfooters}[4]{
\fancyhf{}
\lhead{\textcolor{light-gray}{#1}}
\rhead{\textcolor{light-gray}{#2}}
\lfoot{\textcolor{light-gray}{#3}}
\rfoot{\textcolor{light-gray}{#4}}
}
% Make a fancy title page
\newcommand{\makeuswtitlepage}{
\begin{titlepage}
\centering
\vspace*{2cm}
% Insert logo
\includegraphics[scale = 0.15]{usw_logo.jpg}\\
% Insert institution and course titles
\textsc{\LARGE \institutionid\\\Large \unicoursename}\\[1cm]
% Insert double-line top
\textcolor{fader-gray}{\rule{\linewidth}{0.2mm}}\\
\vspace{0.8mm}\vspace{-\baselineskip}
\textcolor{fader-gray}{\rule{\linewidth}{0.2mm}}\\[0.5cm]
% Insert report title
%% v3
{\Huge\bfseries \unimodulecode}\\
\textsc{\Large \unimodulename}\\
%%
\textcolor{light-gray}{\rule{\linewidth}{0.2mm}}\\[0.5cm]
\textsc{\Large \thetitle}\\
% Insert lines bottom
\textcolor{fader-gray}{\rule{\linewidth}{0.2mm}}\\
\vspace{0.8mm}\vspace{-\baselineskip}
\textcolor{fader-gray}{\rule{\linewidth}{0.2mm}}\\[2cm]
% Insert italicised date
{\large \textit{\thedate}}\\[2cm]
% \begin{minipage}[t][5cm][t]{0.4\linewidth}
\begin{minipage}[t]{0.4\linewidth}
\vspace{0pt}
\raggedleft
\textcolor{fader-gray}{\textit{Submitted to:}}\\
\unimodulelect\\
\end{minipage}\hspace{5mm}\textcolor{light-gray}{\vline width 0.1mm}\hspace{4mm}~%
\begin{minipage}[t]{0.4\linewidth}
\vspace{0pt}
\raggedright
\textcolor{fader-gray}{\textit{Author(s):}}\\
\theauthor\\\unistudentid\\
\end{minipage}\\
\end{titlepage}
}
% Add an environment equivalent to \makeuswtitlepage that allows for further content to be inserted onto the titlepage
\NewEnviron{uswtitlepage}[0]{
\begin{titlepage}
\centering
\vspace*{2cm}
% Insert logo
\includegraphics[scale = 0.15]{usw_logo.jpg}\\
% Insert institution and course titles
\textsc{\LARGE \institutionid\\\Large \unicoursename}\\[1cm]
% Insert double-line top
\textcolor{fader-gray}{\rule{\linewidth}{0.2mm}}\\
\vspace{0.8mm}\vspace{-\baselineskip}
\textcolor{fader-gray}{\rule{\linewidth}{0.2mm}}\\[0.5cm]
% Insert report title
%% v3
{\Huge\bfseries \unimodulecode}\\
\textsc{\Large \unimodulename}\\
%%
\textcolor{light-gray}{\rule{\linewidth}{0.2mm}}\\[0.5cm]
\textsc{\Large \thetitle}\\
% Insert lines bottom
\textcolor{fader-gray}{\rule{\linewidth}{0.2mm}}\\
\vspace{0.8mm}\vspace{-\baselineskip}
\textcolor{fader-gray}{\rule{\linewidth}{0.2mm}}\\[1cm]
% Insert italicised date
{\large \textit{\thedate}}\\[1cm]
% \begin{minipage}[t][5cm][t]{0.4\linewidth}
\begin{minipage}[t]{0.4\linewidth}
\vspace{0pt}
\raggedleft
\textcolor{fader-gray}{\textit{Submitted to:}}\\
\unimodulelect\\
\end{minipage}\hspace{5mm}\textcolor{light-gray}{\vline width 0.1mm}\hspace{4mm}~%
\begin{minipage}[t]{0.4\linewidth}
\vspace{0pt}
\raggedright
\textcolor{fader-gray}{\textit{Author(s):}}\\
\theauthor\\\unistudentid\\
\end{minipage}\\[2cm]
\BODY
\end{titlepage}
}
% Make a fancy contact card
% #1: image path for includegraphics
% #2: image scale factor
% TODO: Make column widths parameters too
\NewEnviron{personcontact}[2]{
\begin{table}[H]
\newcolumntype{i}{>{\raggedright\arraybackslash}p{1cm}}
\newcolumntype{v}{>{\raggedright\arraybackslash}p{6cm - 4\tabcolsep - 3\arrayrulewidth}}
\newcolumntype{z}{>{\raggedright\arraybackslash}p{5cm - 1\tabcolsep}}
% Force cells to align content to the centre
\renewcommand\cellalign{cc}
% DEBUG: \begin{tabularx}{7cm}{|i|v|}
\begin{tabularx}{7cm}{iv}
\arrayrulecolor{ultralight-gray}
\hline
\makecell[{{p{1cm}}}]{\includegraphics[scale=#2]{#1}}
& \makecell[{{p{5cm}}}]{
% DEBUG: \begin{tabularx}{5cm + 1\tabcolsep + 2\arrayrulewidth}{|z|}
\begin{tabularx}{5cm + 1\tabcolsep + 2\arrayrulewidth}{z}
% DEBUG: \hline
\BODY
% DEBUG: \hline
\end{tabularx}
} \tabularnewline \hline
\end{tabularx}
\end{table}
}
% Make a fancy vulnerability count table
\newcommand{\makevulncounttable}[4]{
\begin{table}[H]
% \caption{Count of vulnerabilities}
\label{tab:vulncount}
\newcolumntype{v}{>{\centering\arraybackslash}X}
\begin{tabularx}{1\textwidth}{v|v|v|v}
\arrayrulecolor{ultralight-gray}
\hline
\cellcolor{terminalbg-gray!25}\hyperref[sec:vuln_crit]{\textcolor{critical-red!75}{\LARGE\textbf{\textsc{Critical}}}} &
\cellcolor{terminalbg-gray!25}\hyperref[sec:vuln_high]{\textcolor{high-red!75}{\LARGE\textbf{\textsc{High}}}} &
\cellcolor{terminalbg-gray!25}\hyperref[sec:vuln_med]{\textcolor{medium-amber!75}{\LARGE\textbf{\textsc{Medium}}}} &
\cellcolor{terminalbg-gray!25}\hyperref[sec:vuln_low]{\textcolor{low-amber!75}{\LARGE\textbf{\textsc{Low}}}} \tabularnewline % \hline
\cellcolor{terminalbg-gray!25}\hyperref[sec:vuln_crit]{\textcolor{critical-red}{\Huge\textbf{#1}}} &
\cellcolor{terminalbg-gray!25}\hyperref[sec:vuln_high]{\textcolor{high-red}{\Huge\textbf{#2}}} &
\cellcolor{terminalbg-gray!25}\hyperref[sec:vuln_med]{\textcolor{medium-amber}{\Huge\textbf{#3}}} &
\cellcolor{terminalbg-gray!25}\hyperref[sec:vuln_low]{\textcolor{low-amber}{\Huge\textbf{#4}}} \tabularnewline \hline
\end{tabularx}
\end{table}
}
% Make a display table
\NewEnviron{displaytable}[2]{
\begin{table}[H]
% This argument allows us to set labels and captions optionally for the table
#1
\newcolumntype{v}{X}
\renewcommand\cellalign{cc}
\begin{tabularx}{1\textwidth}{|v|}
\arrayrulecolor{ultralight-gray}
\hline
\vspace{1pt}\cellcolor{ultralight-gray}\textcolor{deep-gray}{\large\textbf{\textsc{#2}}} \tabularnewline \hline
\cellcolor{terminalbg-gray!75}\makecell[{{p{1\textwidth - 2\tabcolsep}}}]{
\BODY
} \tabularnewline \hline
\end{tabularx}
\end{table}
}
% Make a display table itemize
% TODO: Make so the list type is a param and also so more opts can be added by param
\newcommand{\makedisplaytableitemize}[3]{
\begin{displaytable}{#1}{#2}
\begin{itemize}[leftmargin=2em,itemsep=0.1em,topsep=0pt,parsep=0pt]
#3
\end{itemize}
\end{displaytable}
}
% Define a codelisting environment for multi-page minted listings
\newenvironment{codelisting}{\captionsetup{type=listing}}{}
% Circle something
\newcommand*\listlabelcircle[1]{
\begin{tikzpicture}[baseline=(C.base)]
\node[draw,circle,inner sep=1pt,minimum size=3ex](C) {#1};
\end{tikzpicture}
}
\NewEnviron{methodology0}[0]{
\begin{enumerate}[leftmargin=0em,label=\protect\listlabelcircle{\Large\arabic*}]
\BODY
\end{enumerate}
}
\NewEnviron{methodology1}[0]{
\begin{enumerate}[label=\Roman*~\textcolor{light-gray}{|}]
\BODY
\end{enumerate}
}
\NewEnviron{methodology2}[0]{
\begin{enumerate}[label=\textcolor{deep-gray}{\roman*\textasciitilde}]
\BODY
\end{enumerate}
}
% -