Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "report abuse" prompts for users (disabled by default) #112

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions snappass/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@
app = Flask(__name__)
if os.environ.get('DEBUG'):
app.debug = True

if os.environ.get('ABUSE_ORG') or os.environ.get('ABUSE_EMAIL'):
app.config.update(
dict(ABUSE_MESSAGE=True,
ABUSE_ORG=os.environ.get('ABUSE_ORG', 'Information Security'),
ABUSE_EMAIL=os.environ.get('ABUSE_EMAIL', '')))

app.secret_key = os.environ.get('SECRET_KEY', 'Secret Key')

app.config.update(
dict(STATIC_URL=os.environ.get('STATIC_URL', 'static')))

Expand Down Expand Up @@ -190,6 +198,12 @@ def show_password(password_key):

return render_template('password.html', password=password)

@app.errorhandler(404)
def page_not_found(e):
if request.path.startswith("/snappass"):
return render_template('404snap.html'), 404
else:
return render_template('404.html'), 404

@check_redis_alive
def main():
Expand Down
11 changes: 11 additions & 0 deletions snappass/templates/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{% extends "base.html" %}

{% block content %}
<div class="container">
<section>
<div class="page-header"><h1>Page Not Found</h1></div>
<p>The page you requested is not available.</p>
</section>
</div>
{% endblock %}

22 changes: 22 additions & 0 deletions snappass/templates/404snap.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends "base.html" %}

{% block content %}
<div class="container">
<section>
<div class="page-header"><h1>Secret Not Found</h1></div>
<p>The secret you requested is not available. This typically indicates that one of the three below conditions has occurred:</p>
<ol>
<li>The secret has already been retrieved.</li>
<li>The link was corrupted</li>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match the other items in the list:

Suggested change
<li>The link was corrupted</li>
<li>The link was corrupted.</li>

<li>The secret has timed out based on the sender's requested setting of one hour, one day, or one week.</li>
</ol>
</section>
{% if config.ABUSE_MESSAGE %}
<div class="alert alert-danger">
<p>If there is any indication that an unauthorized party may have retrieved the secret, please rotate the secret and contact {% if config.ABUSE_EMAIL %}<a href="mailto:{{ config.ABUSE_EMAIL }}">{{ config.ABUSE_ORG }}</a>{% else %}{{ config.ABUSE_ORG }}{% endif %} for assistance.</p>
</div>
{% endif %}

</div>
{% endblock %}

6 changes: 6 additions & 0 deletions snappass/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,11 @@
<script src="{{ config.STATIC_URL }}/jquery/jquery-1.12.4.min.js"></script>
<script src="{{ config.STATIC_URL }}/bootstrap/js/bootstrap.min.js"></script>
{% block js %}{% endblock %}

{% if config.ABUSE_MESSAGE %}
<div class=container>
Please report abuse to {% if config.ABUSE_EMAIL %}<a href="mailto:{{ config.ABUSE_EMAIL }}">{{ config.ABUSE_ORG }}</a>{% else %}{{ config.ABUSE_ORG }}{% endif %}.
</div>
{% endif %}
</body>
</html>