-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sf-reintroduce-docker-proxy
- Loading branch information
Showing
13 changed files
with
303 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
changes: | ||
- description: Added validation to ensure every silent trigger points to a silent playbook, and vice versa. | ||
type: feature | ||
pr_number: 4670 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
changes: | ||
- description: Added support for CaseLayouts and CaseFields content items paths to the `validate-content-paths` **pre-commit** hook. | ||
type: feature | ||
pr_number: 4706 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
changes: | ||
- description: Fixed an issue where RM114 falsely failed when it concatenated "Packs/" twice to the file path. | ||
type: fix | ||
pr_number: 4717 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
changes: | ||
- description: Exclude silent items from release notes validation. | ||
type: feature | ||
pr_number: 4720 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
..._sdk/commands/validate/validators/PB_validators/PB131_is_silent_playbook_relationships.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from __future__ import annotations | ||
|
||
from typing import Iterable, List, Union | ||
|
||
from demisto_sdk.commands.content_graph.common import ContentType | ||
from demisto_sdk.commands.content_graph.objects.content_item import ContentItem | ||
from demisto_sdk.commands.content_graph.objects.playbook import Playbook | ||
from demisto_sdk.commands.content_graph.objects.trigger import Trigger | ||
from demisto_sdk.commands.validate.validators.base_validator import ( | ||
BaseValidator, | ||
ValidationResult, | ||
) | ||
|
||
ContentTypes = Union[Playbook, Trigger] | ||
|
||
|
||
class IsSilentPlaybookRelationshipsValidator(BaseValidator[ContentTypes]): | ||
error_code = "PB131" | ||
description = "Every silent trigger must correspond to a silent playbook in the same pack, and vice versa." | ||
rationale = "To ensure the effective operation of the silent playbook items." | ||
error_message = ( | ||
"The {} is silent, but does not correspond to a silent {} in the pack." | ||
) | ||
related_field = "isSilent" | ||
is_auto_fixable = False | ||
|
||
def obtain_invalid_content_items( | ||
self, content_items: Iterable[ContentTypes] | ||
) -> List[ValidationResult]: | ||
def get_types_for_err_msg(c: ContentItem) -> tuple[ContentType, ContentType]: | ||
if isinstance(c, Trigger): | ||
return ContentType.TRIGGER, ContentType.PLAYBOOK | ||
return ContentType.PLAYBOOK, ContentType.TRIGGER | ||
|
||
return [ | ||
ValidationResult( | ||
validator=self, | ||
message=self.error_message.format(*get_types_for_err_msg(content_item)), | ||
content_object=content_item, | ||
) | ||
for content_item in content_items | ||
if not is_valid_relationship(content_item) | ||
] | ||
|
||
|
||
def is_valid_relationship(content_item: ContentTypes) -> bool: | ||
""" | ||
Validates the relationship between a content item and its associated playbook/trigger. | ||
""" | ||
if not content_item.is_silent: | ||
# If the content item is not marked as silent, it's automatically valid | ||
return True | ||
|
||
if content_item.content_type == ContentType.PLAYBOOK: | ||
return any( | ||
trigger.data.get("playbook_id") == content_item.data.get("id") | ||
and trigger.is_silent | ||
for trigger in content_item.pack.content_items.trigger | ||
) | ||
|
||
if content_item.content_type == ContentType.TRIGGER: | ||
return any( | ||
playbook.data.get("id") == content_item.data.get("playbook_id") | ||
and playbook.is_silent | ||
for playbook in content_item.pack.content_items.playbook | ||
) | ||
|
||
# Default case if content type is not PLAYBOOK or TRIGGER | ||
return True |
Oops, something went wrong.