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

allowed paths #2479

Closed
wants to merge 63 commits into from
Closed
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
035c954
black
dorschw Jan 24, 2023
12dff34
ignorable
dorschw Jan 24, 2023
5bb9733
fix type
dorschw Jan 24, 2023
4d497f0
add more checks
dorschw Feb 1, 2023
4ccb26f
merge
dorschw Feb 1, 2023
ce9e919
precommit
dorschw Feb 1, 2023
eaf52dc
precommit
dorschw Feb 1, 2023
ae9dbbd
Merge branch 'master' of https://github.com/demisto/demisto-sdk into …
dorschw Feb 26, 2023
a8c106d
move log
dorschw Feb 26, 2023
1143397
fix ut
dorschw Feb 26, 2023
286802e
remove todo
dorschw Feb 27, 2023
0d17e27
Merge branch 'master' of https://github.com/demisto/demisto-sdk into …
dorschw Feb 27, 2023
c71e831
fix ut
dorschw Feb 27, 2023
b886971
fix ut
dorschw Feb 27, 2023
9ee19ee
Merge branch 'master' of https://github.com/demisto/demisto-sdk into …
dorschw Mar 6, 2023
dd094cc
fix logic
dorschw Mar 6, 2023
eadc994
changelog
dorschw Mar 6, 2023
7e8e708
fix, add ut
dorschw Mar 6, 2023
4a37185
fix logic
dorschw Mar 6, 2023
805b10c
fix uts
dorschw Mar 6, 2023
a65423d
fix more uts
dorschw Mar 6, 2023
a11732d
one more fix
dorschw Mar 6, 2023
1879e82
one more fix
dorschw Mar 7, 2023
20fcc48
more UTs
dorschw Mar 7, 2023
5b3b7e6
one more fix
dorschw Mar 7, 2023
2dc4f36
fix UTs
dorschw Mar 9, 2023
4d706dc
Merge branch 'master' of github.com:demisto/demisto-sdk into ds-allow…
dorschw Mar 9, 2023
2a3e4d1
pre-commit
dorschw Mar 9, 2023
9bbeafe
fix ut
dorschw Mar 15, 2023
a72d308
Merge branch 'master' of github.com:demisto/demisto-sdk into ds-allow…
dorschw Mar 15, 2023
42ba28f
CR comments
dorschw Mar 16, 2023
47481fe
Merge branches 'ds-allowed-paths' and 'master' of github.com:demisto/…
dorschw Mar 16, 2023
c0dd8fe
add space
dorschw Mar 20, 2023
bf25772
remove unused value
dorschw Mar 20, 2023
5ed8914
Merge branch 'master' of github.com:demisto/demisto-sdk into ds-allow…
dorschw Mar 22, 2023
831f5e0
allow files under layout rules
dorschw Mar 22, 2023
3f3359b
Merge branch 'master' of github.com:demisto/demisto-sdk into ds-allow…
dorschw Mar 22, 2023
e279c60
fix ut
dorschw Mar 23, 2023
b6f3585
Merge branch 'master' of github.com:demisto/demisto-sdk into ds-allow…
dorschw Jun 15, 2023
37ebd16
undelete BA124
dorschw Jun 15, 2023
fbd498a
Merge branch 'master' of github.com:demisto/demisto-sdk into ds-allow…
dorschw Jul 19, 2023
8e45c5c
improve logging, ignore deprecatedcontent pack
dorschw Jul 19, 2023
ac868d5
comments
dorschw Jul 19, 2023
3700313
tiny refactor
dorschw Jul 19, 2023
9f1efa1
Update demisto_sdk/commands/validate/tests/validators_test.py
dorschw Jul 19, 2023
c6009f6
Merge branch 'master' of github.com:demisto/demisto-sdk into ds-allow…
dorschw Aug 22, 2023
236083c
Merge branch 'master' into ds-allowed-paths
dorschw Aug 22, 2023
972bd5c
split check
dorschw Aug 23, 2023
bfacc93
Merge branch 'master' of github.com:demisto/demisto-sdk into ds-allow…
dorschw Sep 5, 2023
7611181
Merge branch 'master' of github.com:demisto/demisto-sdk into ds-allow…
dorschw Sep 12, 2023
fddb6a4
fixed order
dorschw Sep 12, 2023
dd0a301
fix some uts, use Dan's suggestion
dorschw Sep 12, 2023
840da76
Merge branch 'master' into ds-allowed-paths
dorschw Sep 12, 2023
1f2715a
Merge branch 'master' of github.com:demisto/demisto-sdk into ds-allow…
dorschw Sep 19, 2023
9a59a2f
fix UT
dorschw Sep 22, 2023
70003e8
Merge branch 'master' of github.com:demisto/demisto-sdk into ds-allow…
dorschw Sep 26, 2023
7ba183a
cl
dorschw Sep 26, 2023
122814c
fix duplicate variable
dorschw Sep 26, 2023
f86863a
fix duplicate variable, again
dorschw Sep 26, 2023
23ca7d7
undo unintended changes
dorschw Sep 26, 2023
087725c
pre-commit-config
dorschw Sep 26, 2023
b303e43
Merge branch 'master' of github.com:demisto/demisto-sdk into ds-allow…
dorschw Oct 17, 2023
acc9e6c
exempt unified files
dorschw Oct 17, 2023
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
302 changes: 153 additions & 149 deletions .pre-commit-config.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog
## Unreleased
* Added a **validate** step checking for misplaced files (i.e. directly under `Integrations`, or under mistyped folder name)
* Fixed an issue where **validate** falsely failed with error `DS108` on descriptions ending with brackets that contains a dot at the end of them.
* Fixed an issue where **modeling-rule test** command failed to properly render the comparison table when boolean value were printed.
* Fixed an issue were format added a dot at end of the description that already ends with question mark and exclamation mark.
Expand Down
52 changes: 38 additions & 14 deletions TestSuite/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@
from demisto_sdk.commands.common.constants import (
CORRELATION_RULES_DIR,
DEFAULT_IMAGE_BASE64,
INDICATOR_TYPE_PREFIX,
LAYOUT_CONTAINER_PREFIX,
LAYOUT_PREFIX,
LAYOUT_RULES_DIR,
MODELING_RULES_DIR,
PARSING_RULES_DIR,
REPORT_PREFIX,
TRIGGER_DIR,
WIDGET_PREFIX,
XDRC_TEMPLATE_DIR,
XSIAM_DASHBOARDS_DIR,
XSIAM_REPORTS_DIR,
Expand Down Expand Up @@ -87,6 +92,7 @@ def __init__(self, packs_dir: Path, name: str, repo):
self.wizards: List[Wizard] = list()
self.xdrc_templates: List[XDRCTemplate] = list()
self.layout_rules: List[LayoutRule] = list()
self.connections: List[JSONBased] = list()

# Create base pack
self._pack_path = packs_dir / self.name
Expand Down Expand Up @@ -156,6 +162,9 @@ def __init__(self, packs_dir: Path, name: str, repo):
self._lists_path = self._pack_path / "Lists"
self._lists_path.mkdir()

self._connections_path = self._pack_path / "Connections"
self._connections_path.mkdir()

self._parsing_rules_path = self._pack_path / PARSING_RULES_DIR
self._parsing_rules_path.mkdir()

Expand Down Expand Up @@ -380,8 +389,9 @@ def create_indicator_field(self, name, content: dict = None) -> JSONBased:
self.indicator_fields.append(indicator_field)
return indicator_field

def create_indicator_type(self, name, content: dict = None) -> JSONBased:
prefix = "reputation"
def create_indicator_type(
self, name, content: dict = None, prefix=INDICATOR_TYPE_PREFIX
) -> JSONBased:
indicator_type = self._create_json_based(
name, prefix, content, dir_path=self._indicator_types
)
Expand Down Expand Up @@ -442,34 +452,42 @@ def create_job(
self.jobs.append(job)
return job

def create_layout(self, name, content: dict = None) -> JSONBased:
prefix = "layout"
def create_layout(
self,
name,
content: dict = None,
prefix: str = LAYOUT_PREFIX,
) -> JSONBased:
layout = self._create_json_based(
name, prefix, content, dir_path=self._layout_path
)
self.layouts.append(layout)
return layout

def create_layoutcontainer(self, name, content: Optional[dict] = None) -> JSONBased:
if not content:
content = {"group": "default"}
prefix = "layoutscontainer"
def create_layoutcontainer(
self, name, content: dict = None, prefix: str = LAYOUT_CONTAINER_PREFIX
) -> JSONBased:
layoutcontainer = self._create_json_based(
name, prefix, content, dir_path=self._layout_path
)
self.layoutcontainers.append(layoutcontainer)
return layoutcontainer

def create_report(self, name, content: dict = None) -> JSONBased:
prefix = "report"
def create_report(
self, name, content: dict = None, prefix=REPORT_PREFIX
) -> JSONBased:
report = self._create_json_based(
name, prefix, content, dir_path=self._report_path
)
self.reports.append(report)
return report

def create_widget(self, name, content: dict = None) -> JSONBased:
prefix = "widget"
def create_widget(
self,
name,
content: dict = None,
prefix: str = WIDGET_PREFIX,
) -> JSONBased:
widget = self._create_json_based(
name, prefix, content, dir_path=self._widget_path
)
Expand Down Expand Up @@ -505,14 +523,20 @@ def create_wizard(
self.wizards.append(wizard)
return wizard

def create_list(self, name, content: dict = None) -> JSONBased:
prefix = "list"
def create_list(self, name, content: dict = None, prefix="list") -> JSONBased:
list_item = self._create_json_based(
name, prefix, content, dir_path=self._lists_path
)
self.lists.append(list_item)
return list_item

def create_connection(self, name: str, content: dict = None) -> JSONBased:
connection = self._create_json_based(
name, "", content, dir_path=self._connections_path
)
self.connections.append(connection)
return connection

def create_playbook(
self,
name: Optional[str] = None,
Expand Down
67 changes: 66 additions & 1 deletion demisto_sdk/commands/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
CLASSIFIERS_DIR = "Classifiers"
MAPPERS_DIR = "Classifiers"
CONNECTIONS_DIR = "Connections"
RELEASE_NOTES_DIR = "ReleaseNotes"

PACKS_DIR = "Packs"
TOOLS_DIR = "Tools"
RELEASE_NOTES_DIR = "ReleaseNotes"
TESTS_DIR = "Tests"
DOC_FILES_DIR = "doc_files"
DOCUMENTATION_DIR = "Documentation"
Expand All @@ -50,6 +51,38 @@
XDRC_TEMPLATE_DIR = "XDRCTemplates"
LAYOUT_RULES_DIR = "LayoutRules"

FIRST_LEVEL_FOLDERS_ALLOWED_TO_CONTAIN_FILES = {
PLAYBOOKS_DIR,
TEST_PLAYBOOKS_DIR,
REPORTS_DIR,
DASHBOARDS_DIR,
INCIDENT_FIELDS_DIR,
INCIDENT_TYPES_DIR,
INDICATOR_FIELDS_DIR,
INDICATOR_TYPES_DIR,
GENERIC_TYPES_DIR,
GENERIC_MODULES_DIR,
GENERIC_DEFINITIONS_DIR,
LAYOUTS_DIR,
CLASSIFIERS_DIR,
MAPPERS_DIR,
CONNECTIONS_DIR,
RELEASE_NOTES_DIR,
DOC_FILES_DIR,
JOBS_DIR,
PRE_PROCESS_RULES_DIR,
LISTS_DIR,
PARSING_RULES_DIR,
MODELING_RULES_DIR,
CORRELATION_RULES_DIR,
XSIAM_DASHBOARDS_DIR,
XSIAM_REPORTS_DIR,
TRIGGER_DIR,
WIDGETS_DIR,
WIZARDS_DIR,
LAYOUT_RULES_DIR,
}

dorschw marked this conversation as resolved.
Show resolved Hide resolved
# NAMES OF ENTITIES

SCRIPT = "script"
Expand Down Expand Up @@ -807,6 +840,11 @@ class FileType(str, Enum):
MODELING_RULE_NAME_SUFFIX = "Modeling Rule"
XDRC_TEMPLATE_PREFIX = "xdrctemplate"
LAYOUT_RULE_PREFIX = "layoutrule"
LAYOUT_CONTAINER_PREFIX = "layoutscontainer"
INDICATOR_TYPE_PREFIX = "reputation"
REPORT_PREFIX = "report"
LAYOUT_PREFIX = "layout"
WIDGET_PREFIX = "widget"

# Pack Unique Files
PACKS_WHITELIST_FILE_NAME = ".secrets-ignore"
Expand All @@ -819,6 +857,9 @@ class FileType(str, Enum):
PACKS_FOLDER = "Packs"

CONF_JSON_FILE_NAME = "conf.json"
GIT_IGNORE_FILE_NAME = ".gitignore"
PIPFILE_FILE_NAME = "Pipfile"
PIPFILE_LOCK_FILE_NAME = "Pipfile.lock"

PYTHON_TEST_REGEXES = [PACKS_SCRIPT_TEST_PY_REGEX, PACKS_INTEGRATION_TEST_PY_REGEX]

Expand Down Expand Up @@ -1867,6 +1908,30 @@ class ParameterType(Enum):

NATIVE_IMAGE_DOCKER_NAME = "demisto/py3-native"

PACK_ROOT_FILE_NAMES = {
dorschw marked this conversation as resolved.
Show resolved Hide resolved
GIT_IGNORE_FILE_NAME,
PACKS_PACK_IGNORE_FILE_NAME,
PACKS_WHITELIST_FILE_NAME,
AUTHOR_IMAGE_FILE_NAME,
PACKS_CONTRIBUTORS_FILE_NAME,
PIPFILE_FILE_NAME,
PIPFILE_LOCK_FILE_NAME,
PACKS_README_FILE_NAME,
PACKS_PACK_META_FILE_NAME,
}

PACK_ROOT_FILE_NAMES = {
GIT_IGNORE_FILE_NAME,
PACKS_PACK_IGNORE_FILE_NAME,
PACKS_WHITELIST_FILE_NAME,
AUTHOR_IMAGE_FILE_NAME,
PACKS_CONTRIBUTORS_FILE_NAME,
PIPFILE_FILE_NAME,
PIPFILE_LOCK_FILE_NAME,
PACKS_README_FILE_NAME,
PACKS_PACK_META_FILE_NAME,
}

FORMATTING_SCRIPT = "indicator-format"

ENV_SDK_WORKING_OFFLINE = "DEMISTO_SDK_OFFLINE_ENV"
Expand Down
Loading