From a1d9fb829915cafdd6a2609f46832cd2d815ff1d Mon Sep 17 00:00:00 2001 From: ggykx123 Date: Wed, 10 Jul 2024 09:11:00 +0000 Subject: [PATCH] Update main.py Remove redundant logic that checks for the existence of dist_rule_path. --- suricata/update/main.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/suricata/update/main.py b/suricata/update/main.py index 7814518..48a6a57 100644 --- a/suricata/update/main.py +++ b/suricata/update/main.py @@ -361,26 +361,26 @@ def load_dist_rules(files): dist_rule_path) return - if os.path.exists(dist_rule_path): - if not os.access(dist_rule_path, os.R_OK): - logger.warning("Distribution rule path not readable: %s", - dist_rule_path) - return - for filename in filenames: - path = os.path.join(dist_rule_path, filename) - if not os.path.exists(path): - continue - if not os.access(path, os.R_OK): - logger.warning("Distribution rule file not readable: %s", - path) - continue - logger.info("Loading distribution rule file %s", path) - try: - with open(path, "rb") as fileobj: - files.append(SourceFile(path, fileobj.read())) - except Exception as err: - logger.error("Failed to open {}: {}".format(path, err)) - sys.exit(1) + if not os.access(dist_rule_path, os.R_OK): + logger.warning("Distribution rule path not readable: %s", + dist_rule_path) + return + + for filename in filenames: + path = os.path.join(dist_rule_path, filename) + if not os.path.exists(path): + continue + if not os.access(path, os.R_OK): + logger.warning("Distribution rule file not readable: %s", + path) + continue + logger.info("Loading distribution rule file %s", path) + try: + with open(path, "rb") as fileobj: + files.append(SourceFile(path, fileobj.read())) + except Exception as err: + logger.error("Failed to open {}: {}".format(path, err)) + sys.exit(1) def load_classification(suriconf, files): filename = os.path.join("suricata", "classification.config")