From 418159cce25720bc1faef26dc2d6c9c86c0cb653 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 1 Oct 2024 18:52:05 +0200 Subject: [PATCH] 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' --- blocks_empty.db | Bin 57344 -> 57344 bytes fba/commands.py | 10 ++++++++-- fba/models/obfuscation.py | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/blocks_empty.db b/blocks_empty.db index daea60bdb128ce57d407722a7cf6c087820d420c..d36e78c6ff3fbe6ae1adbc06c57b9d8fcc2895cd 100644 GIT binary patch delta 118 zcmZoTz}#?vd4jYc4+8@O9}sf`F%uBSOw=(}$n=gv< wGH(R0Dn~W@tBnm#>=PHrhyj(%1!@9=Mm`>Pab;!3#^lLo*mE~0a?HOD0L~B 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): -- 2.39.5