mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
b02ddbaed0
commit
db64ceb87d
1
auth.py
1
auth.py
|
@ -10,7 +10,6 @@ import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import binascii
|
import binascii
|
||||||
import os
|
import os
|
||||||
import random
|
|
||||||
import secrets
|
import secrets
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -535,7 +535,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
except BaseException:
|
except BaseException:
|
||||||
pass
|
pass
|
||||||
if not etag:
|
if not etag:
|
||||||
etag = sha1(data).hexdigest() # nosec
|
etag = sha1(data).hexdigest() # nosec
|
||||||
try:
|
try:
|
||||||
with open(mediaFilename + '.etag', 'w') as etagFile:
|
with open(mediaFilename + '.etag', 'w') as etagFile:
|
||||||
etagFile.write(etag)
|
etagFile.write(etag)
|
||||||
|
@ -5098,7 +5098,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
else:
|
else:
|
||||||
with open(mediaFilename, 'rb') as avFile:
|
with open(mediaFilename, 'rb') as avFile:
|
||||||
mediaBinary = avFile.read()
|
mediaBinary = avFile.read()
|
||||||
etag = sha1(mediaBinary).hexdigest() # nosec
|
etag = sha1(mediaBinary).hexdigest() # nosec
|
||||||
try:
|
try:
|
||||||
with open(mediaTagFilename, 'w') as etagFile:
|
with open(mediaTagFilename, 'w') as etagFile:
|
||||||
etagFile.write(etag)
|
etagFile.write(etag)
|
||||||
|
|
6
media.py
6
media.py
|
@ -43,10 +43,10 @@ def removeMetaData(imageFilename: str, outputFilename: str) -> None:
|
||||||
return
|
return
|
||||||
if os.path.isfile('/usr/bin/exiftool'):
|
if os.path.isfile('/usr/bin/exiftool'):
|
||||||
print('Removing metadata from ' + outputFilename + ' using exiftool')
|
print('Removing metadata from ' + outputFilename + ' using exiftool')
|
||||||
os.system('exiftool -all= ' + outputFilename) # nosec
|
os.system('exiftool -all= ' + outputFilename) # nosec
|
||||||
elif os.path.isfile('/usr/bin/mogrify'):
|
elif os.path.isfile('/usr/bin/mogrify'):
|
||||||
print('Removing metadata from ' + outputFilename + ' using mogrify')
|
print('Removing metadata from ' + outputFilename + ' using mogrify')
|
||||||
os.system('/usr/bin/mogrify -strip ' + outputFilename) # nosec
|
os.system('/usr/bin/mogrify -strip ' + outputFilename) # nosec
|
||||||
|
|
||||||
|
|
||||||
def getImageHash(imageFilename: str) -> str:
|
def getImageHash(imageFilename: str) -> str:
|
||||||
|
@ -119,7 +119,7 @@ def updateEtag(mediaFilename: str) -> None:
|
||||||
if not data:
|
if not data:
|
||||||
return
|
return
|
||||||
# calculate hash
|
# calculate hash
|
||||||
etag = sha1(data).hexdigest() # nosec
|
etag = sha1(data).hexdigest() # nosec
|
||||||
# save the hash
|
# save the hash
|
||||||
try:
|
try:
|
||||||
with open(mediaFilename + '.etag', 'w') as etagFile:
|
with open(mediaFilename + '.etag', 'w') as etagFile:
|
||||||
|
|
14
person.py
14
person.py
|
@ -153,16 +153,14 @@ def randomizeActorImages(personJson: {}) -> None:
|
||||||
existingExtension = lastPartOfFilename.split('.')[1]
|
existingExtension = lastPartOfFilename.split('.')[1]
|
||||||
# NOTE: these files don't need to have cryptographically
|
# NOTE: these files don't need to have cryptographically
|
||||||
# secure names
|
# secure names
|
||||||
|
randStr = str(randint(10000000000000, 99999999999999)) # nosec
|
||||||
personJson['icon']['url'] = \
|
personJson['icon']['url'] = \
|
||||||
personId + '/avatar' + \
|
personId + '/avatar' + randStr + '.' + existingExtension
|
||||||
str(randint(10000000000000, 99999999999999)) + \ # nosec
|
|
||||||
'.' + existingExtension
|
|
||||||
lastPartOfFilename = personJson['image']['url'].split('/')[-1]
|
lastPartOfFilename = personJson['image']['url'].split('/')[-1]
|
||||||
existingExtension = lastPartOfFilename.split('.')[1]
|
existingExtension = lastPartOfFilename.split('.')[1]
|
||||||
|
randStr = str(randint(10000000000000, 99999999999999)) # nosec
|
||||||
personJson['image']['url'] = \
|
personJson['image']['url'] = \
|
||||||
personId + '/image' + \
|
personId + '/image' + randStr + '.' + existingExtension
|
||||||
str(randint(10000000000000, 99999999999999)) + \ # nosec
|
|
||||||
'.' + existingExtension
|
|
||||||
|
|
||||||
|
|
||||||
def createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
def createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
|
@ -206,11 +204,11 @@ def createPersonBase(baseDir: str, nickname: str, domain: str, port: int,
|
||||||
|
|
||||||
imageUrl = \
|
imageUrl = \
|
||||||
personId + '/image' + \
|
personId + '/image' + \
|
||||||
str(randint(10000000000000, 99999999999999)) + '.png' # nosec
|
str(randint(10000000000000, 99999999999999)) + '.png' # nosec
|
||||||
|
|
||||||
iconUrl = \
|
iconUrl = \
|
||||||
personId + '/avatar' + \
|
personId + '/avatar' + \
|
||||||
str(randint(10000000000000, 99999999999999)) + '.png' # nosec
|
str(randint(10000000000000, 99999999999999)) + '.png' # nosec
|
||||||
|
|
||||||
contextDict = {
|
contextDict = {
|
||||||
'Emoji': 'toot:Emoji',
|
'Emoji': 'toot:Emoji',
|
||||||
|
|
5
utils.py
5
utils.py
|
@ -1099,9 +1099,8 @@ def siteIsActive(url: str) -> bool:
|
||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
req = urllib.request.Request(url)
|
req = urllib.request.Request(url)
|
||||||
with urllib.request.urlopen(req, timeout=10) as res: # nosec
|
urllib.request.urlopen(req, timeout=10) # nosec
|
||||||
# testStr = response.read()
|
return True
|
||||||
return True
|
|
||||||
except SocketError as e:
|
except SocketError as e:
|
||||||
if e.errno == errno.ECONNRESET:
|
if e.errno == errno.ECONNRESET:
|
||||||
print('WARN: connection was reset during siteIsActive')
|
print('WARN: connection was reset during siteIsActive')
|
||||||
|
|
Loading…
Reference in New Issue