]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 1 Oct 2024 16:52:05 +0000 (18:52 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 1 Oct 2024 16:54:31 +0000 (18:54 +0200)
- 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
fba/commands.py
fba/models/obfuscation.py

index daea60bdb128ce57d407722a7cf6c087820d420c..d36e78c6ff3fbe6ae1adbc06c57b9d8fcc2895cd 100644 (file)
Binary files a/blocks_empty.db and b/blocks_empty.db differ
index dc4980af2b9a3a83d085434e551a3460ef3bb3e9..d862ce14593d6e039182aa4b81ed8845c8a9cd8b 100644 (file)
@@ -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
 
index cdbb19bb4a3fa84c6d06b213806dd6cb7c45c3cb..1db08159a8fbbe4d2e3a761f15a57dec70665d8a 100644 (file)
@@ -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):