summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--README.md6
-rw-r--r--main.py7
3 files changed, 14 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index bee8a64..e42d897 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
1__pycache__ 1__pycache__
2custom_templates
diff --git a/README.md b/README.md
index b12e1ea..5f00d86 100644
--- a/README.md
+++ b/README.md
@@ -79,6 +79,12 @@ collector cronjob to remove leftover files . Besides, it can create a
79the uploads folder, to ensure that the uploaded files won't be recoverable 79the uploads folder, to ensure that the uploaded files won't be recoverable
80between reboots. 80between reboots.
81 81
82# Custom templates
83
84You can override the default templates from `templates/` by putting replacements
85into the directory path that's configured in `app.config['CUSTOM_TEMPLATES_DIR']`
86(default `custom_templates/`).
87
82# Threat model 88# Threat model
83 89
84- An attacker in possession of the very same file that a user wants to clean, 90- An attacker in possession of the very same file that a user wants to clean,
diff --git a/main.py b/main.py
index 59c3791..033d8b6 100644
--- a/main.py
+++ b/main.py
@@ -6,6 +6,7 @@ from libmat2 import parser_factory
6 6
7from flask import Flask, flash, request, redirect, url_for, render_template 7from flask import Flask, flash, request, redirect, url_for, render_template
8from flask import send_from_directory, after_this_request 8from flask import send_from_directory, after_this_request
9import jinja2
9 10
10from werkzeug.utils import secure_filename 11from werkzeug.utils import secure_filename
11 12
@@ -14,6 +15,12 @@ app = Flask(__name__)
14app.config['SECRET_KEY'] = os.urandom(32) 15app.config['SECRET_KEY'] = os.urandom(32)
15app.config['UPLOAD_FOLDER'] = './uploads/' 16app.config['UPLOAD_FOLDER'] = './uploads/'
16app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB 17app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16MB
18app.config['CUSTOM_TEMPLATES_DIR'] = 'custom_templates'
19
20app.jinja_loader = jinja2.ChoiceLoader([ # type: ignore
21 jinja2.FileSystemLoader(app.config['CUSTOM_TEMPLATES_DIR']),
22 app.jinja_loader,
23 ])
17 24
18def __hash_file(filepath: str) -> str: 25def __hash_file(filepath: str) -> str:
19 sha256 = hashlib.sha256() 26 sha256 = hashlib.sha256()