Skip to content

Commit

Permalink
Remove IN124 from Old validate (#4317)
Browse files Browse the repository at this point in the history
* Remove IN124 from Old validate

* fixes

* fixes

* fix pre-commit

* cr fixes
  • Loading branch information
YuvHayun committed Jun 2, 2024
1 parent d2ce3b5 commit 3263d17
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 49 deletions.
4 changes: 4 additions & 0 deletions .changelog/4317.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changes:
- description: Removed support for IN124 - 'is param valid is hidden' validation from old-validate flow and prevent the validation from being ignored. The validation and the related information can be found in the new-validate flow.
type: breaking
pr_number: 4317
4 changes: 0 additions & 4 deletions demisto_sdk/commands/common/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,6 @@
"code": "IN123",
"related_field": "display",
},
"param_not_allowed_to_hide": {
"code": "IN124",
"related_field": "<parameter-name>.hidden",
},
"no_default_value_in_parameter": {
"code": "IN125",
"related_field": "<parameter-name>.default",
Expand Down
25 changes: 2 additions & 23 deletions demisto_sdk/commands/common/hook_validations/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from demisto_sdk.commands.common import tools
from demisto_sdk.commands.common.constants import (
ALERT_FETCH_REQUIRED_PARAMS,
ALLOWED_HIDDEN_PARAMS,
BANG_COMMAND_ARGS_MAPPING_DICT,
BANG_COMMAND_NAMES,
DBOT_SCORES_DICT,
Expand Down Expand Up @@ -68,7 +67,6 @@
is_iron_bank_pack,
is_str_bool,
server_version_compare,
string_to_bool,
strip_description,
)
from demisto_sdk.commands.validate.tools import (
Expand Down Expand Up @@ -1534,7 +1532,7 @@ def _is_replaced_by_type9(self, display_name: str) -> bool:
return True
return False

@error_codes("IN124,IN156")
@error_codes("IN156")
def is_valid_hidden_params(self) -> bool:
"""
Verify there are no non-allowed hidden integration parameters.
Expand All @@ -1550,8 +1548,6 @@ def is_valid_hidden_params(self) -> bool:

for param in self.current_file.get("configuration", ()):
name = param.get("name", "")
display_name = param.get("display", "")
type_ = param.get("type")
hidden = param.get("hidden")

invalid_type = not isinstance(hidden, (type(None), bool, list, str))
Expand All @@ -1562,24 +1558,7 @@ def is_valid_hidden_params(self) -> bool:
if self.handle_error(message, code, self.file_path):
valid = False

is_true = (hidden is True) or (
is_str_bool(hidden) and string_to_bool(hidden)
)
invalid_bool = is_true and name not in ALLOWED_HIDDEN_PARAMS
hidden_in_all_marketplaces = isinstance(hidden, list) and set(
hidden
) == set(MarketplaceVersions)

if invalid_bool or hidden_in_all_marketplaces:
if type_ in (0, 4, 12, 14) and self._is_replaced_by_type9(display_name):
continue
error_message, error_code = Errors.param_not_allowed_to_hide(name)
if self.handle_error(
error_message, error_code, file_path=self.file_path
):
valid = False

elif isinstance(hidden, list) and (
if isinstance(hidden, list) and (
invalid := set(hidden).difference(MarketplaceVersions)
):
# if the value is a list, all its values must be marketplace names
Expand Down
18 changes: 4 additions & 14 deletions demisto_sdk/commands/common/tests/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1912,16 +1912,6 @@ def test_verify_reputation_commands_has_reliability(
(["true"], False),
(["True"], False),
(MarketplaceVersions.XSOAR, False),
(
[
MarketplaceVersions.XSOAR,
MarketplaceVersions.MarketplaceV2,
MarketplaceVersions.XPANSE,
MarketplaceVersions.XSOAR_SAAS,
MarketplaceVersions.XSOAR_ON_PREM,
],
False,
),
("🥲", False),
("Trüe", False),
([MarketplaceVersions.XSOAR, None], False),
Expand Down Expand Up @@ -2388,16 +2378,16 @@ def test_value_for_marketplace_feed(self):
IS_VALID_HIDDEN_PARAMS = [
(NO_HIDDEN, True),
(HIDDEN_FALSE, True),
(HIDDEN_TRUE, False),
(HIDDEN_TRUE_AND_FALSE, False),
(HIDDEN_TRUE, True),
(HIDDEN_TRUE_AND_FALSE, True),
(HIDDEN_ALLOWED_TRUE, True),
(HIDDEN_ALLOWED_FEED_REPUTATION, True),
(HIDDEN_TRUE_BUT_REPLACED_TYPE_0, True),
(HIDDEN_TRUE_BUT_REPLACED_TYPE_12, True),
(HIDDEN_TRUE_BUT_REPLACED_TYPE_14, True),
(HIDDEN_TRUE_BUT_REPLACED_BY_NOT_ALLOWED, False),
(HIDDEN_TRUE_BUT_REPLACED_BY_NOT_ALLOWED, True),
(HIDDEN_TRUE_BUT_REPLACED_4, True),
(HIDDEN_ONE_REPLACED_TO_9_OTHER_NOT, False),
(HIDDEN_ONE_REPLACED_TO_9_OTHER_NOT, True),
]

@pytest.mark.parametrize("current, answer", IS_VALID_HIDDEN_PARAMS)
Expand Down
2 changes: 1 addition & 1 deletion demisto_sdk/commands/validate/default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ warning = []

[xsoar_best_practices_path_based_validations]
select = [
"IN100", "IN102", "IN104", "IN106", "IN107", "IN108", "IN109", "IN110", "IN112", "IN113", "IN114", "IN121", "IN122", "IN123", "IN124", "IN125", "IN126", "IN127", "IN130",
"IN100", "IN102", "IN104", "IN106", "IN107", "IN108", "IN109", "IN110", "IN112", "IN113", "IN114", "IN121", "IN122", "IN123", "IN125", "IN126", "IN127", "IN130",
"IN131", "IN134", "IN135", "IN139", "IN141", "IN142", "IN144", "IN145", "IN146", "IN149", "IN150", "IN151", "IN152", "IN153", "IN154", "IN156", "IN158", "IN159", "IN160",
"IN161", "IN162",
"BA100", "BA101", "BA105", "BA106", "BA110", "BA111", "BA116", "BA118", "BA126",
Expand Down
4 changes: 2 additions & 2 deletions demisto_sdk/commands/validate/sdk_validation_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ignorable_errors = [
"GF102",
"DS107", "DS108",
"IF100", "IF106", "IF113", "IF115", "IF116",
"IN107", "IN109", "IN110", "IN122", "IN123", "IN124", "IN126", "IN128", "IN135", "IN136", "IN139", "IN144", "IN145", "IN150", "IN153", "IN154", "IN161",
"IN107", "IN109", "IN110", "IN122", "IN123", "IN126", "IN128", "IN135", "IN136", "IN139", "IN144", "IN145", "IN150", "IN153", "IN154", "IN161",
"MP106",
"PA113", "PA116", "PA124", "PA125", "PA127", "PA129",
"PB104", "PB105", "PB106", "PB107", "PB110", "PB111", "PB114", "PB115", "PB116", "PB118", "PB119", "PB121",
Expand Down Expand Up @@ -48,7 +48,7 @@ warning = []

[path_based_validations]
select = [
"IN100", "IN102", "IN104", "IN106", "IN107", "IN108", "IN109", "IN110", "IN112", "IN113", "IN114", "IN121", "IN122", "IN123", "IN124", "IN125", "IN126", "IN127", "IN130",
"IN100", "IN102", "IN104", "IN106", "IN107", "IN108", "IN109", "IN110", "IN112", "IN113", "IN114", "IN121", "IN122", "IN123", "IN125", "IN126", "IN127", "IN130",
"IN131", "IN134", "IN135", "IN139", "IN141", "IN142", "IN144", "IN145", "IN146", "IN149", "IN150", "IN151", "IN152", "IN153", "IN154", "IN156", "IN158", "IN159", "IN160",
"IN161", "IN162",
"LO107",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,6 @@ def test_negative__hidden_param(self, mocker):
- Ensure failure message on hidden params.
"""
logger_info = mocker.patch.object(logging.getLogger("demisto-sdk"), "info")
logger_error = mocker.patch.object(logging.getLogger("demisto-sdk"), "error")
mocker.patch.object(
IntegrationValidator,
"has_no_fromlicense_key_in_contributions_integration",
Expand Down Expand Up @@ -1648,10 +1647,6 @@ def test_negative__hidden_param(self, mocker):
assert str_in_call_args_list(
logger_info.call_args_list, f"Validating {integration_path} as integration"
)
assert str_in_call_args_list(
logger_error.call_args_list,
'[IN124] - Parameter: "credentials" can\'t be hidden in all marketplaces',
)

def test_positive_hidden_param(self, mocker):
"""
Expand Down

0 comments on commit 3263d17

Please sign in to comment.