]> git.ipfire.org Git - thirdparty/suricata-update.git/commitdiff
config: configure a custom user-agent-string
authorWolfgang Hotwagner <sec@feedyourhead.at>
Fri, 8 Dec 2017 16:39:52 +0000 (16:39 +0000)
committerJason Ish <ish@unx.ca>
Fri, 8 Dec 2017 22:09:00 +0000 (16:09 -0600)
Includes an command-line/config-file-option for a custom user-agent string.

suricata/update/configs/update.yaml
suricata/update/main.py
suricata/update/net.py

index ad6e5a7478bf3bc11ea248e213f09f5b49126f08..e113f539cdf821e5a690c9ff762ee0c9a4db7e70 100644 (file)
@@ -22,6 +22,9 @@ modify-conf: /etc/suricata/modify.conf
 ignore:
   - "*deleted.rules"
 
+# Override the user-agent string.
+#user-agent: "Suricata-Update"
+
 # Provide an alternate command to the default test command.
 #
 # The following environment variables can be used.
index cb12c678f4921c7e229aa09757d646e4d28d5aed..cf00cdc3f1409aa9e39e0f0314105c752be2cafd 100644 (file)
@@ -1011,6 +1011,8 @@ def _main():
     
     update_parser.add_argument("--no-merge", action="store_true", default=False,
                                help="Do not merge the rules into a single file")
+    update_parser.add_argument("--user-agent", metavar="<user-agent>",
+                               help="Set custom user-agent string")
 
     update_parser.add_argument("-h", "--help", action="store_true")
     
@@ -1181,6 +1183,12 @@ def _main():
         logger.info("Loading %s.", drop_conf_filename)
         drop_filters += load_drop_filters(drop_conf_filename)
 
+    # Load custom user-agent-string
+    user_agent = config.get("user-agent")
+    if user_agent:
+        logger.info("Using user-agent: %s.",user_agent)
+        suricata.update.net.set_custom_user_agent(user_agent)
+
     if os.path.exists("/etc/suricata/suricata.yaml") and \
        suricata_path and os.path.exists(suricata_path):
         logger.info("Loading /etc/suricata/suricata.yaml")
index f89a4cadcb4c2338d7e1f87ca0b4670351a3c6cc..6fb68c6d912483e674538880a7a832c59d6dc084 100644 (file)
@@ -37,6 +37,11 @@ logger = logging.getLogger()
 GET_BLOCK_SIZE = 8192
 
 user_agent_suricata_verison = "Unknown"
+custom_user_agent = None
+
+def set_custom_user_agent(ua):
+    global custom_user_agent
+    custom_user_agent = ua
 
 def set_user_agent_suricata_version(version):
     global user_agent_suricata_verison
@@ -45,6 +50,9 @@ def set_user_agent_suricata_version(version):
 def build_user_agent():
     params = []
 
+    if custom_user_agent is not None:
+        return custom_user_agent
+
     uname_system = platform.uname()[0]
 
     params.append("OS: %s" % (uname_system))