Skip to content

Commit

Permalink
ContentItemXSIAM default fromversion is now 8.0.0 (#4243)
Browse files Browse the repository at this point in the history
* ContentItemXSIAM default fromversion is now 8.0.0

* Use constants

* Revert from_version query change.
Add changelog.

* fix unit tests

* Update .changelog/4243.yml

* Explicit add of fromversion to all content items

* set fromversion according to marketplace version in parsers

* comment out explicit add of fromversion

* Remove explicit fromversion addition

---------

Co-authored-by: ilaner <88267954+ilaner@users.noreply.github.com>
  • Loading branch information
thefrieddan1 and ilaner committed May 15, 2024
1 parent 373d616 commit d3ec197
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .changelog/4243.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- description: Change the default `fromversion` of XSIAM content items to 8.0.0
type: fix
pr_number: 4243
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ def validate_unknown_content(
def validate_fromversion(
tx: Transaction, file_paths: List[str], for_supported_versions: bool
):
excluded_from_version = [ContentType.TRIGGER]
op = ">=" if for_supported_versions else "<"
query = f"""// Returning all the USES relationships with where the target's fromversion is higher than the source's
MATCH (content_item_from:{ContentType.BASE_CONTENT}&!{"&!".join(excluded_from_version)} {{deprecated: false, is_test: false}})-[r:{RelationshipType.USES}{{mandatorily:true}}]->(n)
MATCH (content_item_from{{deprecated: false, is_test: false}})-[r:{RelationshipType.USES}{{mandatorily:true}}]->(n)
WHERE {versioned('content_item_from.fromversion')} < {versioned('n.fromversion')}
AND {versioned('n.fromversion')} {op} {versioned(GENERAL_DEFAULT_FROMVERSION)}
AND n.fromversion <> "{DEFAULT_CONTENT_ITEM_FROM_VERSION}" // skips types with no "fromversion"
Expand Down
14 changes: 12 additions & 2 deletions demisto_sdk/commands/content_graph/objects/content_item_xsiam.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

import demisto_client
from packaging.version import Version
from pydantic import DirectoryPath
from pydantic import DirectoryPath, validator

from demisto_sdk.commands.common.constants import MarketplaceVersions
from demisto_sdk.commands.common.constants import (
DEFAULT_CONTENT_ITEM_FROM_VERSION,
MINIMUM_XSOAR_SAAS_VERSION,
MarketplaceVersions,
)
from demisto_sdk.commands.common.tools import (
write_dict,
)
Expand All @@ -20,6 +24,12 @@


class ContentItemXSIAM(ContentItem, ABC):
@validator("fromversion", always=True)
def validate_from_version(cls, v: str) -> str:
if not v or DEFAULT_CONTENT_ITEM_FROM_VERSION == v:
return MINIMUM_XSOAR_SAAS_VERSION
return v

def dump(
self,
dir: DirectoryPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from demisto_sdk.commands.common.constants import (
DEFAULT_CONTENT_ITEM_FROM_VERSION,
DEFAULT_CONTENT_ITEM_TO_VERSION,
MINIMUM_XSOAR_SAAS_VERSION,
MarketplaceVersions,
)
from demisto_sdk.commands.common.tools import get_json, get_value
Expand Down Expand Up @@ -75,7 +76,9 @@ def fromversion(self) -> str:
return get_value(
self.json_data,
self.field_mapping.get("fromversion", ""),
DEFAULT_CONTENT_ITEM_FROM_VERSION,
DEFAULT_CONTENT_ITEM_FROM_VERSION
if MarketplaceVersions.XSOAR_ON_PREM in self.supported_marketplaces
else MINIMUM_XSOAR_SAAS_VERSION,
)

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from demisto_sdk.commands.common.constants import (
DEFAULT_CONTENT_ITEM_FROM_VERSION,
DEFAULT_CONTENT_ITEM_TO_VERSION,
MINIMUM_XSOAR_SAAS_VERSION,
MarketplaceVersions,
)
from demisto_sdk.commands.common.tools import get_value, get_yaml
Expand Down Expand Up @@ -88,7 +89,9 @@ def fromversion(self) -> str:
return get_value(
self.yml_data,
self.field_mapping.get("fromversion", ""),
DEFAULT_CONTENT_ITEM_FROM_VERSION,
DEFAULT_CONTENT_ITEM_FROM_VERSION
if MarketplaceVersions.XSOAR_ON_PREM in self.supported_marketplaces
else MINIMUM_XSOAR_SAAS_VERSION,
)

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from demisto_sdk.commands.common import tools
from demisto_sdk.commands.common.constants import (
DEFAULT_CONTENT_ITEM_FROM_VERSION,
DEFAULT_CONTENT_ITEM_TO_VERSION,
MINIMUM_XSOAR_SAAS_VERSION,
MarketplaceVersions,
)
from demisto_sdk.commands.common.legacy_git_tools import git_path
Expand Down Expand Up @@ -379,7 +379,7 @@ def test_correlation_rule_parser(self, pack: Pack):
expected_name="correlation_rule_name",
expected_path=colrrelation_rule_path,
expected_content_type=ContentType.CORRELATION_RULE,
expected_fromversion=DEFAULT_CONTENT_ITEM_FROM_VERSION,
expected_fromversion=MINIMUM_XSOAR_SAAS_VERSION,
expected_toversion=DEFAULT_CONTENT_ITEM_TO_VERSION,
)

Expand Down
2 changes: 0 additions & 2 deletions demisto_sdk/commands/upload/tests/uploader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,8 @@ def test_upload_without_skip_validate(self, mocker, path: Path, version: str):
"metadata.json",
"pack_metadata.json",
"XSIAMDashboards/",
"XSIAMDashboards/xsiamdashboard-MyDashboard.json",
"XSIAMDashboards/external-xsiamdashboard-MyDashboard.json",
"Triggers/",
"Triggers/trigger-MyTrigger.json",
"Triggers/external-trigger-MyTrigger.json",
},
),
Expand Down

0 comments on commit d3ec197

Please sign in to comment.