splunk-soar-sdk 2.3.0__py3-none-any.whl → 2.3.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
soar_sdk/abstract.py CHANGED
@@ -234,6 +234,6 @@ class SOARClient(Generic[SummaryType]):
234
234
  pass
235
235
 
236
236
  @abstractmethod
237
- def get_message(self) -> Optional[str]:
237
+ def get_message(self) -> str:
238
238
  """Get the summary message for the action run."""
239
239
  pass
soar_sdk/app.py CHANGED
@@ -101,7 +101,7 @@ class App:
101
101
  product_name: str,
102
102
  publisher: str,
103
103
  appid: str,
104
- python_version: Optional[list[PythonVersion]] = None,
104
+ python_version: Optional[Union[list[PythonVersion], str]] = None,
105
105
  min_phantom_version: str = MIN_PHANTOM_VERSION,
106
106
  fips_compliant: bool = False,
107
107
  asset_cls: type[BaseAsset] = BaseAsset,
@@ -113,7 +113,7 @@ class App:
113
113
  raise ValueError(f"Appid is not a valid uuid: {appid}")
114
114
 
115
115
  if python_version is None:
116
- python_version = PythonVersion.all()
116
+ python_version = PythonVersion.all_csv()
117
117
 
118
118
  self.app_meta_info = {
119
119
  "name": name,
@@ -636,7 +636,7 @@ class App:
636
636
  ],
637
637
  actions_manager: ActionsManager,
638
638
  action_params: Optional[Params] = None,
639
- message: Optional[str] = None,
639
+ message: str = "",
640
640
  summary: Optional[ActionOutput] = None,
641
641
  ) -> bool:
642
642
  """Handles multiple ways of returning response from action.
@@ -657,9 +657,7 @@ class App:
657
657
  )
658
658
  # Handle empty list/iterator case
659
659
  if not statuses:
660
- result = ActionOutput(
661
- status=True, message=message or "Action completed successfully"
662
- )
660
+ result = ActionOutput(status=True, message=message)
663
661
  else:
664
662
  return all(statuses)
665
663
 
@@ -667,9 +665,6 @@ class App:
667
665
  output_dict = result.dict(by_alias=True)
668
666
  param_dict = action_params.dict() if action_params else None
669
667
 
670
- if not message:
671
- message = "Action completed successfully"
672
-
673
668
  result = ActionResult(
674
669
  status=True,
675
670
  message=message,
soar_sdk/app_client.py CHANGED
@@ -44,7 +44,7 @@ class AppClient(SOARClient[SummaryType]):
44
44
  self.basic_auth: Optional[BasicAuth] = None
45
45
 
46
46
  self._summary: Optional[SummaryType] = None
47
- self._message: Optional[str] = None
47
+ self._message: str = ""
48
48
  self.__container_id: int = 0
49
49
  self.__asset_id: str = ""
50
50
 
@@ -171,6 +171,6 @@ class AppClient(SOARClient[SummaryType]):
171
171
  """Get the summary for the action result."""
172
172
  return self._summary
173
173
 
174
- def get_message(self) -> Optional[str]:
174
+ def get_message(self) -> str:
175
175
  """Get the message for the action result."""
176
176
  return self._message
soar_sdk/cli/init/cli.py CHANGED
@@ -269,11 +269,11 @@ def convert_connector_to_sdk(
269
269
  # Convert the main module path to the SDK format, but save a reference to the original
270
270
  app_meta.main_module = "src.app:app"
271
271
 
272
- app_python_versions = app_meta.python_version
272
+ app_python_versions = PythonVersion.from_csv(app_meta.python_version)
273
273
  enforced_python_versions = PythonVersion.all()
274
274
  if set(app_python_versions) != set(enforced_python_versions):
275
275
  rprint(
276
- f"[yellow]The provided app declares support for Python versions {[str(v) for v in app_python_versions]}.[/]"
276
+ f"[yellow]The provided app declares support for Python versions '{app_meta.python_version}'.[/]"
277
277
  )
278
278
  rprint(
279
279
  f"[yellow]The converted app will support the default versions {[str(v) for v in enforced_python_versions]}.[/]"
@@ -6,7 +6,7 @@ import pydantic
6
6
 
7
7
  from soar_sdk.action_results import ActionOutput, OutputFieldSpecification, OutputField
8
8
  from soar_sdk.cli.utils import normalize_field_name, NormalizationResult
9
- from soar_sdk.compat import PythonVersion, remove_when_soar_newer_than
9
+ from soar_sdk.compat import remove_when_soar_newer_than
10
10
  from soar_sdk.meta.actions import ActionMeta
11
11
  from soar_sdk.meta.app import AppMeta
12
12
  from soar_sdk.params import Params, Param
@@ -41,15 +41,6 @@ class AppMetaDeserializer:
41
41
  """
42
42
  manifest: dict[str, Any] = json.loads(json_path.read_text())
43
43
 
44
- # Massage the python_version field, which may be a comma-separated string
45
- python_version = manifest.pop("python_version", None)
46
- if isinstance(python_version, str):
47
- manifest["python_version"] = PythonVersion.from_csv(python_version)
48
- elif isinstance(python_version, list):
49
- manifest["python_version"] = [
50
- PythonVersion.from_str(py) for py in python_version
51
- ]
52
-
53
44
  deserialized_actions = [
54
45
  ActionDeserializer.from_action_json(action)
55
46
  for action in manifest.get("actions", [])
soar_sdk/compat.py CHANGED
@@ -59,11 +59,21 @@ class PythonVersion(str, Enum):
59
59
  cls.from_str(version.strip()) for version in versions if version.strip()
60
60
  ]
61
61
 
62
+ @classmethod
63
+ def to_csv(cls, versions: list["PythonVersion"]) -> str:
64
+ """Converts a list of PythonVersion enums to a comma-separated string."""
65
+ return ",".join(str(v) for v in versions)
66
+
62
67
  @classmethod
63
68
  def all(cls) -> list["PythonVersion"]:
64
69
  """Returns a list of all supported Python versions."""
65
70
  return [cls.PY_3_9, cls.PY_3_13]
66
71
 
72
+ @classmethod
73
+ def all_csv(cls) -> str:
74
+ """Returns a comma-separated string of all supported Python versions."""
75
+ return ",".join(str(v) for v in cls.all())
76
+
67
77
  @classmethod
68
78
  def to_requires_python(cls, versions: list["PythonVersion"]) -> str:
69
79
  """Converts a list of PythonVersions to a PEP-508 compatible requires-python string."""
@@ -43,19 +43,31 @@ class MakeRequestDecorator:
43
43
  "The 'make_request' decorator can only be used once per App instance."
44
44
  )
45
45
 
46
- # Validate function signature - must have at least one parameter of type MakeRequestParams
46
+ # Validate function signature - must have exactly one parameter of type MakeRequestParams
47
47
  signature = inspect.signature(function)
48
48
  params = list(signature.parameters.values())
49
49
 
50
- if not any(param.annotation == MakeRequestParams for param in params):
50
+ make_request_params = [
51
+ param
52
+ for param in params
53
+ if inspect.isclass(param.annotation)
54
+ and issubclass(param.annotation, MakeRequestParams)
55
+ ]
56
+
57
+ if len(make_request_params) == 0:
58
+ raise TypeError(
59
+ "Make request action function must have exactly one parameter of type MakeRequestParams or its subclass."
60
+ )
61
+ elif len(make_request_params) > 1:
62
+ param_names = [p.name for p in make_request_params]
51
63
  raise TypeError(
52
- f"Make request action function must have at least one parameter of type MakeRequestParams, got {params[0].annotation}"
64
+ f"Make request action function can only have one MakeRequestParams parameter, "
65
+ f"but found {len(make_request_params)}: {param_names}"
53
66
  )
54
67
 
55
68
  action_identifier = "make_request"
56
69
  action_name = "make request"
57
- # for make request action use MakeRequestParams
58
- validated_params_class = MakeRequestParams
70
+ validated_params_class = make_request_params[0].annotation
59
71
 
60
72
  return_type = inspect.signature(function).return_annotation
61
73
  if return_type is not inspect.Signature.empty:
soar_sdk/meta/app.py CHANGED
@@ -1,5 +1,5 @@
1
- from pydantic import BaseModel, Field
2
- from typing import Optional
1
+ from pydantic import BaseModel, Field, validator
2
+ from typing import Optional, Union
3
3
 
4
4
  from soar_sdk.asset import AssetFieldSpecification
5
5
  from soar_sdk.compat import PythonVersion
@@ -32,7 +32,7 @@ class AppMeta(BaseModel):
32
32
  logo: str = ""
33
33
  logo_dark: str = ""
34
34
  product_name: str = ""
35
- python_version: list[PythonVersion] = Field(default_factory=PythonVersion.all)
35
+ python_version: str = Field(default_factory=PythonVersion.all_csv)
36
36
  product_version_regex: str = ".*"
37
37
  publisher: str = ""
38
38
  utctime_updated: str = ""
@@ -47,6 +47,21 @@ class AppMeta(BaseModel):
47
47
 
48
48
  webhook: Optional[WebhookMeta]
49
49
 
50
+ @validator("python_version", pre=True)
51
+ def convert_python_version_to_csv(cls, v: Union[list, str]) -> str:
52
+ """Converts python_version to a comma-separated string if it's a list and validates versions."""
53
+ if isinstance(v, list):
54
+ # Validate each version in the list and convert to CSV
55
+ validated_versions = [PythonVersion.from_str(str(version)) for version in v]
56
+ return PythonVersion.to_csv(validated_versions)
57
+ elif isinstance(v, str):
58
+ # Validate the CSV string by parsing it and convert back to CSV
59
+ validated_versions = PythonVersion.from_csv(v)
60
+ return PythonVersion.to_csv(validated_versions)
61
+ raise ValueError(
62
+ f"Invalid python_version type must be a list or a comma-separated string: {v}"
63
+ )
64
+
50
65
  def to_json_manifest(self) -> dict:
51
66
  """Converts the AppMeta instance to a JSON-compatible dictionary."""
52
67
  return self.dict(exclude_none=True)
soar_sdk/params.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import Optional, Union, Any
1
+ from typing import Optional, Union, Any, ClassVar
2
2
  from typing_extensions import NotRequired, TypedDict
3
3
 
4
4
  from pydantic.fields import Field, Undefined
@@ -178,6 +178,34 @@ class OnPollParams(Params):
178
178
  class MakeRequestParams(Params):
179
179
  """Canonical parameters for the special make request action."""
180
180
 
181
+ # Define allowed field names for subclasses
182
+ _ALLOWED_FIELDS: ClassVar[set[str]] = {
183
+ "http_method",
184
+ "endpoint",
185
+ "headers",
186
+ "query_parameters",
187
+ "body",
188
+ "timeout",
189
+ "verify_ssl",
190
+ }
191
+
192
+ def __init_subclass__(cls, **kwargs: dict[str, Any]) -> None:
193
+ """Validate that subclasses only define allowed fields."""
194
+ super().__init_subclass__(**kwargs)
195
+ cls._validate_make_request_fields()
196
+
197
+ @classmethod
198
+ def _validate_make_request_fields(cls) -> None:
199
+ """Ensure subclasses only define allowed MakeRequest fields."""
200
+ # Check if any fields are not in the allowed set
201
+ invalid_fields = set(cls.__fields__.keys()) - cls._ALLOWED_FIELDS
202
+
203
+ if invalid_fields:
204
+ raise TypeError(
205
+ f"MakeRequestParams subclass '{cls.__name__}' can only define these fields: "
206
+ f"{sorted(cls._ALLOWED_FIELDS)}. Invalid fields: {sorted(invalid_fields)}"
207
+ )
208
+
181
209
  http_method: str = Param(
182
210
  description="The HTTP method to use for the request.",
183
211
  required=True,
@@ -194,7 +222,7 @@ class MakeRequestParams(Params):
194
222
  required=False,
195
223
  )
196
224
 
197
- query_params: str = Param(
225
+ query_parameters: str = Param(
198
226
  description="The query string to send with the request.",
199
227
  required=False,
200
228
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: splunk-soar-sdk
3
- Version: 2.3.0
3
+ Version: 2.3.2
4
4
  Summary: The official framework for developing and testing Splunk SOAR Apps
5
5
  Project-URL: Homepage, https://github.com/phantomcyber/splunk-soar-sdk
6
6
  Project-URL: Documentation, https://github.com/phantomcyber/splunk-soar-sdk
@@ -1,19 +1,19 @@
1
1
  soar_sdk/__init__.py,sha256=RzAng-ARqpK01SY82lNy4uYJFVG0yW6Q3CccEqbToJ4,726
2
- soar_sdk/abstract.py,sha256=jGXs2Fv5TRpnh5Duz3mWjY8_DAOpY4RSSzvw_z4XN4I,7950
2
+ soar_sdk/abstract.py,sha256=AU5ssJWytMp_RmYOxt_sKBqaFN63UfdMmzmAn0HQE_g,7940
3
3
  soar_sdk/action_results.py,sha256=NQTcQ3NJcYB6h-YNRqO0bCG_hILmTidv2D4FdvCzyDE,11092
4
4
  soar_sdk/actions_manager.py,sha256=wJCyfzkI_6OKZ-Kmll4vRJpGvYdL93Uw-JyEEGnKcw0,5779
5
- soar_sdk/app.py,sha256=lYvaDUYEV6b_uF4CyPh6wlAIbCNISya7bJ8Z2xJyyGY,33356
5
+ soar_sdk/app.py,sha256=WywDS9Eqy52u2lOQyuF6EfLHhLqCVjPTbFzIX06hiAs,33200
6
6
  soar_sdk/app_cli_runner.py,sha256=fJoozhyAt7QUMuc02nE5RL_InpsjQBpr6U4rF9sey3E,11627
7
- soar_sdk/app_client.py,sha256=0r3jIvMM8szCEHXOgRu07VaovKH96pZut5rn2GfYcsc,6275
7
+ soar_sdk/app_client.py,sha256=GZmpenBl25-UQVVpELxWRJanmXBWNIQBRphcSAbnZlU,6253
8
8
  soar_sdk/asset.py,sha256=deS8_B5hr7W2fED8_6wUpVriRgiQ5r8TkGVHiasIaro,10666
9
9
  soar_sdk/async_utils.py,sha256=gND8ZiVTqDYLQ88Ua6SN1mInJaEcfa168eOaRoURt3E,1441
10
10
  soar_sdk/colors.py,sha256=--i_iXqfyITUz4O95HMjfZQGbwFZ34bLmBhtfpXXqlQ,1095
11
- soar_sdk/compat.py,sha256=H7At6OSsZQMtlarjyWNcPfsa4_8FC5k0JLdGrmU-O1M,2666
11
+ soar_sdk/compat.py,sha256=m2fRS3ReJD5K7kwKjJfNE_MYBm5uM6MFuXkefPkPl1Y,3056
12
12
  soar_sdk/crypto.py,sha256=qiBMHUQqgn5lPI1DbujSj700s89FuLJrkQgCO9_eBn4,392
13
13
  soar_sdk/exceptions.py,sha256=CxJ_Q6N1jlknO_3ItDQNhHEw2pNWZr3sMLqutYmr5HA,1863
14
14
  soar_sdk/input_spec.py,sha256=BAa36l8IKDvM8SVMjgZ1XcnWZ2F7O052n2415tLeKK8,4690
15
15
  soar_sdk/logging.py,sha256=lSz8PA6hOCw2MHGE0ZSKbw-FzSr1WdbfQ7BHnXBUUY0,11440
16
- soar_sdk/params.py,sha256=Q2tWOzZWNl2Spvnu29iSUfMleW8U7OD-DdCWtkOXRMw,7720
16
+ soar_sdk/params.py,sha256=OomwUt2bkOwzDs9ypmf-ziZmj2D4uIieO85Jo3haWCg,8731
17
17
  soar_sdk/paths.py,sha256=XhpanQCAiTXaulRx440oKu36mnll7P05TethHXgMpgQ,239
18
18
  soar_sdk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  soar_sdk/types.py,sha256=uMFnNOHpmCLrbAhQOgmXjScXiGE67sM8ySN04MhkC3U,602
@@ -33,10 +33,10 @@ soar_sdk/cli/cli.py,sha256=62n6b41bjXILtkqLTpeID8JyDYMbkfXNV1LCo52YUsA,926
33
33
  soar_sdk/cli/path_utils.py,sha256=rFJDAe-sTC_6KgSiidlD3JcpygFmyHAEsn1j_6eWpIc,1263
34
34
  soar_sdk/cli/utils.py,sha256=GNZLFAMH_BKQo2-D5GvweWxeuR7DfR8eMZS4-sJUggU,1441
35
35
  soar_sdk/cli/init/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- soar_sdk/cli/init/cli.py,sha256=bVp8t28FYCS_wP2FhLWqmIvCkFbqmO1-7Dw8PpTFNq0,14495
36
+ soar_sdk/cli/init/cli.py,sha256=rRt_Rho-mKHYivQzcSKtakFGM6hie0-bQ4D-5O1gjII,14507
37
37
  soar_sdk/cli/manifests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
38
  soar_sdk/cli/manifests/cli.py,sha256=cly5xVdj4bBIdZVMQPIWTXRgUfd1ON3qKO-76Fwql18,524
39
- soar_sdk/cli/manifests/deserializers.py,sha256=FtXv-OywYGb_O5TptS2Hg6niWcfihRPF_RaS5zDBXRk,17045
39
+ soar_sdk/cli/manifests/deserializers.py,sha256=xFTRzWEszKbkO-yNUvGnQfjdJryXpB2FalkxaDmzm3Y,16589
40
40
  soar_sdk/cli/manifests/processors.py,sha256=6B1fQC2WGVaUP-7E9Y5g7BipaVwEomJCkUQ_7gRfSn8,4155
41
41
  soar_sdk/cli/manifests/serializers.py,sha256=0qps_2jsySXa4ytX3DvFt0tbbZlZ7mowIjMu9FEhQMc,3417
42
42
  soar_sdk/cli/package/cli.py,sha256=oCpP9E3PtXq-zCdzQD8Z-4dowKF1YT-uKjTpbt_YT-A,9516
@@ -50,7 +50,7 @@ soar_sdk/code_renderers/toml_renderer.py,sha256=-zP8UzlYMCVVA5ex9slaNLeFTu4xLjkv
50
50
  soar_sdk/code_renderers/templates/pyproject.toml.jinja,sha256=Ti6A5kWMb902Lbd1kmw8qPgVDPNNzlV6rd0pcVEbVUo,3917
51
51
  soar_sdk/decorators/__init__.py,sha256=ttvapTczeQpReZVYgjTw4qnEqKd7b8pR7lNaCpO0npQ,513
52
52
  soar_sdk/decorators/action.py,sha256=ZuSsowsBeEuenGQw03iyd2uv-Ymp9kQYnhYsx7k7pX8,6695
53
- soar_sdk/decorators/make_request.py,sha256=W_ltGvryTvdKomiJ8gL7rE_KVc1VVodhFYstGxB8d4Q,5527
53
+ soar_sdk/decorators/make_request.py,sha256=Em9GoVMtDF3K8CxzVQmcamC3bLOsnNosd8JCaNh-dKw,5959
54
54
  soar_sdk/decorators/on_poll.py,sha256=xdT0QSa_dnh37XdJNGW-DAZsb9oQO5tjxPbIQmWpaZs,8232
55
55
  soar_sdk/decorators/test_connectivity.py,sha256=8uXMD4NW5bokpsAfBctUrfOR4K_geYLEZUY0Y6uI6aU,3568
56
56
  soar_sdk/decorators/view_handler.py,sha256=jhBzbJcokWOeUWR4_orDRWTXiiVwE9RZdRSvNUYF3S0,7362
@@ -58,7 +58,7 @@ soar_sdk/decorators/webhook.py,sha256=Pde0MjxC2kckpxoKb3m4WVfLWtiFAAzAwZe5AF5VIb
58
58
  soar_sdk/meta/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
59
59
  soar_sdk/meta/actions.py,sha256=nrTBwCnCwjOzof-_8Ww9vfoTIfZfauiL6C6DTRg2Mhs,2580
60
60
  soar_sdk/meta/adapters.py,sha256=KjSYIUtkCz2eesA_vhsNCjfi5C-Uz71tbSuDIjhuB8U,1112
61
- soar_sdk/meta/app.py,sha256=rwgoFfIFnLutLB9PF1kR7X1neKs175VA0Xx4KpJ6c7I,1765
61
+ soar_sdk/meta/app.py,sha256=KHvtyxBYf740pTKuMYdrZCh7Kikoaybq5JJeCIQs0CI,2595
62
62
  soar_sdk/meta/datatypes.py,sha256=piR-oBVAATiRciXSdVE7XaqjUZTgSaOvTEqcOcNvCS0,795
63
63
  soar_sdk/meta/dependencies.py,sha256=AQlkdm6A7JEfLI0IAXKU6WzPkUX7oPfxgDkGZ3AofHk,17927
64
64
  soar_sdk/meta/webhooks.py,sha256=1sh4-3I3_UiXFNzVEyoz2Tp6NhgTEZWpERYIzV8OYNY,1188
@@ -96,8 +96,8 @@ soar_sdk/views/components/pie_chart.py,sha256=LVTeHVJN6nf2vjUs9y7PDBhS0U1fKW750l
96
96
  soar_sdk/webhooks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
97
97
  soar_sdk/webhooks/models.py,sha256=-rjuFA9cRX5zTLp7cHSHVTkt5eVJD6BdESGbj_qkyHI,4540
98
98
  soar_sdk/webhooks/routing.py,sha256=BKbURSrBPdOTS5UFL-mHzFEr-Fj04mJMx9KeiPrZ2VQ,6872
99
- splunk_soar_sdk-2.3.0.dist-info/METADATA,sha256=WGypNiW3i7PR8Eef-5QYJUwWSR1ua062kpRU86c7g8Y,7361
100
- splunk_soar_sdk-2.3.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
101
- splunk_soar_sdk-2.3.0.dist-info/entry_points.txt,sha256=CgBjo2ZWpYNkt9TgvToL26h2Tg1yt8FbvYTb5NVgNuc,51
102
- splunk_soar_sdk-2.3.0.dist-info/licenses/LICENSE,sha256=gNCGrGhrSQb1PUzBOByVUN1tvaliwLZfna-QU2r2hQ8,11345
103
- splunk_soar_sdk-2.3.0.dist-info/RECORD,,
99
+ splunk_soar_sdk-2.3.2.dist-info/METADATA,sha256=995bovTLwLBvV4GCEKW5rzi93BCmrwPBiECkFpLciAQ,7361
100
+ splunk_soar_sdk-2.3.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
101
+ splunk_soar_sdk-2.3.2.dist-info/entry_points.txt,sha256=CgBjo2ZWpYNkt9TgvToL26h2Tg1yt8FbvYTb5NVgNuc,51
102
+ splunk_soar_sdk-2.3.2.dist-info/licenses/LICENSE,sha256=gNCGrGhrSQb1PUzBOByVUN1tvaliwLZfna-QU2r2hQ8,11345
103
+ splunk_soar_sdk-2.3.2.dist-info/RECORD,,