mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 14:14:22 +01:00
Temporal fix for Cryptographer logs. Close #91
This commit is contained in:
@@ -13,6 +13,7 @@ from apps.cli import config, LOG_PREFIX
|
||||
from apps.cli.help import help_add_appointment, help_get_appointment
|
||||
from apps.cli.blob import Blob
|
||||
|
||||
import common.cryptographer
|
||||
from common import constants
|
||||
from common.logger import Logger
|
||||
from common.appointment import Appointment
|
||||
@@ -20,7 +21,7 @@ from common.cryptographer import Cryptographer
|
||||
from common.tools import check_sha256_hex_format, check_locator_format, compute_locator
|
||||
|
||||
logger = Logger(actor="Client", log_name_prefix=LOG_PREFIX)
|
||||
|
||||
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix=LOG_PREFIX)
|
||||
|
||||
# FIXME: creating a simpler load_keys for the alpha. Client keys will not be necessary. PISA key is hardcoded.
|
||||
# def load_keys(pisa_pk_path, cli_sk_path, cli_pk_path):
|
||||
|
||||
@@ -10,9 +10,8 @@ from cryptography.hazmat.primitives.serialization import load_der_public_key, lo
|
||||
from cryptography.exceptions import InvalidSignature
|
||||
from common.tools import check_sha256_hex_format
|
||||
|
||||
from common.logger import Logger
|
||||
|
||||
logger = Logger("Cryptographer")
|
||||
# FIXME: Common has not log file, so it needs to log in the same log as the caller. This is a temporary fix.
|
||||
logger = None
|
||||
|
||||
|
||||
class Cryptographer:
|
||||
@@ -39,12 +38,10 @@ class Cryptographer:
|
||||
|
||||
if len(data) % 2:
|
||||
error = "Incorrect (Odd-length) value"
|
||||
logger.error(error, data=data)
|
||||
raise ValueError(error)
|
||||
|
||||
if not check_sha256_hex_format(secret):
|
||||
error = "Secret must be a 32-byte hex value (64 hex chars)"
|
||||
logger.error(error, secret=secret)
|
||||
raise ValueError(error)
|
||||
|
||||
return True
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import re
|
||||
from binascii import unhexlify
|
||||
|
||||
import common.cryptographer
|
||||
from common.constants import LOCATOR_LEN_HEX
|
||||
from common.cryptographer import Cryptographer
|
||||
|
||||
@@ -10,6 +11,7 @@ from common.appointment import Appointment
|
||||
from pisa.block_processor import BlockProcessor
|
||||
|
||||
logger = Logger(actor="Inspector", log_name_prefix=LOG_PREFIX)
|
||||
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix=LOG_PREFIX)
|
||||
|
||||
# FIXME: The inspector logs the wrong messages sent form the users. A possible attack surface would be to send a really
|
||||
# long field that, even if not accepted by PISA, would be stored in the logs. This is a possible DoS surface
|
||||
|
||||
@@ -2,6 +2,7 @@ from getopt import getopt
|
||||
from sys import argv, exit
|
||||
from signal import signal, SIGINT, SIGQUIT, SIGTERM
|
||||
|
||||
import common.cryptographer
|
||||
from common.logger import Logger
|
||||
from common.cryptographer import Cryptographer
|
||||
|
||||
@@ -16,6 +17,7 @@ from pisa.block_processor import BlockProcessor
|
||||
from pisa.tools import can_connect_to_bitcoind, in_correct_network
|
||||
|
||||
logger = Logger(actor="Daemon", log_name_prefix=LOG_PREFIX)
|
||||
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix=LOG_PREFIX)
|
||||
|
||||
|
||||
def handle_signals(signal_received, frame):
|
||||
|
||||
@@ -2,6 +2,7 @@ from uuid import uuid4
|
||||
from queue import Queue
|
||||
from threading import Thread
|
||||
|
||||
import common.cryptographer
|
||||
from common.cryptographer import Cryptographer
|
||||
from common.appointment import Appointment
|
||||
from common.tools import compute_locator
|
||||
@@ -13,6 +14,7 @@ from pisa.cleaner import Cleaner
|
||||
from pisa.block_processor import BlockProcessor
|
||||
|
||||
logger = Logger(actor="Watcher", log_name_prefix=LOG_PREFIX)
|
||||
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix=LOG_PREFIX)
|
||||
|
||||
|
||||
class Watcher:
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
import responses
|
||||
import json
|
||||
import os
|
||||
@@ -9,6 +8,8 @@ from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import ec
|
||||
|
||||
import common.cryptographer
|
||||
from common.logger import Logger
|
||||
from common.tools import compute_locator
|
||||
from common.appointment import Appointment
|
||||
from common.cryptographer import Cryptographer
|
||||
@@ -17,6 +18,8 @@ from apps.cli.blob import Blob
|
||||
import apps.cli.wt_cli as wt_cli
|
||||
from test.apps.cli.unit.conftest import get_random_value_hex
|
||||
|
||||
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix=wt_cli.LOG_PREFIX)
|
||||
|
||||
# dummy keys for the tests
|
||||
dummy_sk = ec.generate_private_key(ec.SECP256K1, default_backend())
|
||||
dummy_pk = dummy_sk.public_key()
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import os
|
||||
import pytest
|
||||
import binascii
|
||||
from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives.asymmetric import ec
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
|
||||
import common.cryptographer
|
||||
from apps.cli.blob import Blob
|
||||
from common.logger import Logger
|
||||
from common.cryptographer import Cryptographer
|
||||
from pisa.encrypted_blob import EncryptedBlob
|
||||
from test.common.unit.conftest import get_random_value_hex
|
||||
|
||||
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix="")
|
||||
|
||||
data = "6097cdf52309b1b2124efeed36bd34f46dc1c25ad23ac86f28380f746254f777"
|
||||
key = "b2e984a570f6f49bc38ace178e09147b0aa296cbb7c92eb01412f7e2d07b5659"
|
||||
encrypted_data = "8f31028097a8bf12a92e088caab5cf3fcddf0d35ed2b72c24b12269373efcdea04f9d2a820adafe830c20ff132d89810"
|
||||
|
||||
@@ -7,6 +7,9 @@ from pisa import HOST, PORT
|
||||
from apps.cli import wt_cli
|
||||
from apps.cli.blob import Blob
|
||||
from apps.cli import config as cli_conf
|
||||
|
||||
import common.cryptographer
|
||||
from common.logger import Logger
|
||||
from common.tools import compute_locator
|
||||
from common.appointment import Appointment
|
||||
from common.cryptographer import Cryptographer
|
||||
@@ -19,6 +22,8 @@ from test.pisa.e2e.conftest import (
|
||||
run_pisad,
|
||||
)
|
||||
|
||||
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix="")
|
||||
|
||||
# We'll use wt_cli to add appointments. The expected input format is a list of arguments with a json-encoded
|
||||
# appointment
|
||||
wt_cli.pisa_api_server = HOST
|
||||
|
||||
@@ -22,9 +22,14 @@ from bitcoind_mock.transaction import create_dummy_transaction
|
||||
from bitcoind_mock.bitcoind import BitcoindMock
|
||||
from bitcoind_mock.conf import BTC_RPC_HOST, BTC_RPC_PORT
|
||||
|
||||
from pisa import LOG_PREFIX
|
||||
import common.cryptographer
|
||||
from common.logger import Logger
|
||||
from common.constants import LOCATOR_LEN_HEX
|
||||
from common.cryptographer import Cryptographer
|
||||
|
||||
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix=LOG_PREFIX)
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def run_bitcoind():
|
||||
|
||||
@@ -14,6 +14,12 @@ from test.pisa.unit.conftest import get_random_value_hex, generate_dummy_appoint
|
||||
|
||||
from common.constants import LOCATOR_LEN_BYTES, LOCATOR_LEN_HEX
|
||||
from common.cryptographer import Cryptographer
|
||||
from common.logger import Logger
|
||||
|
||||
from pisa import LOG_PREFIX
|
||||
import common.cryptographer
|
||||
|
||||
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix=LOG_PREFIX)
|
||||
|
||||
|
||||
inspector = Inspector(get_config())
|
||||
|
||||
@@ -20,9 +20,14 @@ from test.pisa.unit.conftest import (
|
||||
)
|
||||
from pisa.conf import EXPIRY_DELTA, MAX_APPOINTMENTS
|
||||
|
||||
import common.cryptographer
|
||||
from pisa import LOG_PREFIX
|
||||
from common.logger import Logger
|
||||
from common.tools import compute_locator
|
||||
from common.cryptographer import Cryptographer
|
||||
|
||||
common.cryptographer.logger = Logger(actor="Cryptographer", log_name_prefix=LOG_PREFIX)
|
||||
|
||||
|
||||
APPOINTMENTS = 5
|
||||
START_TIME_OFFSET = 1
|
||||
|
||||
Reference in New Issue
Block a user