From c4ae41b54df4dddd0919fd56cccf94d8f1d2ed46 Mon Sep 17 00:00:00 2001 From: Taha Yassine Kraiem Date: Fri, 10 Mar 2023 11:45:33 +0100 Subject: [PATCH] feat(chalice): enhanced helper functions --- api/chalicelib/utils/helper.py | 2 ++ ee/api/chalicelib/core/unlock.py | 3 ++- ee/api/routers/crons/core_dynamic_crons.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/api/chalicelib/utils/helper.py b/api/chalicelib/utils/helper.py index 369aff40a..62fe6c248 100644 --- a/api/chalicelib/utils/helper.py +++ b/api/chalicelib/utils/helper.py @@ -318,4 +318,6 @@ def get_domain(): def obfuscate(text, keep_last: int = 4): if text is None or not isinstance(text, str): return text + if len(text) <= keep_last: + return "*" * len(text) return "*" * (len(text) - keep_last) + text[-keep_last:] diff --git a/ee/api/chalicelib/core/unlock.py b/ee/api/chalicelib/core/unlock.py index d656edf8a..646cea681 100644 --- a/ee/api/chalicelib/core/unlock.py +++ b/ee/api/chalicelib/core/unlock.py @@ -4,6 +4,7 @@ from os import environ import requests from decouple import config +from chalicelib.utils import helper from chalicelib.utils.TimeUTC import TimeUTC @@ -22,7 +23,7 @@ def check(): environ["expiration"] = "-1" environ["numberOfSeats"] = "0" return - print(f"validating: {license}") + print(f"validating: {helper.obfuscate(license)}") r = requests.post('https://api.openreplay.com/os/license', json={"mid": __get_mid(), "license": get_license()}) if r.status_code != 200 or "errors" in r.json() or not r.json()["data"].get("valid"): print("license validation failed") diff --git a/ee/api/routers/crons/core_dynamic_crons.py b/ee/api/routers/crons/core_dynamic_crons.py index 0ea096546..5d13c90d1 100644 --- a/ee/api/routers/crons/core_dynamic_crons.py +++ b/ee/api/routers/crons/core_dynamic_crons.py @@ -26,7 +26,7 @@ def unlock_cron() -> None: cron_jobs = [ - {"func": unlock_cron, "trigger": "cron", "hour": "*"}, + {"func": unlock_cron, "trigger": CronTrigger(day="*")}, ] SINGLE_CRONS = [{"func": telemetry_cron, "trigger": CronTrigger(day_of_week="*"),