mirror of https://github.com/CIRCL/lookyloo
fix: Typing in SRI generator
parent
8b08d76e48
commit
e6a027c82d
|
@ -5,16 +5,18 @@ import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from typing import Dict
|
||||||
|
|
||||||
from lookyloo.helpers import get_homedir
|
from lookyloo.helpers import get_homedir
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
dest_dir = get_homedir() / 'website' / 'web'
|
dest_dir = get_homedir() / 'website' / 'web'
|
||||||
|
|
||||||
to_save = {'static': {}}
|
to_save: Dict = {'static': {}}
|
||||||
|
|
||||||
for resource in (dest_dir / 'static').glob('*'):
|
for resource in (dest_dir / 'static').glob('*'):
|
||||||
with resource.open('rb') as f:
|
with resource.open('rb') as f:
|
||||||
to_save['static'][resource.name] = base64.b64encode(hashlib.sha512(f.read()).digest()).decode('utf-8')
|
to_save['static'][resource.name] = base64.b64encode(hashlib.sha512(f.read()).digest()).decode('utf-8')
|
||||||
|
|
||||||
with (dest_dir / 'sri.txt').open('w') as f:
|
with (dest_dir / 'sri.txt').open('w') as fw:
|
||||||
json.dump(to_save, f, indent=2)
|
json.dump(to_save, fw, indent=2)
|
||||||
|
|
Loading…
Reference in New Issue