from common.ifwi import IFWI_IMAGE from common.firmware_volume import FirmwareDevice from common.siip_constants import IP_OPTIONS from common.tools_path import FMMT, GENFV, GENFFS, GENSEC, LZCOMPRESS, TOOLS_DIR from common.tools_path import RSA_HELPER, FMMT_CFG from common.siip_constants import VERSION as __version__ from common.banner import banner import common.logging as logging __prog__ = "siip_stitch" TOOLNAME = "SIIP Stitching Tool" banner(TOOLNAME, __version__) logger = logging.getLogger("siip_stitch") if sys.version_info < (3, 6): raise Exception("Python 3.6 is the minimal version required") GUID_FFS_OBBPEI_HASH = uuid.UUID("F57757FC-2603-404F-AAE2-34C6232388E8") GUID_FFS_OBBDXE_HASH = uuid.UUID("32198477-7337-40E4-897D-BC33F018B42F") # Region for OBBPEI digest GUID_FVOSBOOT = uuid.UUID("13BF8810-75FD-4B1A-91E6-E16C4201F80A") GUID_FVUEFIBOOT = uuid.UUID("0496D33D-EA79-495C-B65D-ABF607184E3B") GUID_FVADVANCED = uuid.UUID("B23E7388-9953-45C7-9201-0473DDE5487A") # Region for OBBDXE digest GUID_FVPOSTMEMORY = uuid.UUID("9DFE49DB-8EF0-4D9C-B273-0036144DE917") GUID_FVFSPS = uuid.UUID(
import os import sys import argparse from datetime import datetime from enum import Enum import struct from ctypes import Structure from ctypes import c_char, c_uint32, c_uint8, c_uint64, c_uint16, sizeof, ARRAY sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from common.banner import banner import common.logging as logging logger = logging.getLogger("siip_sign") try: from cryptography.hazmat.primitives import hashes as hashes from cryptography.hazmat.primitives import serialization as serialization from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import padding as crypto_padding # Check its version import cryptography if cryptography.__version__ < "2.2.2": logger.critical("Error: Cryptography version must be 2.2.2 or higher" " (installed version: {})".format( cryptography.__version__)) exit(1)
""" import sys import os import argparse import glob sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import common.subregion_descriptor as subrgn_descrptr import common.subregion_image as sbrgn_image import common.utilities as utils from common.tools_path import EDK2_CAPSULE_TOOL from common.banner import banner import common.logging as logging logger = logging.getLogger("subregion_capsule") if sys.version_info < (3, 7): raise Exception("Python 3.7 is the minimal version required") # # Globals for help information # __prog__ = "subregion_capsule" __version__ = "0.7.3" TOOLNAME = "Sub-Region Capsule Tool" banner(TOOLNAME, __version__)
import os import sys import subprocess import argparse import uuid import struct import re from pathlib import Path sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from common.siip_constants import VERSION as __version__ from common.banner import banner import common.utilities as utils import common.logging as logging LOGGER = logging.getLogger("subregion_sign") __prog__ = "subregion_sign" TOOLNAME = "Sub-Region Signing Tool" banner(TOOLNAME, __version__) if sys.version_info < (3, 6): raise Exception("Python 3.6 is the minimal version required") class UefiSubregAuthenClass: """ Class define EFI subreation Authentication class """ # typedef struct {
class ResourceDecorator(object): _logger = logging.getLogger('http') _caught_exceptions = ( common.exceptions.InvalidInputError, common.exceptions.ForbiddenError, common.exceptions.NotFoundError, common.exceptions.ConflictError, common.exceptions.DuplicateError, common.exceptions.ServiceError, ) def __init__(self, decorated_method): self._decorated_method = decorated_method @staticmethod def generate_meta(start_time, result): """ Generate metadata to be appended to the JSON data """ return { 'service': common.config.get('rest', 'service_name'), 'version': common.config.get('rest', 'service_version'), 'path': flask.request.path, 'method': flask.request.method, 'parameters': { 'headers': dict(flask.request.headers), 'form': dict(flask.request.form or {}), 'args': dict(flask.request.args or {}), 'json': flask.request.json, }, 'timestamp': { 'start': start_time, 'end': time.time(), }, 'response': { 'code': result[1], } } def __call__(self, *args, **kwargs): # remember when we started start_time = time.time() # try to execute the decorated method try: result = self._decorated_method(*args, **kwargs) except werkzeug.exceptions.HTTPException as error: if hasattr(error, 'data'): data = error.data else: data = '' result = data, error.code, error.get_headers() except self._caught_exceptions as error: result = { 'message': error.args[0], 'type': error.__class__.__name__ }, error.http_code, {} except Exception as error: exec_info = sys.exc_info() result = { 'type': error.__class__.__module__ + '.' + error.__class__.__name__, 'message': str(error), 'traceback': traceback.format_exception(*exec_info), }, 500, {} # format result if necessary if not isinstance(result, tuple): result = result, 200, {} if result[1] == 204: result = {}, 200, {} # logging log_level = { 4: logging.WARNING, 5: logging.ERROR, }.get(result[1]//100, logging.DEBUG) request_identifier = common.generators.wordlike_identifier(7) self._logger.log(log_level, '%s: %s %s\n\t%s\n\t%s' % ( request_identifier, flask.request.method, flask.request.url, json.dumps(dict(flask.request.headers), indent=4).replace('\n', '\n\t'), json.dumps(flask.request.json, indent=4).replace('\n', '\n\t'), )) try: debugvalue = json.dumps(result[0], indent=4).replace('\n', '\n\t') except: debugvalue = repr(result[0]) self._logger.log(log_level, '%s:%s: \n\t%s' % ( request_identifier, result[1], debugvalue, )) # add meta parameter and return corresponding result try: if common.config.get('rest', 'debug') and isinstance(result[0], dict): result[0].update(_meta = self.generate_meta(start_time, result)) except Exception as error: try: result[0].update(_meta = { 'ERROR_WHILE_GENERATING_META': str(error) }) except: pass return result