There is a security vulnerability in SSH key-generation using GitKraken < v8.0.1. If you used this tool to create SSH keys, please update GitKraken and regenerate. If you need help with this, contact forum-support@opengroup.org

partition_info.py 1.01 KB
Newer Older
1
import logging
Luc Yriarte's avatar
Luc Yriarte committed
2
from typing import Optional
Christophe Lallement's avatar
Christophe Lallement committed
3
from datetime import datetime
4

Luc Yriarte's avatar
Luc Yriarte committed
5
6
7
from osdu_az.identity.az_identity import AzureIdentity


8
9
_LOGGER = logging.getLogger(__name__)

10
11

class PartitionInfo:
Luc Yriarte's avatar
Luc Yriarte committed
12
13
14
    def __init__(self, partition_properties: dict = None):
        self._partition_properties = partition_properties

Yannick's avatar
Yannick committed
15
    def get_value(self, property_name: str) -> Optional[str]:
Luc Yriarte's avatar
Luc Yriarte committed
16
17
18
19
20
21
22
        partition_property = self._partition_properties.get(property_name)
        if not partition_property:
            return None

        if not partition_property.get('sensitive'):
            return partition_property['value']

23
        if 'secret' not in partition_property:
Yannick's avatar
Yannick committed
24
            partition_property['secret'] = self._get_secret(partition_property['value'])
25
        return partition_property['secret']
Luc Yriarte's avatar
Luc Yriarte committed
26

Yannick's avatar
Yannick committed
27
    def _get_secret(self, key: str) -> str:
28
        ts = datetime.utcnow()
Yannick's avatar
Yannick committed
29
        secret = AzureIdentity.get_secret(key)
30
31
        _LOGGER.info(f'PartitionInfo get secret took {(datetime.utcnow() - ts).total_seconds()} ms')
        return secret
Luc Yriarte's avatar
Luc Yriarte committed
32
33