[-] Remove path tricks

This commit is contained in:
Hykilpikonna
2021-11-25 17:55:45 -05:00
parent ecadbfa8d7
commit 987935edd5
2 changed files with 7 additions and 14 deletions
+2 -13
View File
@@ -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/<path:path>')
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")
+5 -1
View File
@@ -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]`,
<blockquote>
$$ \text{freqs}_i =
\sum_{j = 0}^{7} \frac{|\text{COVID-posts on dates}_{i - j}|}{|\text{All posts on dates}_{i - j}|} $$
</blockquote>
<blockquote>
$$ \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) $$
</blockquote>
**_TODO_**
## References