From 0dcf087c2b59f83ff747632e31f29b7d2f72d028 Mon Sep 17 00:00:00 2001 From: Zack McCauley Date: Thu, 11 Jan 2024 14:46:22 -0800 Subject: [PATCH 1/3] Add checks for incomplete tags in EAs --- pre_commit_hooks/check_jamf_extension_attributes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pre_commit_hooks/check_jamf_extension_attributes.py b/pre_commit_hooks/check_jamf_extension_attributes.py index 21fa95d..ebf76bf 100644 --- a/pre_commit_hooks/check_jamf_extension_attributes.py +++ b/pre_commit_hooks/check_jamf_extension_attributes.py @@ -3,7 +3,7 @@ """Check Jamf extension attributes for common issues.""" import argparse -import os +import re def build_argument_parser(): @@ -29,8 +29,12 @@ def main(argv=None): ea_content = openfile.read() if "" not in ea_content or "" not in ea_content: - print("{}: missing and/or tags".format(filename)) + print(f"{filename}: missing and/or tags") retval = 1 + all_results = len(re.findall("result.*\/result", ea_content)) + proper_results = len(re.findall("<.*>.*<\/.*>", ea_content)) + if proper_results < all_results: + print(f"{filename}: has an incomplete tags!") return retval From 1225d67ca61742999e7d34eb852cb4b62347cbc1 Mon Sep 17 00:00:00 2001 From: Zack McCauley Date: Thu, 11 Jan 2024 14:49:25 -0800 Subject: [PATCH 2/3] Tighten proper tags to just results tags --- pre_commit_hooks/check_jamf_extension_attributes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_commit_hooks/check_jamf_extension_attributes.py b/pre_commit_hooks/check_jamf_extension_attributes.py index ebf76bf..55b776c 100644 --- a/pre_commit_hooks/check_jamf_extension_attributes.py +++ b/pre_commit_hooks/check_jamf_extension_attributes.py @@ -32,7 +32,7 @@ def main(argv=None): print(f"{filename}: missing and/or tags") retval = 1 all_results = len(re.findall("result.*\/result", ea_content)) - proper_results = len(re.findall("<.*>.*<\/.*>", ea_content)) + proper_results = len(re.findall(".*<\/result>", ea_content)) if proper_results < all_results: print(f"{filename}: has an incomplete tags!") From 9cb4fbb1ae1c57d54cb5ad324ebcb39ccb0dab2f Mon Sep 17 00:00:00 2001 From: Zack McCauley Date: Fri, 12 Jan 2024 08:31:03 -0800 Subject: [PATCH 3/3] Removed an, improved grammer --- pre_commit_hooks/check_jamf_extension_attributes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pre_commit_hooks/check_jamf_extension_attributes.py b/pre_commit_hooks/check_jamf_extension_attributes.py index 55b776c..df3c97e 100644 --- a/pre_commit_hooks/check_jamf_extension_attributes.py +++ b/pre_commit_hooks/check_jamf_extension_attributes.py @@ -34,7 +34,7 @@ def main(argv=None): all_results = len(re.findall("result.*\/result", ea_content)) proper_results = len(re.findall(".*<\/result>", ea_content)) if proper_results < all_results: - print(f"{filename}: has an incomplete tags!") + print(f"{filename}: has incomplete tags!") return retval