-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathowasp-doc.cls
More file actions
executable file
·508 lines (415 loc) · 22.7 KB
/
owasp-doc.cls
File metadata and controls
executable file
·508 lines (415 loc) · 22.7 KB
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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
%%% ============================================================================
%%% This LaTeX document class is based on the LaTeX Templates port of the
%%% Legrand Orange Book Template by Mathias Legrand. It has been modified
%%% to meet the OWASP Documentation Project's style guide.
%%% The original template is available at:
%%% https://www.latextemplates.com/template/legrand-orange-book
%%%
%%% This template is licensed under a CC BY-NC-SA 4.0 license.
%%% To see what this license means for your use of the template, visit:
%%% https://creativecommons.org/licenses/by-nc-sa/4.0/
%%% ============================================================================
\def\headerimagefile{Header_Blue_Net}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{owasp-doc}[2023-11-29 The OWASP Doc 0.1]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}} % Pass through any options to the base class
\ProcessOptions\relax % Process given options
\LoadClass{book} % Load the base class
%-------------------------------------------------------------------------------
% REQUIRED PACKAGES
%-------------------------------------------------------------------------------
\usepackage{graphicx} % Required for including pictures
\graphicspath{{assets/}} % Specifies the root path for images
\usepackage{float} % Required for controlling float positions
\usepackage[usenames, svgnames, table]{xcolor} % Required for defining and using custom colors
\usepackage{calc} % Used for spacing the index letter headings correctly
\usepackage{changepage} % Required for temporarily indenting text blocks
\usepackage[toc]{appendix} % Required for the appendices chapters
\usepackage{etoolbox} % Required for conditional logic and easily changing commands
\usepackage{eso-pic} % Required for specifying an image background in the cover page
\usepackage[nochapter, tablegrid]{vhistory} % Required for changelog
\usepackage{enumitem} % Customize lists
\setlist{nolistsep} % Reduce spacing between bullet points and numbered lists
% \usepackage{booktabs} % Required for nicer horizontal rules in tables
\usepackage{array}
% \usepackage{lscape} % Required for landscape tables
\usepackage{longtable} % Tables which may stretch over more than 1 page
\usepackage{ltxtable}
\usepackage{tabularx} % Required for tables with adjustable-width columns
\usepackage[none]{hyphenat} % Hyphenates words to split over two lines
\usepackage{listings} % Source code formatting and highlighting
\usepackage{color} % Required for syntax highlighting
\usepackage{colortbl} % Required for coloring table cells
\usepackage[skip=\baselineskip]{parskip} % Required for sane paragraph spacing
\usepackage{lmodern}
\usepackage{kpfonts}
\usepackage[export]{adjustbox}
% ===================================================
% Color Definitions
% ===================================================
% branding -- uses hex values from libre office colors:
% https://github.com/LibreOffice/core/blob/master/extras/source/palettes/standard.soc
\definecolor{urlblue}{HTML}{3465a4} % Dark Blue 1
\definecolor{owaspdarkpurple}{HTML}{5b277d} % Dark Indigo 1
\definecolor{owasplightpurple}{HTML}{b7b3ca} % Light Indigo 3
\definecolor{owasplightgrey}{HTML}{eeeeee} % Light Grey 4
\definecolor{owaspdarkgrey}{HTML}{666666} % Dark Grey 1
\definecolor{owaspred}{HTML}{f10d0c} % Dark Red 1
\definecolor{owasporange}{HTML}{ea7500} % Dark Orange 1
\definecolor{owaspyellow}{HTML}{ffff38} % Light Yellow 1
\definecolor{owaspgold}{HTML}{ffbf00} % Gold
\definecolor{owasplightgreen}{HTML}{5eb91e} % Dark Lime 1
\definecolor{owaspdarkgreen}{HTML}{069a2e} % Dark Green 1
% Syntax highlighting color scheme
% -- this is based on pygments defaults
% https://github.com/richleland/pygments-css/blob/master/default.css
\definecolor{Brown}{HTML}{773714}
\definecolor{OliveGreen}{HTML}{3d6624}
\definecolor{CadetBlue}{HTML}{244166}
\definecolor{nsclass}{HTML}{0000ff}
\definecolor{atnotation}{HTML}{008000}
\definecolor{comment}{HTML}{408080}
\definecolor{import}{HTML}{008000}
\definecolor{string}{HTML}{ba2121}
\definecolor{class}{HTML}{0000ff}
\definecolor{custommethod}{HTML}{008000}
% Misc. colors
\definecolor{Apricot}{HTML}{ffb786}
% Vulnerability header colors
% \definecolor{vcrit}{HTML}{e50000}
% \definecolor{vhigh}{HTML}{e52d00}
% \definecolor{vmed}{HTML}{dde500}
% \definecolor{vlow}{HTML}{7ee500}
% \definecolor{vinfo}{HTML}{aaaaaa}
% allow bold font to be colored
% example: \colorbf{owaspdarkpurple}{some purple bold text}
\newcommand\owaspbf[1]{\textcolor{owaspdarkpurple}{\textbf{#1}}}
%-------------------------------------------------------------------------------
% MARGINS
%-------------------------------------------------------------------------------
\usepackage{geometry} % Required for adjusting page dimensions and margins
\geometry{
top=2.5cm, % Top margin
bottom=2.5cm, % Bottom margin
inner=2.5cm, % Inner margin (left on odd pages, right on even or left in oneside mode)
outer=2.5cm, % Outer margin (right on odd pages, left on even or right in oneside mode)
headsep=10pt, % Space from the top margin to the baseline of the header
headheight=0.5cm, % Header height
footskip=1.4cm, % Space from the bottom margin to the baseline of the footer
columnsep=1cm, % Horizontal space between columns when in two column mode
%showframe, % Uncomment to show how the type block is set on the page
}
\setlength{\parindent}{0pt} % Disable paragraph indentation
%-------------------------------------------------------------------------------
% FONTS
%-------------------------------------------------------------------------------
% \usepackage{avant} % Use the Avantgarde font for headings
\usepackage[sfdefault]{roboto} % Use the Roboto font by default
\usepackage{microtype} % Improve typography
\usepackage[utf8]{inputenc} % Required for inputting international characters
\usepackage[T1]{fontenc} % Output font encoding for international characters
\usepackage{mathptmx} % Use the Adobe Times Roman as the default text font
% together with math symbols from the Symbol, Chancery
% and Computer Modern fonts
% adds the OWASP logo to the bottom corner of the page
\newcommand{\owasplogobottomright}{%
\AddToShipoutPicture*{\put(375,15){\includegraphics[width=80mm]{owasp_logo.png}}}
}
% creates the header image on new sections
\newcommand{\headerimage}{%
\clearpage
\AddToShipoutPicture*{%
\AtPageUpperLeft{%
\raisebox{-\height}{%
\includegraphics[width=\paperwidth, height=1in]{\headerimagefile}%
}%
}%
}%
}
%----------------------------------------------------------------------------------------
% HEADERS AND FOOTERS
%----------------------------------------------------------------------------------------
\usepackage{fancyhdr} % Required for customizing headers and footers
\pagestyle{fancy} % Enable the custom headers and footers
% Top horizontal rule thickness
\renewcommand{\headrulewidth}{0.5pt}
% Redefine the styling of the current chapter name in the header
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries\chaptername\ \thechapter.~#1}{}}
% Redefine the styling of the current section name in the header
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection~#1}{}}
% Clear default headers and footers
\fancyhf{}
\fancyhead[LE, RO]{\sffamily\thepage} % Header for left even pages and right odd pages
\fancyhead[LO]{\rightmark} % Header for left odd pages
\fancyhead[RE]{\leftmark} % Header for right even pages
% Style for when a plain pagestyle is specified
\fancypagestyle{plain}{
\fancyhead{} % Clear headers
\renewcommand{\headrulewidth}{0pt} % Remove header rule
}
\usepackage{emptypage} % removes headers and footers on empty pages between chapters
%----------------------------------------------------------------------------------------
% SECTION STYLING
%----------------------------------------------------------------------------------------
\setcounter{secnumdepth}{3} % Number sections down to subsubsections, a value of 2 will number to subsections only and 1 to sections only
\usepackage[
explicit, % Specify section names explicitly in \titleformat with #1
newparttoc, % Required for writing the part toc entry number in a standard way (overriding default LaTeX behavior) so the titletoc package can style it
]{titlesec} % Required for modifying sections
%-------------------------------------------
% % Command to create and output the parts pages
% \newcommand{\outputpartpage}[2]{
% \begin{tikzpicture}[remember picture, overlay]
% \node[anchor=center, rectangle, fill=owaspdarkpurple!20, inner sep=0pt, minimum height=\paperheight, minimum width=\paperwidth] at (current page.center) {}; % Background color
% \node[anchor=north west, inner sep=0pt, xshift=\Gm@lmargin, yshift=-\Gm@tmargin] at (current page.north west) {\fontsize{220pt}{220pt}\selectfont\sffamily\bfseries\textcolor{owaspdarkpurple!40}{#1}}; % Part number
% \node[anchor=north east, inner sep=0pt, xshift=-\Gm@rmargin, yshift=-\Gm@tmargin] at (current page.north east) {\fontsize{30pt}{30pt}\selectfont\sffamily\bfseries\textcolor{white}{\strut #2}}; % Part title
% \node[anchor=south east, inner sep=0pt, xshift=-\Gm@rmargin, yshift=\Gm@bmargin] at (current page.south east) { % Mini table of contents
% \parbox[t][][t]{8.5cm}{ % Width of box holding the mini ToC
% \printcontents[part]{l}{0}{\setcounter{tocdepth}{1}} % Display the mini table of contents showing chapters and sections, change tocdepth to 2 to also show subsections or 0 to only show chapters
% }
% };
% \end{tikzpicture}
% }
\titleformat
{\chapter} % Section type being modified
[block] % Shape type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame
{} % Format of the whole section
{\filright\huge \textcolor{owaspdarkpurple}{#1}} % Format of the section label
{0em} % Space between the title and label
{} % Code before the label
[] % Code after the label
%-------------------------------------------
\titleformat
{\section} % Section type being modified
[block] % Shape type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame
{\bfseries\sffamily\Large} % Format of the whole section
{\llap{{}\hspace{1em}} #1} % Format of the section label
{0cm} % Space between the title and label
{} % Code before the label
[] % Code after the label
\titleformat
{name=\section, numberless} % Section type being modified
[block] % Shape type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame
{\bfseries\sffamily\Large} % Format of the whole section
{#1} % Format of the section label
{0cm} % Space between the title and label
{} % Code before the label
[] % Code after the label
\titlespacing*{\section}{0pt}{12pt}{6pt} % Spacing around section titles, the order is: left, before and after
%-------------------------------------------
\titleformat
{\subsection} % Section type being modified
[block] % Shape type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame
{\bfseries\sffamily\large} % Format of the whole section
{\llap{\textcolor{owaspdarkpurple}{\thesubsection}\hspace{1em}}#1} % Format of the section label
{0cm} % Space between the title and label
{} % Code before the label
[] % Code after the label
\titleformat
{name=\subsection, numberless} % Section type being modified
[block] % Shape type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame
{\bfseries\sffamily\large} % Format of the whole section
{#1} % Format of the section label
{0cm} % Space between the title and label
{} % Code before the label
[] % Code after the label
\titlespacing*{\subsection}{0pt}{12pt}{4pt} % Spacing around section titles, the order is: left, before and after
%-------------------------------------------
\titleformat
{\subsubsection} % Section type being modified
[block] % Shape type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame
{\bfseries\sffamily} % Format of the whole section
{\llap{{\thesubsubsection}\hspace{1em}}#1} % Format of the section label
{0cm} % Space between the title and label
{} % Code before the label
[] % Code after the label
\titleformat
{name=\subsubsection, numberless} % Section type being modified
[block] % Shape type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame
{\bfseries\sffamily} % Format of the whole section
{#1} % Format of the section label
{0cm} % Space between the title and label
{} % Code before the label
[] % Code after the label
\titlespacing*{\subsubsection}{0pt}{8pt}{4pt} % Spacing around section titles, the order is: left, before and after
%-------------------------------------------
\titleformat
{\paragraph} % Section type being modified
[runin] % Shape type, can be: hang, block, display, runin, leftmargin, rightmargin, drop, wrap, frame
{\bfseries\sffamily} % Format of the whole section
{} % Format of the section label
{0cm} % Space between the title and label
{#1} % Code before the label
[] % Code after the label
\titlespacing*{\paragraph}{0pt}{0pt}{6pt} % Spacing around section titles, the order is: left, before and after
%----------------------------------------------------------------------------------------
% TABLE OF CONTENTS
%----------------------------------------------------------------------------------------
\usepackage{titletoc} % Required for manipulating the table of contents
\setcounter{tocdepth}{2} % Display down to subsections in the table of contents
\contentsmargin{0cm} % Removes the default right margin
%------------------------------------------------
% Styling of numbered parts in the table of contents
\newcommand{\tocentrypartnumbered}[1]{%
\setlength\fboxsep{0pt}% Remove box padding
\contentslabel[%
% Part number box
\colorbox{owaspdarkpurple!20}{% Background color
\strut\parbox[c][.7cm]{1.1cm}{% Box size
\color{owaspdarkpurple!70}\Large\sffamily\bfseries\centering\thecontentslabel% Part number
}%
}%
\hspace{4pt}%
% Part title box
\colorbox{owaspdarkpurple!40}{% Background color
\strut\parbox[c][.7cm]{\linewidth-1.25cm}{% Box size
\centering\Large\sffamily #1% Part title
}%
}%
]{1.25cm}
}
% Styling of unnumbered parts in the table of contents
\newcommand{\tocentrypartunnumbered}[1]{%
\setlength\fboxsep{0pt}% Remove box padding
\contentslabel[%
% Part title box
\colorbox{owaspdarkpurple!40}{% Background color
\strut\parbox[c][.7cm]{\linewidth}{% Box size
\centering\Large\sffamily #1% Part title
}%
}%
]{1.25cm}
}
\titlecontents{part} % Section type being modified
[1.25cm] % Left indentation
{\addvspace{20pt}\Large\sffamily\bfseries\hypersetup{linkcolor=owaspdarkpurple}} % Before code
{\tocentrypartnumbered} % Formatting of numbered sections of this type
{\tocentrypartunnumbered} % Formatting of numberless sections of this type
{} % Formatting of the filler to the right of the heading and the page number
[] % After code
%------------------------------------------------
\titlecontents{chapter} % Section type being modified
[1.25cm] % Left indentation
{\addvspace{12pt}\large\sffamily\bfseries\hypersetup{linkcolor=owaspdarkpurple}} % Before code
{\color{owaspdarkpurple}\contentslabel[\Large\thecontentslabel]{1.25cm}} % Formatting of numbered sections of this type
{} % Formatting of numberless sections of this type
{\color{owaspdarkpurple!60}\normalsize\;\titlerule*[6pt]{.}\;\color{owaspdarkpurple}\thecontentspage} % Formatting of the filler to the right of the heading and the page number
[] % After code
%------------------------------------------------
\titlecontents{section} % Section type being modified
[1.25cm] % Left indentation
{\addvspace{3pt}\sffamily\bfseries} % Before code
{\contentslabel[\thecontentslabel]{1.25cm}} % Formatting of numbered sections of this type
{} % Formatting of numberless sections of this type
{~{\normalfont\titlerule*[6pt]{.}}~\thecontentspage} % Formatting of the filler to the right of the heading and the page number
[] % After code
%------------------------------------------------
\titlecontents{subsection} % Section type being modified
[1.25cm] % Left indentation
{\addvspace{1pt}\sffamily\small} % Before code
{\contentslabel[\thecontentslabel]{1.25cm}} % Formatting of numbered sections of this type
{} % Formatting of numberless sections of this type
{~\titlerule*[6pt]{.}~\thecontentspage} % Formatting of the filler to the right of the heading and the page number
[] % After code
%------------------------------------------------
\titlecontents{subsubsection} % Section type being modified
[1.75cm] % Left indentation
{\sffamily\small} % Before code
{\contentslabel[\thecontentslabel]{1.75cm}} % Formatting of numbered sections of this type
{} % Formatting of numberless sections of this type
{~\titlerule*[6pt]{.}~\thecontentspage} % Formatting of the filler to the right of the heading and the page number
[] % After code
%------------------------------------------------
% List of figures entries
\titlecontents{figure} % Section type being modified
[0cm] % Left indentation
{\addvspace{2pt}\sffamily\small} % Before code
{\thecontentslabel\hspace*{1em}} % Formatting of numbered sections of this type
{} % Formatting of numberless sections of this type
{~\titlerule*[6pt]{.}~\thecontentspage} % Formatting of the filler to the right of the heading and the page number
[] % After code
%------------------------------------------------
% List of tables entries
\titlecontents{table} % Section type being modified
[0cm] % Left indentation
{\addvspace{2pt}\sffamily\small} % Before code
{\thecontentslabel\hspace*{1em}} % Formatting of numbered sections of this type
{} % Formatting of numberless sections of this type
{~\titlerule*[6pt]{.}~\thecontentspage} % Formatting of the filler to the right of the heading and the page number
[] % After code
%----------------------------------------------------------------------------------------
% INDEX
%----------------------------------------------------------------------------------------
\usepackage{makeidx} % Required to make an index
\makeindex % Tells LaTeX to create the files required for indexing
% Modify the command to output the index to output the correctly styled Index name to the page headers
\patchcmd{\theindex}
{\MakeUppercase\indexname} % Find
{\sffamily\normalsize\bfseries\indexname} % Replace
{}
{}
%----------------------------------------------------------------------------------------
% TABLES
%----------------------------------------------------------------------------------------
% \usepackage{array} % Required for manipulating table elements
% \newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}} % Define a new right-aligned paragraph column type
% \newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}} % Define a new left-aligned (no justification) paragraph column type
% \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} % Define a new centered paragraph column type
%----------------------------------------------------------------------------------------
% LISTS
%----------------------------------------------------------------------------------------
\usepackage{enumitem} % Required for list customization
\setlist{} % Customize spacing inside and outside lists
\renewcommand{\labelenumi}{\arabic{enumi}.} % Customize the first level numbered list characters
\renewcommand{\labelenumii}{\alph{enumii}.} % Customize the second level numbered list characters
\renewcommand{\labelenumiii}{\roman{enumiii}.} % Customize the third level numbered list characters
%------------------------------------------------
\renewcommand{\labelitemi}{\raisebox{-2pt}{\Large \textbullet}} % Customize the first level bullet point character
\renewcommand{\labelitemii}{--} % Customize the second level bullet point character
\renewcommand{\labelitemiii}{$\circ$} % Customize the third level bullet point character
\newlist{checklist}{itemize}{2}
\setlist[checklist]{label=$\square$}
%----------------------------------------------------------------------------------------
% LINKS
%----------------------------------------------------------------------------------------
\usepackage{hyperref} % Required for links
\hypersetup{
colorlinks, % Whether to color links (a thin box is output around links if this is false)
hidelinks, % Hide the default boxes around links
urlcolor=urlblue, % Color for \url and \href links
linkcolor=urlblue, % Color for \ref/\nameref links
citecolor=owaspdarkpurple, % Color for reference citations like \cite{}
hyperindex=true, % Adds links from the page numbers in the index to the relevant page
linktoc=all, % Link from section names and page numbers in the table of contents
}
%----------------------------------------------------------------------------------------
% BOOKMARKS
%----------------------------------------------------------------------------------------
\usepackage{bookmark} % Required for customizing PDF bookmarks
\bookmarksetup{
open, % Open all bookmark drawers automatically
numbered, % Add section numbers to bookmarks
addtohook={%
\ifnum\bookmarkget{level}=-1 % Customize part bookmarks
\bookmarksetup{color=owaspdarkpurple, bold}% Bold and colored
\fi
\ifnum\bookmarkget{level}=0 % Customize chapter bookmarks
\bookmarksetup{bold}% Bold
\fi
}
}
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
\renewcommand{\titlepage}[2]{
\thispagestyle{empty} % Suppress headers and footers on the title page
\begin{tikzpicture}[remember picture, overlay]
\node [inner sep=0pt] at (current page.center) {#1}; % Background image
\node [anchor=center, inner sep=1.25cm, rectangle, fill=owaspdarkpurple!30!white, fill opacity=0.6, text opacity=1, minimum height=0.2\paperheight, minimum width=\paperwidth, text width=0.8\paperwidth] at (current page.center) {#2}; % Title highlight box with title(s) and author(s)
\end{tikzpicture}
\newpage
}
%----------------------------------------------------------------------------------------
% LOAD PACKAGES THAT CLASH WITH OTHER PACKAGES
%----------------------------------------------------------------------------------------
\usepackage{tikz} % Required for drawing custom shapes and positioning elements absolutely on the page