aboutsummaryrefslogtreecommitdiffstats
path: root/makereport
diff options
context:
space:
mode:
Diffstat (limited to 'makereport')
-rwxr-xr-xmakereport63
1 files changed, 63 insertions, 0 deletions
diff --git a/makereport b/makereport
new file mode 100755
index 0000000..b7b84e1
--- /dev/null
+++ b/makereport
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+SCRIPTPATH="$(readlink -f "$0")"
+SCRIPTDIR="$(dirname "$SCRIPTPATH")/"
+TEMPLATE=${TEMPLATE:-~/Documents/reports/template/template.md}
+SCRIPTNAME="${SCRIPTPATH##*/}"
+TODAY=$(date +%d-%m-%4Y)
+VIEWPDF=${VIEWPDF:-/usr/bin/firefox}
+
+usage()
+{
+ echo "Usage: ${SCRIPTNAME} [-h|-t] [-o outfile.pdf] <inputfile.md>"
+ echo
+ echo " Positional: <inputfile>, markdown report (input)"
+ echo
+ echo " -h|--help display this message and exit"
+ echo " -t|--template print out the template"
+ echo " -o|--output output file to be written (default: report.pdf)"
+ echo
+ echo " EXAMPLES"
+ echo " # Save the markdown template to a file"
+ echo " ${SCRIPTNAME} -t > template.md"
+ echo " # After editing the template with your vulnerabilities"
+ echo " # launch ${SCRIPTNAME} directly on it"
+ echo " ${SCRIPTNAME} -o 2022-09-google.pdf template.md"
+ echo
+}
+
+if ! command -v pandoc pdflatex >/dev/null; then
+ echo "You need to install pandoc and pdflatex"
+fi
+
+while [ "$#" -ne 0 ]; do case "$1" in
+ -h|--help)
+ usage
+ exit
+ ;;
+ -t|--template)
+ cat "${TEMPLATE}"
+ exit
+ ;;
+ -o|--output)
+ shift
+ export OUTFILE="$1"
+ ;;
+ *)
+ INPUTFILE="$1"
+esac; shift; done
+
+if [ -z "$INPUTFILE" ]; then
+ echo "No input file provided"
+ exit 1
+fi
+
+pandoc --pdf-engine=xelatex \
+ --highlight-style=/home/danix/.local/share/pandoc/templates/reports.theme \
+ --template reports \
+ --variable fontsize=16pt \
+ --variable linestretch=1.5 \
+ --variable geometry=a4paper \
+ -i "${INPUTFILE}" -o "${OUTFILE:-~/Documents/reports/report_$TODAY.pdf}"
+# once the file is exported we can preview it in the browser or in a file viewer
+# $VIEWPDF $OUTFILE