From 3f9809f36c969e9d3e1e416108ef0ae8fe235c1a Mon Sep 17 00:00:00 2001 From: Nex Date: Sat, 11 Sep 2021 02:39:33 +0200 Subject: [PATCH] Formatting docstrings --- mvt/common/indicators.py | 8 -------- mvt/common/module.py | 3 --- mvt/common/url.py | 8 ++------ mvt/common/utils.py | 5 ----- 4 files changed, 2 insertions(+), 22 deletions(-) diff --git a/mvt/common/indicators.py b/mvt/common/indicators.py index 4f0c36b..93f42a5 100644 --- a/mvt/common/indicators.py +++ b/mvt/common/indicators.py @@ -35,7 +35,6 @@ class Indicators: :param file_path: Path to the STIX2 file to parse :type file_path: str - """ self.log.info("Parsing STIX2 indicators file at path %s", file_path) @@ -75,9 +74,7 @@ class Indicators: :type url: str :returns: True if the URL matched an indicator, otherwise False :rtype: bool - """ - # TODO: If the IOC domain contains a subdomain, it is not currently # being matched. if not url: @@ -148,7 +145,6 @@ class Indicators: :type urls: list :returns: True if any URL matched an indicator, otherwise False :rtype: bool - """ if not urls: return False @@ -167,7 +163,6 @@ class Indicators: :type process: str :returns: True if process matched an indicator, otherwise False :rtype: bool - """ if not process: return False @@ -193,7 +188,6 @@ class Indicators: :type processes: list :returns: True if process matched an indicator, otherwise False :rtype: bool - """ if not processes: return False @@ -211,7 +205,6 @@ class Indicators: :type email: str :returns: True if email address matched an indicator, otherwise False :rtype: bool - """ if not email: return False @@ -230,7 +223,6 @@ class Indicators: :type file_path: str :returns: True if the file path matched an indicator, otherwise False :rtype: bool - """ if not file_path: return False diff --git a/mvt/common/module.py b/mvt/common/module.py index dfef7b1..fb6a44d 100644 --- a/mvt/common/module.py +++ b/mvt/common/module.py @@ -44,7 +44,6 @@ class MVTModule(object): :param log: Handle to logger :param results: Provided list of results entries :type results: list - """ self.file_path = file_path self.base_folder = base_folder @@ -113,7 +112,6 @@ class MVTModule(object): """Serialize entry as JSON to deduplicate repeated entries :param timeline: List of entries from timeline to deduplicate - """ timeline_set = set() for record in timeline: @@ -192,7 +190,6 @@ def save_timeline(timeline, timeline_path): :param timeline: List of records to order and store :param timeline_path: Path to the csv file to store the timeline to - """ with io.open(timeline_path, "a+", encoding="utf-8") as handle: csvoutput = csv.writer(handle, delimiter=",", quotechar="\"") diff --git a/mvt/common/url.py b/mvt/common/url.py index ba210d4..505787b 100644 --- a/mvt/common/url.py +++ b/mvt/common/url.py @@ -268,7 +268,6 @@ class URL: :type url: str :returns: Domain name extracted from URL :rtype: str - """ # TODO: Properly handle exception. try: @@ -283,7 +282,6 @@ class URL: :type url: str :returns: Top-level domain name extracted from URL :rtype: str - """ # TODO: Properly handle exception. try: @@ -294,11 +292,8 @@ class URL: def check_if_shortened(self) -> bool: """Check if the URL is among list of shortener services. - :returns: True if the URL is shortened, otherwise False - :rtype: bool - """ if self.domain.lower() in SHORTENER_DOMAINS: self.is_shortened = True @@ -306,7 +301,8 @@ class URL: return self.is_shortened def unshorten(self): - """Unshorten the URL by requesting an HTTP HEAD response.""" + """Unshorten the URL by requesting an HTTP HEAD response. + """ res = requests.head(self.url) if str(res.status_code).startswith("30"): return res.headers["Location"] diff --git a/mvt/common/utils.py b/mvt/common/utils.py index aef8ad1..6f25768 100644 --- a/mvt/common/utils.py +++ b/mvt/common/utils.py @@ -16,7 +16,6 @@ def convert_mactime_to_unix(timestamp, from_2001=True): :param from_2001: bool: Whether to (Default value = True) :param from_2001: Default value = True) :returns: Unix epoch timestamp. - """ if not timestamp: return None @@ -43,7 +42,6 @@ def convert_chrometime_to_unix(timestamp): :param timestamp: Chrome timestamp as int. :type timestamp: int :returns: Unix epoch timestamp. - """ epoch_start = datetime.datetime(1601, 1 , 1) delta = datetime.timedelta(microseconds=timestamp) @@ -57,7 +55,6 @@ def convert_timestamp_to_iso(timestamp): :type timestamp: int :returns: ISO timestamp string in YYYY-mm-dd HH:MM:SS.ms format. :rtype: str - """ try: return timestamp.strftime("%Y-%m-%d %H:%M:%S.%f") @@ -70,7 +67,6 @@ def check_for_links(text): :param text: Any provided text. :type text: str :returns: Search results. - """ return re.findall("(?Phttps?://[^\s]+)", text, re.IGNORECASE) @@ -96,7 +92,6 @@ def keys_bytes_to_string(obj): :param obj: Object to convert from bytes to string. :returns: Object converted to string. :rtype: str - """ new_obj = {} if not isinstance(obj, dict):