Skip to content

Commit

Permalink
Add MASTG New Cover for PDF (#2205)
Browse files Browse the repository at this point in the history
* try new cover and fix img

* rm emojis

* rm covers and fix file paths

* transform by function

* fix PDF upload

* apply transforms to workflows

* add cover in pdf

* how to create the cover & rm docx upload
  • Loading branch information
cpholguera authored Sep 4, 2022
1 parent 2d11d52 commit a7146c0
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
python-version: 3.x
- run: pip install -r requirements.txt

- run: python3 tools/scripts/transform_links.py
- run: python3 tools/scripts/transform_files.py
- run: mkdir docs/MASTG
- run: mkdir docs/MASTG/General
- run: mkdir docs/MASTG/Android
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/docgenerator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
run: echo "VERSION=${{env.VERSION}}-$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Process Files
run: python3 tools/scripts/transform_files.py

- name: Generate English PDF
run: ./tools/docker/pandoc_makedocs.sh Document ${{env.VERSION}}

Expand Down Expand Up @@ -136,7 +139,6 @@ jobs:
files: |
OWASP_MASTG-*/OWASP_MASTG-*.pdf
OWASP_MASTG-*/OWASP_MASTG-*.epub
OWASP_MASTG-*/OWASP_MASTG-*.docx
Checklists/*.xlsx
Enhanced-MASVS-YAML-Files/*.yaml
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_modules
.idea
Generated
tmp_*
build
*-temp
OWASP_MSTG-SNAPSHOT-*
logs
Expand Down
2 changes: 1 addition & 1 deletion Document/0x05h-Testing-Platform-Interaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ Using unverified deep links can cause a significant issue- any other apps instal

In recent versions of Android this results in a so-called _disambiguation dialog_ shown to the user that asks them to select the application that should handle the deep link. The user could make the mistake of choosing a malicious application instead of the legitimate one.

<img src="https://developer.android.com/training/app-links/images/app-disambiguation_2x.png"/>
<img src="Images/Chapters/0x05h/app-disambiguation.png" width="50%" />

#### Android App Links

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Document/Images/cover.jpg
Binary file not shown.
Binary file removed Document/cover.jpg
Binary file not shown.
2 changes: 1 addition & 1 deletion Document/cover.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<img src='../Document/Images/cover.jpg' id="cover" class="cover" />
<img src='../cover.pdf' id="cover" class="cover" />
Binary file removed cover.jpg
Binary file not shown.
Binary file added cover.pdf
Binary file not shown.
Binary file added cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 12 additions & 4 deletions tools/docker/cover.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
% IMPORTANT NOTE this file requires latex-header.tex
% cover.jpg is in the root folder (owasp-mastg/)
% Version text is written at (X,Y), where (0, 0) is the lower left corner of the page.

% The cover is created first using Google Drawings: https://docs.google.com/drawings/d/1i0NIJq3ChVrdQ-0YdqcYGeWUw9QCzd61gDBp05dP7b8/edit?usp=sharing
% To best fit the PDF, in Google Drawings we go to File > PAge Setup and set Width = 2480px and Height = 3508px.
% It is exported as cover.pdf and lives in the root folder (owasp-mastg/)

% The version text is written dynamically using the code in this file
% The used latex overlay uses the coordinates (X,Y), where (0, 0) is the lower left corner of the page.

% NOTE: For non-release versions e.g. v1.4.1-70281c8 it might look like the version string is not correctly located but it is for release versions e.g. v1.5.0.
% The coordinates given below are for the release version and are correct.

% This file requires the following pandoc metadata variables:
% * $version$
Expand All @@ -10,5 +18,5 @@

% https://tex.stackexchange.com/questions/136900/insert-a-full-page-image
\incgraph[documentpaper,
overlay={\node[white] at (12.6,10.3) {\Large Version $version$};}]
[width=\paperwidth,height=\paperheight]{cover.jpg}
overlay={\node[white] at (4.0,18.0) {\Large Version $version$};}]
[width=\paperwidth,height=\paperheight]{cover.pdf}
28 changes: 14 additions & 14 deletions tools/docker/pandoc_makedocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cp -R $FOLDER "build"
IMG=${IMG:-dalibo/pandocker}
TAG=${TAG:-21.02} # /!\ use stable-full for non-european languages
LATEX_TEMPLATE=${LATEX_TEMPLATE:-eisvogel}
TITLE=${TITLE:-OWASP Mobile Security Testing Guide ${VERSION}}
TITLE=${TITLE:-OWASP Mobile Application Security Testing Guide ${VERSION}}

PANDOC_PARAMS=${PANDOC_PARAMS:-}
PANDOC_PARAMS+="--resource-path=.:build "
Expand All @@ -35,7 +35,7 @@ PANDOC=${PANDOC:-${PANDOCKER}}

METADATA="build/metadata.md"
CHAPTERS="build/0x*.md build/CHANGELOG.md"
OUTPUT_BASE_NAME="OWASP_MSTG-${VERSION}"
OUTPUT_BASE_NAME="OWASP_MASTG-${VERSION}"

[ ! -z "${VERBOSE}" ] && echo "Create PDF"

Expand Down Expand Up @@ -76,7 +76,7 @@ ${PANDOC} \
${PANDOC} \
--metadata title="${TITLE}" \
--metadata author="Bernhard Mueller, Sven Schleier, Jeroen Willemsen, and Carlos Holguera" \
--epub-cover-image=cover.jpg \
--epub-cover-image=cover.pdf \
-o ${OUTPUT_BASE_NAME}.epub \
${METADATA} \
${CHAPTERS}
Expand All @@ -86,17 +86,17 @@ ${PANDOC} \
#kindlegen ${OUTPUT_BASE_NAME}.epub

# DOCX
${PANDOC} \
--metadata title="${TITLE}" \
--toc \
--number-sections \
--columns 10000 \
--self-contained \
--standalone \
--reference-doc tools/custom-reference.docx \
-o ${OUTPUT_BASE_NAME}_WIP_.docx \
${METADATA} \
${CHAPTERS}
# ${PANDOC} \
# --metadata title="${TITLE}" \
# --toc \
# --number-sections \
# --columns 10000 \
# --self-contained \
# --standalone \
# --reference-doc tools/custom-reference.docx \
# -o ${OUTPUT_BASE_NAME}_WIP_.docx \
# ${METADATA} \
# ${CHAPTERS}


# clean temp files
Expand Down
39 changes: 39 additions & 0 deletions tools/scripts/transform_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import re, os
from pathlib import Path

EMOJIS_regex = r"🥇 |🎁 |📝 |❗ "

def transform_links(file_text):
print("[*] Regex Substitutions ../Document to MASTG/")
found = re.findall(r'(\((?:../)*Document/.*\.md/*)', file_text)
print(f" Found: {found}")
return re.sub(r"\(((?:../)*)Document/(.*)\.md/*", r"(\1MASTG/\2/", file_text)

def remove_emojis(file_text):
print("[*] Regex Substitutions for emojis")
found = re.findall(EMOJIS_regex, file_text)
print(f" Found: {found}")
return re.sub(EMOJIS_regex, r"", file_text)

def transform(folder, functions):
print(f"[*] Applying transforms to {folder}")
for root, dirname, filenames in os.walk(folder):
if len(filenames):
files = Path(root).glob('*.md')

for file in files:
file_obj = Path(file)
print(f" - File {file_obj.as_posix()}")
file_text = file_obj.read_text()

new_text = None
for function in functions:
if new_text is None:
new_text = function(file_text)
else:
new_text = function(new_text)

file_obj.write_text(new_text)

transform("docs", [transform_links])
transform("Document", [remove_emojis])
17 changes: 0 additions & 17 deletions tools/scripts/transform_links.py

This file was deleted.

0 comments on commit a7146c0

Please sign in to comment.