mirror of
https://gitlab.os-k.eu/neox/CNIRevelator.git
synced 2023-08-25 14:03:10 +02:00
Correcting "token clear in repo"
This commit is contained in:
parent
624b78d9d1
commit
83a6e110f6
@ -25,14 +25,41 @@
|
|||||||
"""
|
"""
|
||||||
from requests.auth import HTTPProxyAuth
|
from requests.auth import HTTPProxyAuth
|
||||||
from pypac import PACSession
|
from pypac import PACSession
|
||||||
|
from Crypto import Random
|
||||||
|
from Crypto.Cipher import AES
|
||||||
from requests import Session
|
from requests import Session
|
||||||
import json
|
import json, hashlib, base64
|
||||||
|
|
||||||
import logger # logger.py
|
import logger # logger.py
|
||||||
import globs # globs.py
|
import globs # globs.py
|
||||||
|
|
||||||
credentials = False
|
credentials = False
|
||||||
|
|
||||||
|
class AESCipher(object):
|
||||||
|
|
||||||
|
def __init__(self, key):
|
||||||
|
self.bs = 32
|
||||||
|
self.key = hashlib.sha256(key.encode()).digest()
|
||||||
|
|
||||||
|
def encrypt(self, raw):
|
||||||
|
raw = self._pad(raw)
|
||||||
|
iv = Random.new().read(AES.block_size)
|
||||||
|
cipher = AES.new(self.key, AES.MODE_CBC, iv)
|
||||||
|
return base64.b64encode(iv + cipher.encrypt(raw))
|
||||||
|
|
||||||
|
def decrypt(self, enc):
|
||||||
|
enc = base64.b64decode(enc)
|
||||||
|
iv = enc[:AES.block_size]
|
||||||
|
cipher = AES.new(self.key, AES.MODE_CBC, iv)
|
||||||
|
return self._unpad(cipher.decrypt(enc[AES.block_size:])).decode('utf-8')
|
||||||
|
|
||||||
|
def _pad(self, s):
|
||||||
|
return s + (self.bs - len(s) % self.bs) * chr(self.bs - len(s) % self.bs)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _unpad(s):
|
||||||
|
return s[:-ord(s[len(s) - 1:])]
|
||||||
|
|
||||||
def reportBug(reason="",log=""):
|
def reportBug(reason="",log=""):
|
||||||
|
|
||||||
logfile = logger.logCur
|
logfile = logger.logCur
|
||||||
@ -45,7 +72,7 @@ def reportBug(reason="",log=""):
|
|||||||
|
|
||||||
payload = {'title':"CNIRevelator Bug Report", 'body':"**An error has been reported by a CNIRevelator instance.**\n\n**Here is the full reason of this issue:**\n{}\n\n**The full log is here:** {}".format(reason, log), "assignees":["neox95"], "labels":["bug", "AUTO"]}
|
payload = {'title':"CNIRevelator Bug Report", 'body':"**An error has been reported by a CNIRevelator instance.**\n\n**Here is the full reason of this issue:**\n{}\n\n**The full log is here:** {}".format(reason, log), "assignees":["neox95"], "labels":["bug", "AUTO"]}
|
||||||
|
|
||||||
handler = session.post('https://api.github.com/repos/neox95/cnirevelator/issues', headers={'Authorization': 'token %s' % globs.CNIRGitToken}, data=json.dumps(payload))
|
handler = session.post('https://api.github.com/repos/neox95/cnirevelator/issues', headers={'Authorization': 'token %s' % decryptToken(globs.CNIRGitToken)}, data=json.dumps(payload))
|
||||||
|
|
||||||
logfile.printdbg(handler.reason)
|
logfile.printdbg(handler.reason)
|
||||||
|
|
||||||
@ -54,4 +81,12 @@ def reportBug(reason="",log=""):
|
|||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def encryptToken(token):
|
||||||
|
AESObj = AESCipher(globs.CNIRCryptoKey)
|
||||||
|
return AESObj.encrypt(token)
|
||||||
|
|
||||||
|
def decryptToken(token):
|
||||||
|
AESObj = AESCipher(globs.CNIRCryptoKey)
|
||||||
|
return AESObj.decrypt(token)
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,13 +26,13 @@
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
# CNIRevelator version
|
# CNIRevelator version
|
||||||
verType = "stable release"
|
verType = "beta release"
|
||||||
version = [3, 1, 4]
|
version = [3, 1, 5]
|
||||||
verstring_full = "{}.{}.{} {}".format(version[0], version[1], version[2], verType)
|
verstring_full = "{}.{}.{} {}".format(version[0], version[1], version[2], verType)
|
||||||
verstring = "{}.{}".format(version[0], version[1])
|
verstring = "{}.{}".format(version[0], version[1])
|
||||||
|
|
||||||
CNIRTesserHash = "947224361ffab8c01f05c9394b44b1bd7c8c3d4d"
|
CNIRTesserHash = "947224361ffab8c01f05c9394b44b1bd7c8c3d4d"
|
||||||
CNIRGitToken = "ef7737dd1e5ad8a35d3cc5fdbeb273e69a09f25f"
|
CNIRGitToken = "mJHKXqnazO/xZ9Fs18SDMqcGJ15A27OlZyd27cDe5dhHKklO2YShdWwUgEDUZQI02kpgYaLceMidTK37ZqakW+VYgPPuh0e9Ry2IH0KHc3o="
|
||||||
CNIRFolder = os.path.dirname(os.path.realpath(__file__))
|
CNIRFolder = os.path.dirname(os.path.realpath(__file__))
|
||||||
CNIRLColor = "#006699"
|
CNIRLColor = "#006699"
|
||||||
CNIRName = "CNIRevelator {}".format(verstring)
|
CNIRName = "CNIRevelator {}".format(verstring)
|
||||||
|
14
src/main.py
14
src/main.py
@ -172,7 +172,7 @@ class mainWindow(Tk):
|
|||||||
"SEX" : self.sex,
|
"SEX" : self.sex,
|
||||||
"NAT" : self.nat,
|
"NAT" : self.nat,
|
||||||
"PAYS" : self.pays,
|
"PAYS" : self.pays,
|
||||||
"INDIC" : self.indic,
|
"INDIC" : self.indic
|
||||||
}
|
}
|
||||||
|
|
||||||
# The the image viewer
|
# The the image viewer
|
||||||
@ -723,12 +723,12 @@ class mainWindow(Tk):
|
|||||||
#print(docInfos)
|
#print(docInfos)
|
||||||
# display the infos
|
# display the infos
|
||||||
for key in [ e for e in docInfos ]:
|
for key in [ e for e in docInfos ]:
|
||||||
#print(docInfos[key])
|
print(key)
|
||||||
if key in ["CODE", "CTRL", "CTRLF"]:
|
if key in ["CODE", "CTRL", "CTRLF", "FACULT"]:
|
||||||
continue
|
continue
|
||||||
if not docInfos[key] == False:
|
if not docInfos[key][1] == False:
|
||||||
if not docInfos[key] == "":
|
if not docInfos[key][0] == "":
|
||||||
self.infoList[key]['text'] = docInfos[key]
|
self.infoList[key]['text'] = docInfos[key][0]
|
||||||
self.infoList[key]['background'] = self['background']
|
self.infoList[key]['background'] = self['background']
|
||||||
self.infoList[key]['foreground'] = "black"
|
self.infoList[key]['foreground'] = "black"
|
||||||
else:
|
else:
|
||||||
@ -738,7 +738,7 @@ class mainWindow(Tk):
|
|||||||
else:
|
else:
|
||||||
self.infoList[key]['background'] = "red"
|
self.infoList[key]['background'] = "red"
|
||||||
self.infoList[key]['foreground'] = "white"
|
self.infoList[key]['foreground'] = "white"
|
||||||
self.infoList[key]['text'] = "NC"
|
self.infoList[key]['text'] = docInfos[key][0]
|
||||||
self.compliance = False
|
self.compliance = False
|
||||||
|
|
||||||
if self.compliance == True:
|
if self.compliance == True:
|
||||||
|
35
src/mrz.py
35
src/mrz.py
@ -490,18 +490,19 @@ def getDocInfos(doc, code):
|
|||||||
for field in infoTypes:
|
for field in infoTypes:
|
||||||
|
|
||||||
value = code[ field[1][0] : field[1][1] ].replace("<", " ").strip()
|
value = code[ field[1][0] : field[1][1] ].replace("<", " ").strip()
|
||||||
|
res[field[0]] = [0,0]
|
||||||
|
|
||||||
# State code
|
# State code
|
||||||
if field[0] == 'PAYS' or field[0] == 'NAT':
|
if field[0] == 'PAYS' or field[0] == 'NAT':
|
||||||
try:
|
try:
|
||||||
if len(value) == 3 and value[-1] != "<":
|
if len(value) == 3 and value[-1] != "<":
|
||||||
res[field[0]] = landcode3[value]
|
res[field[0]] = (landcode3[value], True)
|
||||||
elif len(value) == 3 and value[-1] == "<":
|
elif len(value) == 3 and value[-1] == "<":
|
||||||
res[field[0]] = landcode2[value[:-1]]
|
res[field[0]] = (landcode2[value[:-1]], True)
|
||||||
else:
|
else:
|
||||||
res[field[0]] = landcode2[value]
|
res[field[0]] = (landcode2[value], True)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
res[field[0]] = False
|
res[field[0]] = [value, False]
|
||||||
|
|
||||||
# Dates
|
# Dates
|
||||||
elif field[0][1:] == 'DATE':
|
elif field[0][1:] == 'DATE':
|
||||||
@ -517,39 +518,43 @@ def getDocInfos(doc, code):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
#print(value)
|
#print(value)
|
||||||
if value != "":
|
if value != "":
|
||||||
res[field[0]] = False
|
res[field[0]] = [value, False]
|
||||||
else:
|
else:
|
||||||
res[field[0]] = value
|
res[field[0]] = [value, True]
|
||||||
|
|
||||||
# Numbers
|
# Numbers
|
||||||
elif field[0][:-1] == 'NOINT':
|
elif field[0][:-1] == 'NOINT':
|
||||||
try:
|
try:
|
||||||
res["NO"] += value
|
res["NO"][0] += value
|
||||||
|
res["NO"][1] = True
|
||||||
except KeyError:
|
except KeyError:
|
||||||
res["NO"] = value
|
res["NO"] = [value, True]
|
||||||
|
|
||||||
elif field[0] == 'NOINT':
|
elif field[0] == 'NOINT':
|
||||||
try:
|
try:
|
||||||
res["NO"] += value
|
res["NO"][0] += value
|
||||||
|
res["NO"][1] = True
|
||||||
except KeyError:
|
except KeyError:
|
||||||
res["NO"] = value
|
res["NO"] = [value, True]
|
||||||
|
|
||||||
elif field[0] == 'FACULT':
|
elif field[0] == 'FACULT':
|
||||||
try:
|
try:
|
||||||
res["INDIC"] += value
|
res["INDIC"][0] += value
|
||||||
|
res["INDIC"][1] = True
|
||||||
except KeyError:
|
except KeyError:
|
||||||
res["INDIC"] = value
|
res["INDIC"] = [value, True]
|
||||||
|
|
||||||
# Sex
|
# Sex
|
||||||
elif field[0] == 'SEX':
|
elif field[0] == 'SEX':
|
||||||
if not value in "MF":
|
if not value in "MF":
|
||||||
res[field[0]] = False
|
res[field[0]] = [value, False]
|
||||||
else:
|
else:
|
||||||
res[field[0]] = value
|
res[field[0]] = [value, True]
|
||||||
|
|
||||||
# All other cases
|
# All other cases
|
||||||
else:
|
else:
|
||||||
if value != "":
|
if value != "":
|
||||||
res[field[0]] = value
|
res[field[0]] = [value, True]
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ VSVersionInfo(
|
|||||||
ffi=FixedFileInfo(
|
ffi=FixedFileInfo(
|
||||||
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
|
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
|
||||||
# Set not needed items to zero 0.
|
# Set not needed items to zero 0.
|
||||||
filevers=(3, 1, 4, 0),
|
filevers=(3, 1, 5, 0),
|
||||||
prodvers=(3, 1, 4, 0),
|
prodvers=(3, 1, 5, 0),
|
||||||
# Contains a bitmask that specifies the valid bits 'flags'r
|
# Contains a bitmask that specifies the valid bits 'flags'r
|
||||||
mask=0x3f,
|
mask=0x3f,
|
||||||
# Contains a bitmask that specifies the Boolean attributes of the file.
|
# Contains a bitmask that specifies the Boolean attributes of the file.
|
||||||
@ -31,12 +31,12 @@ StringFileInfo(
|
|||||||
u'040904B0',
|
u'040904B0',
|
||||||
[StringStruct(u'CompanyName', u'Adrien Bourmault (neox95)'),
|
[StringStruct(u'CompanyName', u'Adrien Bourmault (neox95)'),
|
||||||
StringStruct(u'FileDescription', u'This file is part of CNIRevelator.'),
|
StringStruct(u'FileDescription', u'This file is part of CNIRevelator.'),
|
||||||
StringStruct(u'FileVersion', u'3.1.4'),
|
StringStruct(u'FileVersion', u'3.1.5'),
|
||||||
StringStruct(u'InternalName', u'CNIRevelator'),
|
StringStruct(u'InternalName', u'CNIRevelator'),
|
||||||
StringStruct(u'LegalCopyright', u'Copyright (c) Adrien Bourmault (neox95)'),
|
StringStruct(u'LegalCopyright', u'Copyright (c) Adrien Bourmault (neox95)'),
|
||||||
StringStruct(u'OriginalFilename', u'CNIRevelator.exe'),
|
StringStruct(u'OriginalFilename', u'CNIRevelator.exe'),
|
||||||
StringStruct(u'ProductName', u'CNIRevelator 3.1'),
|
StringStruct(u'ProductName', u'CNIRevelator 3.1'),
|
||||||
StringStruct(u'ProductVersion', u'3.1.4')])
|
StringStruct(u'ProductVersion', u'3.1.5')])
|
||||||
]),
|
]),
|
||||||
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
|
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user