Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions .changelog/5160.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- description: Updated the content item structure to adopt standardized id and name fields.
type: internal
pr_number: 5160
2 changes: 2 additions & 0 deletions TestSuite/layout_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def __init__(
def create_default_layout_rule(self):
self.write_json(
{
"id": self.rule_id,
"rule_id": self.rule_id,
"name": self.name,
"rule_name": self.name,
"layout_id": "test_layout",
"description": "",
Expand Down
4 changes: 2 additions & 2 deletions TestSuite/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ def __init__(self, name: str, trigger_dir_path: Path, json_content: dict = None)
def create_default_trigger(self):
self.write_json(
{
"trigger_id": self.id,
"id": self.id,
"name": self.id,
"playbook_id": "mock playbook",
"suggestion_reason": "mock reason",
"description": "desc",
"trigger_name": self.id,
"alerts_filter": {
"filter": {
"AND": [
Expand Down
2 changes: 1 addition & 1 deletion TestSuite/xdrc_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def write_dict(self, yml: dict):
def create_default(self):
self.write_json(
{
"content_global_id": self.id,
"id": self.id,
"name": self.id,
"os_type": "os_type_test",
"profile_type": "profile_type_test",
Expand Down
1 change: 1 addition & 0 deletions TestSuite/xsiam_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def create_default(self):
{
"dashboards_data": [
{
"id": self.id,
"name": self.id,
"description": "mock dashboard desc",
"status": "ENABLED",
Expand Down
4 changes: 2 additions & 2 deletions TestSuite/xsiam_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def create_default(self):
{
"templates_data": [
{
"global_id": self.id,
"report_name": self.id,
"id": self.id,
"name": self.id,
"report_description": None,
"default_template_id": None,
"time_frame": {"relativeTime": 86400000},
Expand Down
10 changes: 9 additions & 1 deletion demisto_sdk/commands/common/schemas/layoutrule.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
type: map
mapping:
id:
type: str
required: true
rule_id:
type: str
required: false
# DEPRECATED: Use 'id' field instead. This field is kept for backward compatibility with existing content items.
name:
type: str
required: true
rule_name:
type: str
required: true
required: false
# DEPRECATED: Use 'name' field instead. This field is kept for backward compatibility with existing content items.
layout_id:
type: str
required: true
Expand Down
12 changes: 10 additions & 2 deletions demisto_sdk/commands/common/schemas/trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@ mapping:
type: str
automation_id:
type: str
trigger_id:
id:
type: str
required: true
trigger_id:
type: str
required: false
# DEPRECATED: Use 'id' field instead. This field is kept for backward compatibility with existing content items.
fromVersion:
type: str
toVersion:
type: str
trigger_name:
name:
type: str
required: true
trigger_name:
type: str
required: false
# DEPRECATED: Use 'name' field instead. This field is kept for backward compatibility with existing content items.
playbook_id:
type: str
description:
Expand Down
6 changes: 5 additions & 1 deletion demisto_sdk/commands/common/schemas/xdrctemplate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ mapping:
name:
type: str
required: true
content_global_id:
id:
type: str
required: true
content_global_id:
type: str
required: false
# DEPRECATED: Use 'id' field instead. This field is kept for backward compatibility with existing content items.
from_xdr_version:
type: str
required: true
Expand Down
6 changes: 5 additions & 1 deletion demisto_sdk/commands/common/schemas/xsiamdashboard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ mapping:
schema;dashboards_data_schema:
type: map
mapping:
global_id:
id:
type: str
required: true
global_id:
type: str
required: false
# DEPRECATED: Use 'id' field instead. This field is kept for backward compatibility with existing content items.
status:
type: str
required: true
Expand Down
10 changes: 9 additions & 1 deletion demisto_sdk/commands/common/schemas/xsiamreport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ schema;templates_data_schema:
mapping:
metadata:
type: str
id:
type: str
required: true
global_id:
type: str
required: false
# DEPRECATED: Use 'id' field instead. This field is kept for backward compatibility with existing content items.
name:
type: str
required: true
report_name:
type: str
required: true
required: false
# DEPRECATED: Use 'name' field instead. This field is kept for backward compatibility with existing content items.
report_description:
type: str
required: false
Expand Down
12 changes: 6 additions & 6 deletions demisto_sdk/commands/common/tests/layout_rule_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ def test_is_valid_file(repo):
dummy_layout_rule = pack.create_layout_rule(
"MyRule",
{
"rule_id": "test_rule",
"id": "test_rule",
"layout_id": "test_layout_id",
"description": "This trigger is test",
"rule_name": "test rule name",
"name": "test rule name",
"alerts_filter": {
"filter": {
"AND": [
Expand Down Expand Up @@ -50,10 +50,10 @@ def test_is_valid_file_complicated_schema(repo):
dummy_layout_rule = pack.create_layout_rule(
"MyRule",
{
"rule_id": "test_rule",
"id": "test_rule",
"layout_id": "test_layout_id",
"description": "This trigger is test",
"rule_name": "test rule name",
"name": "test rule name",
"alerts_filter": {
"filter": {
"OR": [
Expand Down Expand Up @@ -109,10 +109,10 @@ def test_is_not_valid_file_complicated_schema(repo):
dummy_layout_rule = pack.create_layout_rule(
"MyRule",
{
"rule_id": "test_rule",
"id": "test_rule",
"layout_id": "test_layout_id",
"description": "This trigger is test",
"rule_name": "test rule name",
"name": "test rule name",
"alerts_filter": {
"filter": {
"OR": [
Expand Down
6 changes: 3 additions & 3 deletions demisto_sdk/commands/common/tests/structure_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -945,17 +945,17 @@ def test_valid_xsiam_report(self, pack: Pack):
validator = StructureValidator(xsiam_report.path)
assert validator.is_valid_scheme()

def test_invalid_xsiam_report_missing_global_id(self, pack: Pack):
def test_invalid_xsiam_report_missing_id(self, pack: Pack):
"""
Given:
An invalid XSIAM report with a missing global_id field
An invalid XSIAM report with a missing id field
When:
Running schema validation.
Then:
Make sure the schema is invalid.
"""
xsiam_report = pack.create_xsiam_report("xsiam_report")
xsiam_report.remove_field_by_path("templates_data.[0].global_id")
xsiam_report.remove_field_by_path("templates_data.[0].id")
validator = StructureValidator(xsiam_report.path)
assert not validator.is_valid_scheme()

Expand Down
12 changes: 6 additions & 6 deletions demisto_sdk/commands/common/tests/trigger_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def test_is_valid_file(repo):
dummy_trigger = pack.create_trigger(
"MyTrigger",
{
"trigger_id": "trigger_id",
"id": "trigger_id",
"playbook_id": "playbook_id",
"suggestion_reason": "Reason",
"description": "Description",
"trigger_name": "trigger_name",
"name": "trigger_name",
"alerts_filter": {
"filter": {
"AND": [
Expand Down Expand Up @@ -48,11 +48,11 @@ def test_is_valid_file_complicated_schema(repo):
dummy_trigger = pack.create_trigger(
"MyTrigger",
{
"trigger_id": "trigger_id",
"id": "trigger_id",
"playbook_id": "playbook_id",
"suggestion_reason": "Reason",
"description": "Description",
"trigger_name": "trigger_name",
"name": "trigger_name",
"alerts_filter": {
"filter": {
"OR": [
Expand Down Expand Up @@ -106,11 +106,11 @@ def test_is_not_valid_file_complicated_schema(repo):
dummy_trigger = pack.create_trigger(
"MyTrigger",
{
"trigger_id": "trigger_id",
"id": "trigger_id",
"playbook_id": "playbook_id",
"suggestion_reason": "Reason",
"description": "Description",
"trigger_name": "trigger_name",
"name": "trigger_name",
"alerts_filter": {
"filter": {
"OR": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@


class _StrictLayoutRule(BaseStrictModel):
rule_id: str
rule_name: str
rule_id: Optional[str] = None
id: str
rule_name: Optional[str] = None
name: str
layout_id: str
from_version: str = Field(
alias="fromVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@


class _StrictTrigger(BaseStrictModel):
trigger_id: str
trigger_name: str
trigger_id: Optional[str] = None
id: str
trigger_name: Optional[str] = None
name: str
playbook_id: Optional[str]
description: str
suggestion_reason: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class _StrictXDRCTemplate(BaseStrictModel):
os_type: str
profile_type: str
name: str
content_global_id: str
content_global_id: Optional[str] = None
id: str
from_xdr_version: str
yaml_template: str
supportedModules: Optional[List[str]] = Field(None, alias="supportedModules")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class _Layout(BaseStrictModel):


class _DashboardsData(BaseStrictModel):
global_id: str
global_id: Optional[str] = None
id: str
status: str
name: str
description: Optional[str] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ class TimeFrame(BaseStrictModel):

class TemplatesData(BaseStrictModel):
metadata: Optional[str] = None
global_id: str
report_name: str
global_id: Optional[str] = None
id: str
report_name: Optional[str] = None
name: str
report_description: Optional[str] = None
default_template_id: Optional[int] = None
time_frame: Optional[TimeFrame] = None
Expand Down
Loading
Loading