From d91070c116d5215e61ddfc2e9da7802aa5ba93e7 Mon Sep 17 00:00:00 2001 From: Aayush Goel <81844215+Aayush-Goel-04@users.noreply.github.com> Date: Mon, 8 May 2023 20:17:29 +0530 Subject: [PATCH] Update detect_duplicate_features.py --- scripts/detect_duplicate_features.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/scripts/detect_duplicate_features.py b/scripts/detect_duplicate_features.py index b44a30ad..0ce8ff3a 100644 --- a/scripts/detect_duplicate_features.py +++ b/scripts/detect_duplicate_features.py @@ -5,11 +5,15 @@ import capa.rules import capa.engine as ceng -def get_child_features(feature) -> list: +def get_child_features(feature: ceng.Statement) -> list: """ - args: - \tfeature : capa.rule.Rule.statement containing feature statements - returns a list containg all the features in the rule + Recursively extracts all feature statements from a given rule statement. + + Args: + feature (capa.engine.Statement): The feature statement to extract features from. + + Returns: + list: A list of all feature statements contained within the given feature statement. """ children = [] @@ -23,11 +27,15 @@ def get_child_features(feature) -> list: return children -def get_features(rule_path): +def get_features(rule_path: str) -> list: """ - args: - \tfeature : rule path - returns a list containg all the features in the rule + Extracts all features from a given rule file. + + Args: + rule_path (str): The path to the rule file to extract features from. + + Returns: + list: A list of all feature statements contained within the rule file. """ feature_list = [] with open(rule_path, "r") as f: