Skip to content

Commit

Permalink
Merge pull request #6277 from freedomofpress/backport-6270
Browse files Browse the repository at this point in the history
Backport reply key mtime/ctime  update
  • Loading branch information
zenmonkeykstop authored Feb 16, 2022
2 parents eed98b7 + 348515f commit 41a06b9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions securedrop/source_app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from pathlib import Path
from typing import Optional

import os
import time
import werkzeug
from flask import (Flask, render_template, escape, flash, Markup, request, g, session,
url_for)
Expand Down Expand Up @@ -134,4 +136,15 @@ def page_not_found(error: werkzeug.exceptions.HTTPException) -> Tuple[str, int]:
def internal_error(error: werkzeug.exceptions.HTTPException) -> Tuple[str, int]:
return render_template('error.html'), 500

# Obscure the creation time of source private keys by touching them all
# on startup.
private_keys = Path(config.GPG_KEY_DIR) / 'private-keys-v1.d'
now = time.time()
for entry in os.scandir(private_keys):
if not entry.is_file() or not entry.name.endswith('.key'):
continue
os.utime(entry.path, times=(now, now))
# So the ctime is also updated
os.chmod(entry.path, entry.stat().st_mode)

return app

0 comments on commit 41a06b9

Please sign in to comment.