Skip to content

Commit

Permalink
Merge pull request #84 from rapid7/description
Browse files Browse the repository at this point in the history
Description validator
  • Loading branch information
mhofert-r7 authored Feb 11, 2020
2 parents 42e42c2 + 86cd83e commit 6e32725
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ to simulate the `--all` flag.

## Changelog

* 2.16.0 - Add workflow description validator
* 2.15.0 - Fix issue in title validator, Add title validator for workflows, clean up requirements
* 2.14.0 - Fix issue where InputOutput validator would fail when missing required key
* 2.13.0 - Add screenshot validator
Expand Down
2 changes: 2 additions & 0 deletions icon_validator/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from icon_validator.rules.workflow_validators.workflow_icon_filename_validator import *
from icon_validator.rules.workflow_validators.workflow_screenshot_validator import *
from icon_validator.rules.workflow_validators.workflow_title_validator import *
from icon_validator.rules.workflow_validators.workflow_description_validator import *

# The order of this list is the execution order of the validators.
VALIDATORS = [
Expand Down Expand Up @@ -100,5 +101,6 @@
WorkflowICONFileNameValidator(),
WorkflowScreenshotValidator(),
WorkflowTitleValidator(),
WorkflowDescriptionValidator(),
WorkflowProfanityValidator()
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from icon_validator.rules.validator import KomandPluginValidator
from icon_validator.exceptions import ValidationException


class WorkflowDescriptionValidator(KomandPluginValidator):

@staticmethod
def validate_workflow_description_exists(spec):
if "description" not in spec.spec_dictionary():
raise ValidationException("Workflow description in yaml is missing.")

description = spec.spec_dictionary()["description"]
if description == "":
raise ValidationException("Workflow description in yaml can not be blank")

@staticmethod
def validate_workflow_description_punctuation(description):
if not description.endswith("."):
raise ValidationException("Description does not end with a period when it should.")
if description[0].islower():
raise ValidationException("Description should not start with a lower case letter.")
if description[0].isspace():
raise ValidationException("Description should not start with a whitespace character.")

def validate(self, spec):
WorkflowDescriptionValidator.validate_workflow_description_exists(spec)
WorkflowDescriptionValidator.validate_workflow_description_punctuation(spec.spec_dictionary()["description"])
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
long_description = fh.read()

setup(name="insightconnect_integrations_validators",
version="2.15.0",
version="2.16.0",
description="Validator tooling for InsightConnect integrations",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
20 changes: 20 additions & 0 deletions unit_test/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from icon_validator.rules.workflow_validators.workflow_icon_filename_validator import WorkflowICONFileNameValidator
from icon_validator.rules.workflow_validators.workflow_screenshot_validator import WorkflowScreenshotValidator
from icon_validator.rules.workflow_validators.workflow_title_validator import WorkflowTitleValidator
from icon_validator.rules.workflow_validators.workflow_description_validator import WorkflowDescriptionValidator


class TestPluginValidate(unittest.TestCase):
Expand Down Expand Up @@ -151,3 +152,22 @@ def test_title_validator(self):
file_to_test = "workflow_bad_caps.spec.yaml"
result = validate(directory_to_test, file_to_test, False, True, [WorkflowTitleValidator()])
self.assertTrue(result)

def test_description_validator(self):
# Test bad workflows. This will test the workflow_description_validator
directory_to_test = "workflow_examples/description_tests"
file_to_test = "workflow_no_description.spec.yaml"
result = validate(directory_to_test, file_to_test, False, True, [WorkflowDescriptionValidator()])
self.assertTrue(result)
file_to_test = "workflow_no_period.spec.yaml"
result = validate(directory_to_test, file_to_test, False, True, [WorkflowDescriptionValidator()])
self.assertTrue(result)
file_to_test = "workflow_whitespace.spec.yaml"
result = validate(directory_to_test, file_to_test, False, True, [WorkflowDescriptionValidator()])
self.assertTrue(result)
file_to_test = "workflow_blank_description.spec.yaml"
result = validate(directory_to_test, file_to_test, False, True, [WorkflowDescriptionValidator()])
self.assertTrue(result)
file_to_test = "workflow_lower_case.spec.yaml"
result = validate(directory_to_test, file_to_test, False, True, [WorkflowDescriptionValidator()])
self.assertTrue(result)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extension: workflow
products: ["insightconnect"]
name: Automated_Indicator_Enrichment
title: "Automated Indicator Enrichment"
description: ""
version: 1.0.0
vendor: rapid7
support: rapid7
status: []
hub_tags:
use_cases: [alerting_and_notifications, threat_detection_and_response]
keywords: [enrichment, slack, url, ip]
features: []
resources:
source_url: https://github.com/rapid7/insightconnect-workflows/tree/master/workflows/Automated_Indicator_Enrichment
license_url: https://github.com/rapid7/insightconnect-workflows/blob/master/LICENSE
screenshots:
- name: Automated_Indicator_Enrichment_Job.png
title: Example Job Output
- name: Automated_Indicator_Enrichment_Snapshot.png
title: Workflow View
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extension: workflow
products: ["insightconnect"]
name: Automated_Indicator_Enrichment
title: "Automated Indicator Enrichment"
description: "this workflow triggers from directly slack messaging the chatbot to \"!investigate\" the defined indicator. To date, this workflow supports automatically looking up URLs and IPs in open source threat intelligence such as VirusTotal and Whois. Lastly, the workflow will post back results to the specific user."
version: 1.0.0
vendor: rapid7
support: rapid7
status: []
hub_tags:
use_cases: [alerting_and_notifications, threat_detection_and_response]
keywords: [enrichment, slack, url, ip]
features: []
resources:
source_url: https://github.com/rapid7/insightconnect-workflows/tree/master/workflows/Automated_Indicator_Enrichment
license_url: https://github.com/rapid7/insightconnect-workflows/blob/master/LICENSE
screenshots:
- name: Automated_Indicator_Enrichment_Job.png
title: Example Job Output
- name: Automated_Indicator_Enrichment_Snapshot.png
title: Workflow View
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
extension: workflow
products: ["insightconnect"]
name: Automated_Indicator_Enrichment
title: "Automated Indicator Enrichment"
version: 1.0.0
vendor: rapid7
support: rapid7
status: []
hub_tags:
use_cases: [alerting_and_notifications, threat_detection_and_response]
keywords: [enrichment, slack, url, ip]
features: []
resources:
source_url: https://github.com/rapid7/insightconnect-workflows/tree/master/workflows/Automated_Indicator_Enrichment
license_url: https://github.com/rapid7/insightconnect-workflows/blob/master/LICENSE
screenshots:
- name: Automated_Indicator_Enrichment_Job.png
title: Example Job Output
- name: Automated_Indicator_Enrichment_Snapshot.png
title: Workflow View
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extension: workflow
products: ["insightconnect"]
name: Automated_Indicator_Enrichment
title: "Automated Indicator Enrichment"
description: "This workflow triggers from directly slack messaging the chatbot to \"!investigate\" the defined indicator. To date, this workflow supports automatically looking up URLs and IPs in open source threat intelligence such as VirusTotal and Whois. Lastly, the workflow will post back results to the specific user"
version: 1.0.0
vendor: rapid7
support: rapid7
status: []
hub_tags:
use_cases: [alerting_and_notifications, threat_detection_and_response]
keywords: [enrichment, slack, url, ip]
features: []
resources:
source_url: https://github.com/rapid7/insightconnect-workflows/tree/master/workflows/Automated_Indicator_Enrichment
license_url: https://github.com/rapid7/insightconnect-workflows/blob/master/LICENSE
screenshots:
- name: Automated_Indicator_Enrichment_Job.png
title: Example Job Output
- name: Automated_Indicator_Enrichment_Snapshot.png
title: Workflow View
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extension: workflow
products: ["insightconnect"]
name: Automated_Indicator_Enrichment
title: "Automated Indicator Enrichment"
description: " This workflow triggers from directly slack messaging the chatbot to \"!investigate\" the defined indicator. To date, this workflow supports automatically looking up URLs and IPs in open source threat intelligence such as VirusTotal and Whois. Lastly, the workflow will post back results to the specific user."
version: 1.0.0
vendor: rapid7
support: rapid7
status: []
hub_tags:
use_cases: [alerting_and_notifications, threat_detection_and_response]
keywords: [enrichment, slack, url, ip]
features: []
resources:
source_url: https://github.com/rapid7/insightconnect-workflows/tree/master/workflows/Automated_Indicator_Enrichment
license_url: https://github.com/rapid7/insightconnect-workflows/blob/master/LICENSE
screenshots:
- name: Automated_Indicator_Enrichment_Job.png
title: Example Job Output
- name: Automated_Indicator_Enrichment_Snapshot.png
title: Workflow View

0 comments on commit 6e32725

Please sign in to comment.