-
Notifications
You must be signed in to change notification settings - Fork 687
/
shredder
executable file
·57 lines (44 loc) · 1.37 KB
/
shredder
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/opt/venvs/securedrop-app-code/bin/python
#
# Clears the SecureDrop shredder directory, securely deleting its contents.
#
import argparse
import logging
import sys
import time
sys.path.insert(0, "/var/www/securedrop")
import journalist_app # noqa: E402
from sdconfig import SecureDropConfig # noqa: E402
from store import Storage # noqa: E402
def parse_args():
parser = argparse.ArgumentParser(
prog=__file__,
description="Utility for clearing deleted content in the SecureDrop store.",
)
parser.add_argument(
"-i", "--interval", type=int, help="Keep running every 'interval' seconds.",
)
return parser.parse_args()
def clear_shredder():
try:
Storage.get_default().clear_shredder()
except Exception as e:
logging.info(f"Error clearing shredder: {e}")
def main():
args = parse_args()
logging.basicConfig(
format="%(asctime)s %(levelname)s %(message)s", level=logging.INFO
)
if args.interval:
logging.info(f"Clearing shredder every {args.interval} seconds.")
while 1:
clear_shredder()
time.sleep(args.interval)
else:
logging.info("Clearing shredder once.")
clear_shredder()
if __name__ == "__main__":
config = SecureDropConfig.get_current()
app = journalist_app.create_app(config)
with app.app_context():
main()