From: Roland Häder Date: Tue, 1 Oct 2024 16:52:05 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=418159cce25720bc1faef26dc2d6c9c86c0cb653;p=fba.git Continued: - added function update() for "model" obfuscation (module name and table name must match as this is naming convention) - added column 'last_used' to table 'obfuscation' --- diff --git a/blocks_empty.db b/blocks_empty.db index daea60b..d36e78c 100644 Binary files a/blocks_empty.db and b/blocks_empty.db differ diff --git a/fba/commands.py b/fba/commands.py index dc4980a..d862ce1 100644 --- a/fba/commands.py +++ b/fba/commands.py @@ -379,8 +379,11 @@ def fetch_blocks(args: argparse.Namespace) -> int: logger.warning("Cannot deobfuscate block[blocked]='%s',blocker='%s',software='%s' - SKIPPED!", block["blocked"], blocker, software) if not obfuscation.is_added(block["blocked"]): - logger.debug("Invoking add(%s)", block["blocked"]) + logger.debug("Invoking obfuscation.add(%s) ...", block["blocked"]) obfuscation.add(block["blocked"]) + else: + logger.debug("Invoking obfuscation.update(%s) ...", block["blocked"]) + obfuscation.update(block["blocked"]) continue @@ -401,8 +404,11 @@ def fetch_blocks(args: argparse.Namespace) -> int: logger.warning("Cannot deobfuscate block[blocked]='%s',blocker='%s',software='%s' - SKIPPED!", block["blocked"], blocker, software) if not obfuscation.is_added(block["blocked"]): - logger.debug("Invoking add(%s)", block["blocked"]) + logger.debug("Invoking obfuscation.add(%s) ...", block["blocked"]) obfuscation.add(block["blocked"]) + else: + logger.debug("Invoking obfuscation.update(%s) ...", block["blocked"]) + obfuscation.update(block["blocked"]) continue diff --git a/fba/models/obfuscation.py b/fba/models/obfuscation.py index cdbb19b..1db0815 100644 --- a/fba/models/obfuscation.py +++ b/fba/models/obfuscation.py @@ -56,6 +56,22 @@ def add(pattern: str) -> None: logger.debug("EXIT!") +def update (pattern: str) -> None: + logger.debug("pattern='%s' - CALLED!", pattern) + if not isinstance(pattern, str): + raise ValueError(f"pattern[]='{type(pattern)}' is not of type 'str'") + elif pattern == "": + raise ValueError("Parametern 'pattern' is an empty string") + elif not is_added(pattern): + raise Exception(f"pattern='{pattern}' is not added but function was invoked") + + database.cursor.execute("UPDATE obfuscation SET last_used=? WHERE pattern=? LIMIT 1", ( + time.time(), + pattern + )) + + logger.debug("EXIT!") + def delete (pattern: str) -> None: logger.debug("pattern='%s' - CALLED!", pattern) if not isinstance(pattern, str):