1
0
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:
Adrien Bourmault 2019-08-27 16:49:01 +02:00 committed by GitHub
parent 624b78d9d1
commit 83a6e110f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 71 additions and 31 deletions

View File

@ -25,14 +25,41 @@
"""
from requests.auth import HTTPProxyAuth
from pypac import PACSession
from Crypto import Random
from Crypto.Cipher import AES
from requests import Session
import json
import json, hashlib, base64
import logger # logger.py
import globs # globs.py
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=""):
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"]}
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)
@ -54,4 +81,12 @@ def reportBug(reason="",log=""):
else:
return False
def encryptToken(token):
AESObj = AESCipher(globs.CNIRCryptoKey)
return AESObj.encrypt(token)
def decryptToken(token):
AESObj = AESCipher(globs.CNIRCryptoKey)
return AESObj.decrypt(token)

View File

@ -26,13 +26,13 @@
import os
# CNIRevelator version
verType = "stable release"
version = [3, 1, 4]
verType = "beta release"
version = [3, 1, 5]
verstring_full = "{}.{}.{} {}".format(version[0], version[1], version[2], verType)
verstring = "{}.{}".format(version[0], version[1])
CNIRTesserHash = "947224361ffab8c01f05c9394b44b1bd7c8c3d4d"
CNIRGitToken = "ef7737dd1e5ad8a35d3cc5fdbeb273e69a09f25f"
CNIRGitToken = "mJHKXqnazO/xZ9Fs18SDMqcGJ15A27OlZyd27cDe5dhHKklO2YShdWwUgEDUZQI02kpgYaLceMidTK37ZqakW+VYgPPuh0e9Ry2IH0KHc3o="
CNIRFolder = os.path.dirname(os.path.realpath(__file__))
CNIRLColor = "#006699"
CNIRName = "CNIRevelator {}".format(verstring)

View File

@ -172,7 +172,7 @@ class mainWindow(Tk):
"SEX" : self.sex,
"NAT" : self.nat,
"PAYS" : self.pays,
"INDIC" : self.indic,
"INDIC" : self.indic
}
# The the image viewer
@ -723,12 +723,12 @@ class mainWindow(Tk):
#print(docInfos)
# display the infos
for key in [ e for e in docInfos ]:
#print(docInfos[key])
if key in ["CODE", "CTRL", "CTRLF"]:
print(key)
if key in ["CODE", "CTRL", "CTRLF", "FACULT"]:
continue
if not docInfos[key] == False:
if not docInfos[key] == "":
self.infoList[key]['text'] = docInfos[key]
if not docInfos[key][1] == False:
if not docInfos[key][0] == "":
self.infoList[key]['text'] = docInfos[key][0]
self.infoList[key]['background'] = self['background']
self.infoList[key]['foreground'] = "black"
else:
@ -738,7 +738,7 @@ class mainWindow(Tk):
else:
self.infoList[key]['background'] = "red"
self.infoList[key]['foreground'] = "white"
self.infoList[key]['text'] = "NC"
self.infoList[key]['text'] = docInfos[key][0]
self.compliance = False
if self.compliance == True:

View File

@ -490,18 +490,19 @@ def getDocInfos(doc, code):
for field in infoTypes:
value = code[ field[1][0] : field[1][1] ].replace("<", " ").strip()
res[field[0]] = [0,0]
# State code
if field[0] == 'PAYS' or field[0] == 'NAT':
try:
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] == "<":
res[field[0]] = landcode2[value[:-1]]
res[field[0]] = (landcode2[value[:-1]], True)
else:
res[field[0]] = landcode2[value]
res[field[0]] = (landcode2[value], True)
except KeyError:
res[field[0]] = False
res[field[0]] = [value, False]
# Dates
elif field[0][1:] == 'DATE':
@ -517,39 +518,43 @@ def getDocInfos(doc, code):
except ValueError:
#print(value)
if value != "":
res[field[0]] = False
res[field[0]] = [value, False]
else:
res[field[0]] = value
res[field[0]] = [value, True]
# Numbers
elif field[0][:-1] == 'NOINT':
try:
res["NO"] += value
res["NO"][0] += value
res["NO"][1] = True
except KeyError:
res["NO"] = value
res["NO"] = [value, True]
elif field[0] == 'NOINT':
try:
res["NO"] += value
res["NO"][0] += value
res["NO"][1] = True
except KeyError:
res["NO"] = value
res["NO"] = [value, True]
elif field[0] == 'FACULT':
try:
res["INDIC"] += value
res["INDIC"][0] += value
res["INDIC"][1] = True
except KeyError:
res["INDIC"] = value
res["INDIC"] = [value, True]
# Sex
elif field[0] == 'SEX':
if not value in "MF":
res[field[0]] = False
res[field[0]] = [value, False]
else:
res[field[0]] = value
res[field[0]] = [value, True]
# All other cases
else:
if value != "":
res[field[0]] = value
res[field[0]] = [value, True]
return res

View File

@ -6,8 +6,8 @@ VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0.
filevers=(3, 1, 4, 0),
prodvers=(3, 1, 4, 0),
filevers=(3, 1, 5, 0),
prodvers=(3, 1, 5, 0),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
@ -31,12 +31,12 @@ StringFileInfo(
u'040904B0',
[StringStruct(u'CompanyName', u'Adrien Bourmault (neox95)'),
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'LegalCopyright', u'Copyright (c) Adrien Bourmault (neox95)'),
StringStruct(u'OriginalFilename', u'CNIRevelator.exe'),
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])])
]