From 987935edd53299498e7ec4e752f00500bae2fc13 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Thu, 25 Nov 2021 17:55:45 -0500 Subject: [PATCH] [-] Remove path tricks --- src/report/report.py | 15 ++------------- src/report/report_document.md | 6 +++++- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/report/report.py b/src/report/report.py index 20ac94d..16875e5 100644 --- a/src/report/report.py +++ b/src/report/report.py @@ -84,13 +84,7 @@ def serve_report() -> None: :param path: Path of the resource :return: File resource or 404 """ - # Prevent path traversal attacks - if '..' in path: - return Response('Nope.') - - # Send file - path = os.path.join(REPORT_DIR, path) - return send_from_directory(Path(path).absolute().parent, Path(path).name) + return send_from_directory(Path(REPORT_DIR).absolute(), path) @app.route('/resources/') def js_res(path: str) -> Response: @@ -100,12 +94,7 @@ def serve_report() -> None: :param path: Path of the resource :return: File resource or 404 """ - # Prevent path traversal attacks - if '..' in path: - return Response('Nope.') - - path = os.path.join(src_dir, 'resources', path) - return send_from_directory(Path(path).absolute().parent, Path(path).name) + return send_from_directory(os.path.join(src_dir, 'resources'), path) # Run app webbrowser.open("http://localhost:5000") diff --git a/src/report/report_document.md b/src/report/report_document.md index 4a38107..5ea2dc0 100644 --- a/src/report/report_document.md +++ b/src/report/report_document.md @@ -73,13 +73,17 @@ After we answered how frequently people posted about COVID-19 and how interested ## Method -This analysis is separate for each of our samples, just like the previous analysis. However, unlike how tweets are separated for each user in the previous analysis, we combine the tweets of all users in each sample in this analysis. In this analysis, we defined the start of COVID-19 as `2020-01-01` and ignored all posts prior to this date. Then, we calculate the average frequency and popularity ratio for every day since `2020-01-01`. To reduce random variability, instead of using only the data from the day in the calculation, we used the average of the last 7 days for each day, and calculated the frequency and popularity of that interval. This calculation gave us a list of numbers `freqs` and list of dates `dates` where, for every date `dates[i]`, +This analysis is separate for each of our samples, just like the previous analysis. However, unlike how tweets are separated for each user in the previous analysis, we combine the tweets of all users in each sample in this analysis. In this analysis, we defined the start of COVID-19 as `2020-01-01` and ignored all posts prior to this date. Then, we calculate the average frequency and popularity ratio for every day since `2020-01-01`. To reduce random variability, instead of using only the data from the day in the calculation, we used the average of the last 7 days for each day, and calculated the frequency and popularity of that interval. This calculation gave us a list `freqs` and a list `pops` where, for every date `dates[i]`,
$$ \text{freqs}_i = \sum_{j = 0}^{7} \frac{|\text{COVID-posts on dates}_{i - j}|}{|\text{All posts on dates}_{i - j}|} $$
+
+$$ \text{pops}_i = \sum_{j = 0}^{7} \left(\frac{\sum\text{Popularity of COVID-posts}}{|\text{COVID-posts}|}\right) / \left(\frac{\sum \text{Popularity of all posts}}{|\text{All posts}|}\right) $$ +
+ **_TODO_** ## References