Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set CAP signature check based on env variable #831

Merged
merged 2 commits into from
Jan 7, 2025

Conversation

maaikelimper
Copy link
Collaborator

set CAP signature check based on env variable

#823

@@ -74,8 +76,11 @@ def transform(self, input_data: Union[Path, bytes],
# add relative filepath to _meta
_meta['relative_filepath'] = self.get_local_filepath(_meta['data_date']) # noqa

# check CAP signature based on ENV variable, default is False
check_cap_signature = os.getenv('CHECK_CAP_SIGNATURE', False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Environment variables are not typechecked. Suggest the following:

  1. add in wis2box-management/wis2box/util.py:
def str2bool(value: Union[bool, str]) -> bool:
    """
    helper function to return Python boolean
    type (source: https://stackoverflow.com/a/715468)

    :param value: value to be evaluated

    :returns: `bool` of whether the value is boolean-ish
    """

    value2 = False

    if isinstance(value, bool):
        value2 = value
    else:
        value2 = value.lower() in ('yes', 'true', 't', '1', 'on')

    return value2
  1. back in wis2box-management/wis2box/data/cap_message.py, update with:
from wis2box.util import str2bool

Then:

check_cap_signature = str2bool(os.getenv('CHECK_CAP_SIGNATURE', False))

@tomkralidis tomkralidis merged commit 5af06bf into main Jan 7, 2025
7 checks passed
@tomkralidis tomkralidis deleted the cap-signature-check-using-env branch January 7, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants