Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added parameter types and updated output schema check #12

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions .github/workflows/sanity_checks_utcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
'Vulnerability and Risk Management', 'Web Application', 'Breach and Attack Simulation (BAS)',
'Ticket Management']
OPERATION_CATEGORY = ["investigation", "containment", "remediation", "miscellaneous"]
PARAMETER_CATEGORY = ["text", "textarea", "integer", "datetime", "select", "multiselect", "checkbox", "password",
"json", "apiOperation", "email"]
PARAMETER_CATEGORY = ["text", "textarea", "integer", "datetime", "date", "select", "multiselect", "checkbox", "password",
"json", "apiOperation", "email", "object", "file", "richtext", "html", "decimal", "phone", "domain",
"filehash", "ipv4", "ipv6", "url"]


def get_info_file_path():
Expand Down Expand Up @@ -95,7 +96,7 @@ def init_test(self):
self.verify_configurations()

for op in self.connector_info.get("operations", []):
self.verify_operation(op)
self.verify_operation(op, self.connector_info.get("cs_approved"))

def verify_copyright_block(self):
for dirname, dirnames, filenames in os.walk('.'):
Expand Down Expand Up @@ -190,12 +191,12 @@ def verify_configurations(self):
for field in fields:
self.verify_parameter("Configurations", field)

def verify_operation(self, operation):
def verify_operation(self, operation, is_certified):
self.verify_operation_name(operation)
self.verify_operation_title(operation)
self.verify_operation_category(operation)
self.verify_operation_descriptions(operation)
self.verify_operation_output_schema(operation)
self.verify_operation_output_schema(operation, is_certified)

for param in operation.get("parameters", []):
self.verify_parameter(operation.get("title"), param)
Expand Down Expand Up @@ -237,7 +238,11 @@ def verify_operation_descriptions(self, operation):
else:
self.append_wrong(f"Operation: '{operation.get('operation')}' -> Operation description is missing.")

def verify_operation_output_schema(self, operation):
def verify_operation_output_schema(self, operation, is_certified):
action_names = ["Execute an API Call", "Execute an API Request"]
if any(name in operation.get("title") for name in action_names):
self.append_correct(
f"Operation: '{operation.get('operation')}' -> Operation output schema is available.")
if "conditional_output_schema" in operation:
op_output_schema = operation.get("conditional_output_schema")
elif "api_output_schema" in operation:
Expand All @@ -247,9 +252,12 @@ def verify_operation_output_schema(self, operation):
if op_output_schema:
self.append_correct(
f"Operation: '{operation.get('operation')}' -> Operation output schema is available.")
else:
elif is_certified:
self.append_wrong(
f"Operation: '{operation.get('operation')}' -> Operation output schema is missing.")
else:
self.append_warning(
f"Operation: '{operation.get('operation')}' -> Operation output schema is missing.")

def verify_parameter(self, op_name, params):
self.verify_parameter_name(op_name, params)
Expand Down Expand Up @@ -326,7 +334,7 @@ def main():
if test_conn.warning:
error_msg = f"\033[31mAll the checks didn't pass. '{test_conn.failed_test_count}' checks failed, " \
f"'{test_conn.warning_test_count}' checks had warnings out of '{total_checks}' checks.\n" \
+ test_conn.warning + test_conn.error
+ test_conn.error
else:
error_msg = f"\033[31mAll the checks didn't pass. '{test_conn.failed_test_count}' checks failed out of " \
f"'{total_checks}' checks.\n" + test_conn.error
Expand Down
Loading