diff --git a/troubadix/plugins/valid_oid.py b/troubadix/plugins/valid_oid.py index 4c6f92d3..b5a3af8b 100644 --- a/troubadix/plugins/valid_oid.py +++ b/troubadix/plugins/valid_oid.py @@ -82,12 +82,11 @@ def check_content( ) return + family_pattern = get_special_script_tag_pattern(SpecialScriptTag.FAMILY) + family_match = family_pattern.search(file_content) + # Vendor-specific OIDs if "1.3.6.1.4.1.25623.1.1." in oid: - family_pattern = get_special_script_tag_pattern( - SpecialScriptTag.FAMILY - ) - family_match = family_pattern.search(file_content) if family_match is None or family_match.group("value") is None: yield LinterError( "VT is missing a script family!", @@ -405,47 +404,41 @@ def check_content( return return + + # Fixed OID-scheme for Windows OIDs if "1.3.6.1.4.1.25623.1.3." in oid: - family_pattern = get_special_script_tag_pattern( - SpecialScriptTag.FAMILY - ) - family_match = family_pattern.search(file_content) - if not family_match or not family_match.group("value"): + family = family_match.group("value") + if not family_match or not family: yield LinterError( - "VT is missing a script name!", + "VT is missing a script family!", file=nasl_file, plugin=self.name, ) return - family = family_match.group("value") - - # Fixed OID-scheme for win-vt-generator - if "1.3.6.1.4.1.25623.1.3" in oid: - if family != windows_family_template: - yield LinterError( - f"script_oid() {is_using_reserved} 'Windows' (" - f"{str(oid)})", - file=nasl_file, - plugin=self.name, - ) - return - - windows_oid_match = re.search( - r"^1\.3\.6\.1\.4\.1\.25623\.1\.3\.[0-9]{5}\.[0-9]\.[0-9]{7}\.[0-9]{30}", - oid, + if family != windows_family_template: + yield LinterError( + f"script_oid() {is_using_reserved} 'Windows' (" + f"{str(oid)})", + file=nasl_file, + plugin=self.name, ) - if not windows_oid_match: - yield LinterError( - f"script_oid() {invalid_oid} '{str(oid)}' " - "(Windows pattern: 1.3.6.1.4.1.25623.1.3." - "[product_id].[platform_id].[kb_article_id].[fixed_build_number])", - file=nasl_file, - plugin=self.name, - ) - return + return + windows_oid_match = re.search( + r"^1\.3\.6\.1\.4\.1\.25623\.1\.3\.[0-9]{5}\.[0-9]\.[0-9]{7}\.[0-9]{30}", + oid, + ) + if not windows_oid_match: + yield LinterError( + f"script_oid() {invalid_oid} '{str(oid)}' " + "(Windows pattern: 1.3.6.1.4.1.25623.1.3." + "[product_id].[platform_id].[kb_article_id].[fixed_build_number])", + file=nasl_file, + plugin=self.name, + ) return + return oid_digit_match = re.search( r"^1\.3\.6\.1\.4\.1\.25623\.1\.0\.([0-9]+)", oid