Skip to content

Commit

Permalink
#964: updated generation scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
commjoen committed Sep 6, 2018
1 parent 8bcd60d commit d366c26
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 70 deletions.
Binary file modified Generated/MSTG.pdf
Binary file not shown.
48 changes: 47 additions & 1 deletion Tools/generate_document.sh
Expand Up @@ -5,7 +5,6 @@ type pandoc >/dev/null 2>&1 || { echo >&2 "I require pandoc but it's not install
# 0. fix position of TOC: https://stackoverflow.com/questions/25591517/pandoc-inserting-pages-before-generated-table-of-contents
# 1. add changelog
# 2. add [Date] to tag+tag of Date
# 3. add russian support

cd ../Document

Expand Down Expand Up @@ -53,3 +52,50 @@ Foreword.md \
pandoc -f docx -N --columns 10000 --reference-doc ../Tools/reference.docx -o ../Generated/MSTG.docx \
../Generated/MSTG_1.docx \
../Generated/MSTG_2.docx

cd ../Document-ru

pandoc -f gfm --toc -N --columns 10000 --self-contained --reference-doc ../Tools/reference.docx -t docx -o ../Generated/MSTG_2.docx \
0x03-Overview.md \
0x04-General-Testing-Guide.md \
0x04a-Mobile-App-Taxonomy.md \
0x04b-Mobile-App-Security-Testing.md \
0x04c-Tampering-and-Reverse-Engineering.md \
0x04e-Testing-Authentication-and-Session-Management.md \
0x04f-Testing-Network-Communication.md \
0x04g-Testing-Cryptography.md \
0x04h-Testing-Code-Quality.md \
0x05-Android-Testing-Guide.md \
0x05a-Platform-Overview.md \
0x05b-Basic-Security_Testing.md \
0x05d-Testing-Data-Storage.md \
0x05e-Testing-Cryptography.md \
0x05f-Testing-Local-Authentication.md \
0x05g-Testing-Network-Communication.md \
0x05h-Testing-Platform-Interaction.md \
0x05i-Testing-Code-Quality-and-Build-Settings.md \
0x05c-Reverse-Engineering-and-Tampering.md \
0x05j-Testing-Resiliency-Against-Reverse-Engineering.md \
0x06-iOS-Testing-Guide.md \
0x06a-Platform-Overview.md \
0x06b-Basic-Security-Testing.md \
0x06d-Testing-Data-Storage.md \
0x06e-Testing-Cryptography.md \
0x06f-Testing-Local-Authentication.md \
0x06g-Testing-Network-Communication.md \
0x06h-Testing-Platform-Interaction.md \
0x06i-Testing-Code-Quality-and-Build-Settings.md \
0x06c-Reverse-Engineering-and-Tampering.md \
0x06j-Testing-Resiliency-Against-Reverse-Engineering.md \
0x07-Appendix.md \
0x08-Testing-Tools.md \
0x09-Suggested-Reading.md

pandoc -f gfm -N --columns 10000 --reference-doc ../Tools/reference.docx -o ../Generated/MSTG_1-ru.docx \
0x00-Header.md \
Foreword.md \
0x02-Frontispiece.md

pandoc -f docx -N --columns 10000 --reference-doc ../Tools/reference.docx -o ../Generated/MSTG-ru.docx \
../Generated/MSTG_1-ru.docx \
../Generated/MSTG_2-ru.docx
143 changes: 74 additions & 69 deletions Tools/genpdf.js
@@ -1,9 +1,10 @@
var markdownpdf = require("markdown-pdf")
, fs = require("fs")
, split = require("split")
, through = require("through")
, duplexer = require("duplexer");
var markdownpdf = require("markdown-pdf"),
fs = require("fs"),
split = require("split"),
through = require("through"),
duplexer = require("duplexer");
var lang = "";
var langdir = "";
var help = false;

if (process.argv.includes("-h")) {
Expand All @@ -17,95 +18,99 @@ if (process.argv.includes("-h")) {

if (!help) {
if (lang == "" || lang == null) {
lang = "../Document/";
lang = "EN"
langdir = "../Document/";
} else {
lang = "../Document-" + lang +"/";
langdir = "../Document-" + lang + "/";
}
console.log("printing for " + lang);
runPDF();
}

function preProcessMd () {
function preProcessMd() {
// Split the input stream by lines
var splitter = split()
var splitter = split();

var replacer = through(function (data) {
this.queue(data.replace("[date]", setDate()).replace("Images/", lang+"/Images/") + "\n")
})
var replacer = through(function(data) {
this.queue(
data.replace("[date]", setDate()).replace("Images/", lang + "/Images/") +
"\n"
);
});

splitter.pipe(replacer)
return duplexer(splitter, replacer)
splitter.pipe(replacer);
return duplexer(splitter, replacer);
}

function setDate(){
function setDate() {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();

if(dd<10) {
dd = '0'+dd
if (dd < 10) {
dd = "0" + dd;
}

if(mm<10) {
mm = '0'+mm
if (mm < 10) {
mm = "0" + mm;
}

return mm + '/' + dd + '/' + yyyy;
return mm + "/" + dd + "/" + yyyy;
}

function runPDF() {
var mdDocs = [
lang+"0x00-Header.md",
lang+"Foreword.md",
lang+"0x02-Frontispiece.md",
lang+"0x03-Overview.md",
lang+"0x04-General-Testing-Guide.md",
lang+"0x04a-Mobile-App-Taxonomy.md",
lang+"0x04b-Mobile-App-Security-Testing.md",
lang+"0x04c-Tampering-and-Reverse-Engineering.md",
lang+"0x04e-Testing-Authentication-and-Session-Management.md",
lang+"0x04f-Testing-Network-Communication.md",
lang+"0x04g-Testing-Cryptography.md",
lang+"0x04h-Testing-Code-Quality.md",
lang+"0x05-Android-Testing-Guide.md",
lang+"0x05a-Platform-Overview.md",
lang+"0x05b-Basic-Security_Testing.md",
lang+"0x05d-Testing-Data-Storage.md",
lang+"0x05e-Testing-Cryptography.md",
lang+"0x05f-Testing-Local-Authentication.md",
lang+"0x05g-Testing-Network-Communication.md",
lang+"0x05h-Testing-Platform-Interaction.md",
lang+"0x05i-Testing-Code-Quality-and-Build-Settings.md",
lang+"0x05c-Reverse-Engineering-and-Tampering.md",
lang+"0x05j-Testing-Resiliency-Against-Reverse-Engineering.md",
lang+"0x06-iOS-Testing-Guide.md",
lang+"0x06a-Platform-Overview.md",
lang+"0x06b-Basic-Security-Testing.md",
lang+"0x06d-Testing-Data-Storage.md",
lang+"0x06e-Testing-Cryptography.md",
lang+"0x06f-Testing-Local-Authentication.md",
lang+"0x06g-Testing-Network-Communication.md",
lang+"0x06h-Testing-Platform-Interaction.md",
lang+"0x06i-Testing-Code-Quality-and-Build-Settings.md",
lang+"0x06c-Reverse-Engineering-and-Tampering.md",
lang+"0x06j-Testing-Resiliency-Against-Reverse-Engineering.md",
lang+"0x07-Appendix.md",
lang+"0x08-Testing-Tools.md",
lang+"0x09-Suggested-Reading.md"
langdir + "0x00-Header.md",
langdir + "Foreword.md",
langdir + "0x02-Frontispiece.md",
langdir + "0x03-Overview.md",
langdir + "0x04-General-Testing-Guide.md",
langdir + "0x04a-Mobile-App-Taxonomy.md",
langdir + "0x04b-Mobile-App-Security-Testing.md",
langdir + "0x04c-Tampering-and-Reverse-Engineering.md",
langdir + "0x04e-Testing-Authentication-and-Session-Management.md",
langdir + "0x04f-Testing-Network-Communication.md",
langdir + "0x04g-Testing-Cryptography.md",
langdir + "0x04h-Testing-Code-Quality.md",
langdir + "0x05-Android-Testing-Guide.md",
langdir + "0x05a-Platform-Overview.md",
langdir + "0x05b-Basic-Security_Testing.md",
langdir + "0x05d-Testing-Data-Storage.md",
langdir + "0x05e-Testing-Cryptography.md",
langdir + "0x05f-Testing-Local-Authentication.md",
langdir + "0x05g-Testing-Network-Communication.md",
langdir + "0x05h-Testing-Platform-Interaction.md",
langdir + "0x05i-Testing-Code-Quality-and-Build-Settings.md",
langdir + "0x05c-Reverse-Engineering-and-Tampering.md",
langdir + "0x05j-Testing-Resiliency-Against-Reverse-Engineering.md",
langdir + "0x06-iOS-Testing-Guide.md",
langdir + "0x06a-Platform-Overview.md",
langdir + "0x06b-Basic-Security-Testing.md",
langdir + "0x06d-Testing-Data-Storage.md",
langdir + "0x06e-Testing-Cryptography.md",
langdir + "0x06f-Testing-Local-Authentication.md",
langdir + "0x06g-Testing-Network-Communication.md",
langdir + "0x06h-Testing-Platform-Interaction.md",
langdir + "0x06i-Testing-Code-Quality-and-Build-Settings.md",
langdir + "0x06c-Reverse-Engineering-and-Tampering.md",
langdir + "0x06j-Testing-Resiliency-Against-Reverse-Engineering.md",
langdir + "0x07-Appendix.md",
langdir + "0x08-Testing-Tools.md",
langdir + "0x09-Suggested-Reading.md"
],
bookPath = "./../generated/MSTG.pdf";
// todo:
// 1. fix new page after before h1 starts
// 2. fix/add TOC
// 3. add changelog
// 4. Fix date to version-tag
// 5. Fix page numering
// A. make sure doc + pdf + html is uploaded by travis
// B. make sure a markdown linter runs at PR!
// C. update gitbook automatically
bookPath = "./../generated/MSTG" + lang + ".pdf";
// todo:
// 1. fix new page after before h1 starts
// 2. fix/add TOC
// 3. add changelog
// 4. Fix date to version-tag
// 5. Fix page numering
// A. make sure doc + pdf + html is uploaded by travis
// B. make sure a markdown linter runs at PR!
// C. update gitbook automatically

markdownpdf({preProcessMd: preProcessMd})
markdownpdf({ preProcessMd: preProcessMd })
.concat.from(mdDocs)
.to(bookPath, function() {
console.log("Created", bookPath);
Expand Down
1 change: 1 addition & 0 deletions Tools/package.json
Expand Up @@ -10,6 +10,7 @@
"license": "MIT",
"dependencies": {
"duplexer": "^0.1.1",
"eslint": "^5.5.0",
"fs": "0.0.1-security",
"markdown-pdf": "9.0.0",
"split": "^1.0.1",
Expand Down

0 comments on commit d366c26

Please sign in to comment.