Skip to content

Commit

Permalink
Mposluszny/papp 34725 updating dependencies (#17) (#18)
Browse files Browse the repository at this point in the history
* Mposluszny/papp 34725 updating dependencies (#17)

* PAPP-34725

* PAPP-34725 - fixes from pre-commit

* fix min phantom ver

* Update README.md

* added release notes

---------

Co-authored-by: splunk-soar-connectors-admin <admin@splunksoar>

* Bumped up the version of microsoftsccm from 2.3.1 to 2.3.2

* Release notes for version 2.3.2

* Release notes for version 2.3.2

---------

Co-authored-by: splunk-soar-connectors-admin <admin@splunksoar>
Co-authored-by: root <root@splunksoar>
  • Loading branch information
3 people authored Sep 27, 2024
1 parent 62aab6b commit d168e57
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 130 deletions.
27 changes: 16 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
repos:
- repo: https://github.com/phantomcyber/dev-cicd-tools
rev: v1.17
hooks:
- id: org-hook
- id: package-app-dependencies
args: ["-d", "./Dockerfile.wheels"]
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
- id: detect-secrets
args: ['--no-verify', '--exclude-files', '^microsoftsccm.json$']
- repo: https://github.com/phantomcyber/dev-cicd-tools
rev: v1.22
hooks:
- id: org-hook
- id: package-app-dependencies
args:
- -d
- ./Dockerfile.wheels
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
- id: detect-secrets
args:
- --no-verify
- --exclude-files
- ^microsoftsccm.json$
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Microsoft SCCM

Publisher: Splunk
Connector Version: 2.3.1
Connector Version: 2.3.2
Product Vendor: Microsoft
Product Name: SCCM
Product Version Supported (regex): ".\*"
Minimum Product Version: 6.1.1
Minimum Product Version: 6.2.1

This app integrates with Microsoft System Center Configuration Manager (SCCM) to execute investigative and generic actions

Expand Down
54 changes: 15 additions & 39 deletions microsoftsccm.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
"product_version_regex": ".*",
"publisher": "Splunk",
"license": "Copyright (c) 2017-2024 Splunk Inc.",
"app_version": "2.3.1",
"utctime_updated": "2022-02-03T13:09:24.000000Z",
"app_version": "2.3.2",
"utctime_updated": "2024-09-27T10:04:45.000000Z",
"package_name": "phantom_microsoftsccm",
"main_module": "microsoftsccm_connector.py",
"min_phantom_version": "6.1.1",
"min_phantom_version": "6.2.1",
"fips_compliant": true,
"latest_tested_versions": [
"Microsoft SCCM v5.00.8412.1000"
Expand Down Expand Up @@ -593,11 +593,11 @@
"wheel": [
{
"module": "cffi",
"input_file": "wheels/py36/cffi-1.15.1-cp36-cp36m-manylinux1_x86_64.manylinux_2_5_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
"input_file": "wheels/py36/cffi-1.15.1-cp36-cp36m-manylinux1_x86_64.manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_5_x86_64.manylinux_2_28_x86_64.whl"
},
{
"module": "dataclasses",
"input_file": "wheels/py3/dataclasses-0.8-py3-none-any.whl"
"module": "cryptography",
"input_file": "wheels/py36/cryptography-40.0.2-cp36-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl"
},
{
"module": "ntlm_auth",
Expand All @@ -611,74 +611,50 @@
"module": "pykerberos",
"input_file": "wheels/py36/pykerberos-1.2.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
},
{
"module": "pyspnego",
"input_file": "wheels/shared/pyspnego-0.5.4-py2.py3-none-any.whl"
},
{
"module": "pywinrm",
"input_file": "wheels/shared/pywinrm-0.4.3-py2.py3-none-any.whl"
},
{
"module": "requests_credssp",
"input_file": "wheels/shared/requests_credssp-2.0.0-py2.py3-none-any.whl"
},
{
"module": "requests_ntlm",
"input_file": "wheels/shared/requests_ntlm-1.1.0-py2.py3-none-any.whl"
},
{
"module": "six",
"input_file": "wheels/shared/six-1.16.0-py2.py3-none-any.whl"
},
{
"module": "xmltodict",
"input_file": "wheels/shared/xmltodict-0.13.0-py2.py3-none-any.whl"
}
]
},
"pip39_dependencies": {
"wheel": [
{
"module": "cffi",
"input_file": "wheels/py39/cffi-1.16.0-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.whl"
"input_file": "wheels/py39/cffi-1.17.1-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl"
},
{
"module": "cryptography",
"input_file": "wheels/py39/cryptography-43.0.1-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl"
},
{
"module": "ntlm_auth",
"input_file": "wheels/shared/ntlm_auth-1.5.0-py2.py3-none-any.whl"
},
{
"module": "pycparser",
"input_file": "wheels/shared/pycparser-2.21-py2.py3-none-any.whl"
"input_file": "wheels/py3/pycparser-2.22-py3-none-any.whl"
},
{
"module": "pykerberos",
"input_file": "wheels/py39/pykerberos-1.2.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl"
},
{
"module": "pyspnego",
"input_file": "wheels/py3/pyspnego-0.10.2-py3-none-any.whl"
"input_file": "wheels/py3/pyspnego-0.11.1-py3-none-any.whl"
},
{
"module": "pywinrm",
"input_file": "wheels/shared/pywinrm-0.4.3-py2.py3-none-any.whl"
},
{
"module": "requests_credssp",
"input_file": "wheels/shared/requests_credssp-2.0.0-py2.py3-none-any.whl"
},
{
"module": "requests_ntlm",
"input_file": "wheels/shared/requests_ntlm-1.1.0-py2.py3-none-any.whl"
},
{
"module": "six",
"input_file": "wheels/shared/six-1.16.0-py2.py3-none-any.whl"
},
{
"module": "xmltodict",
"input_file": "wheels/shared/xmltodict-0.13.0-py2.py3-none-any.whl"
"input_file": "wheels/py3/requests_ntlm-1.3.0-py3-none-any.whl"
}
]
}
}
}
82 changes: 39 additions & 43 deletions microsoftsccm_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self):
self._password = None

def _handle_test_connectivity(self, param):
""" This function tests the connectivity of an asset with given credentials.
"""This function tests the connectivity of an asset with given credentials.
:param param: (not used in this method)
:return: status success/failure
Expand Down Expand Up @@ -79,29 +79,32 @@ def _get_fips_enabled(self):

fips_enabled = is_fips_enabled()
if fips_enabled:
self.debug_print('FIPS is enabled')
self.debug_print("FIPS is enabled")
else:
self.debug_print('FIPS is not enabled')
self.debug_print("FIPS is not enabled")
return fips_enabled

def _get_protocol(self):
if self._auth_type != MSSCCM_DEFAULT_AUTH_METHOD:
transport = self._auth_type
else:
transport = 'basic' if self._get_fips_enabled() else "ntlm"
transport = "basic" if self._get_fips_enabled() else "ntlm"

server_cert_validation = 'validate' if self._verify_server_cert else 'ignore'
server_cert_validation = "validate" if self._verify_server_cert else "ignore"

return Protocol(endpoint=MSSCCM_SERVER_URL.format(url=self._server_url),
transport=transport,
username=self._username, password=self._password,
server_cert_validation=server_cert_validation,
cert_pem=self._cert_pem_path,
cert_key_pem=self._cert_key_pem_path,
ca_trust_path=self._cert_ca_trust_path)
return Protocol(
endpoint=MSSCCM_SERVER_URL.format(url=self._server_url),
transport=transport,
username=self._username,
password=self._password,
server_cert_validation=server_cert_validation,
cert_pem=self._cert_pem_path,
cert_key_pem=self._cert_key_pem_path,
ca_trust_path=self._cert_ca_trust_path,
)

def _execute_ps_command(self, action_result, ps_command):
""" This function is used to execute power shell command.
"""This function is used to execute power shell command.
:param action_result: object of ActionResult
:param ps_command: power shell command
Expand All @@ -115,24 +118,19 @@ def _execute_ps_command(self, action_result, ps_command):
shell_id = protocol.open_shell()
except InvalidCredentialsError as credentials_err:
self.debug_print(MSSCCM_INVALID_CREDENTIAL_ERROR, credentials_err)
return action_result.set_status(phantom.APP_ERROR, MSSCCM_INVALID_CREDENTIAL_ERROR,
credentials_err), resp_output
return action_result.set_status(phantom.APP_ERROR, MSSCCM_INVALID_CREDENTIAL_ERROR, credentials_err), resp_output
except exceptions.SSLError as ssl_err:
self.debug_print(MSSCCM_ERROR_BAD_HANDSHAKE, ssl_err)
return action_result.set_status(phantom.APP_ERROR, MSSCCM_ERROR_BAD_HANDSHAKE,
ssl_err), resp_output
return action_result.set_status(phantom.APP_ERROR, MSSCCM_ERROR_BAD_HANDSHAKE, ssl_err), resp_output
except exceptions.ConnectionError as conn_err:
self.debug_print(MSSCCM_ERROR_SERVER_CONNECTION, conn_err)
return action_result.set_status(phantom.APP_ERROR, MSSCCM_ERROR_SERVER_CONNECTION,
conn_err), resp_output
return action_result.set_status(phantom.APP_ERROR, MSSCCM_ERROR_SERVER_CONNECTION, conn_err), resp_output
except WinRMTransportError as transport_err:
self.debug_print(MSSCCM_TRANSPORT_ERROR, transport_err)
return action_result.set_status(phantom.APP_ERROR, MSSCCM_TRANSPORT_ERROR,
transport_err), resp_output
return action_result.set_status(phantom.APP_ERROR, MSSCCM_TRANSPORT_ERROR, transport_err), resp_output
except Exception as e:
self.debug_print(MSSCCM_EXCEPTION_OCCURRED, e)
return action_result.set_status(phantom.APP_ERROR, MSSCCM_EXCEPTION_OCCURRED,
e), resp_output
return action_result.set_status(phantom.APP_ERROR, MSSCCM_EXCEPTION_OCCURRED, e), resp_output

try:
command_id = protocol.run_command(shell_id, ps_command)
Expand All @@ -141,17 +139,15 @@ def _execute_ps_command(self, action_result, ps_command):
protocol.close_shell(shell_id)
except Exception as err:
self.debug_print(MSSCCM_EXCEPTION_OCCURRED, err)
return action_result.set_status(phantom.APP_ERROR, MSSCCM_EXCEPTION_OCCURRED,
err), resp_output
return action_result.set_status(phantom.APP_ERROR, MSSCCM_EXCEPTION_OCCURRED, err), resp_output

if status_code:
return action_result.set_status(phantom.APP_ERROR, MSSCCM_EXCEPTION_OCCURRED,
resp_err), resp_output
return action_result.set_status(phantom.APP_ERROR, MSSCCM_EXCEPTION_OCCURRED, resp_err), resp_output

return action_result.set_status(phantom.APP_SUCCESS), resp_output

def _handle_deploy_patch(self, param):
""" This function is used to deploy software patches.
"""This function is used to deploy software patches.
:param param: dictionary of input parameters
:return: status success/failure
Expand All @@ -167,10 +163,9 @@ def _handle_deploy_patch(self, param):
device_group_name = param[MSSCCM_PARAM_DEVICE_GROUP_NAME]

# Execute Command
status, _ = self._execute_ps_command(action_result,
MSSCCM_DEPLOY_SOFTWARE_PATCHES.format(
name=software_patch_name,
device_group_name=device_group_name, q='\\"'))
status, _ = self._execute_ps_command(
action_result, MSSCCM_DEPLOY_SOFTWARE_PATCHES.format(name=software_patch_name, device_group_name=device_group_name, q='\\"')
)

# Something went wrong
if phantom.is_fail(status):
Expand All @@ -189,7 +184,7 @@ def _handle_deploy_patch(self, param):
return action_result.set_status(phantom.APP_SUCCESS, "Patch deployed successfully")

def _handle_list_patches(self, param):
""" This function is used to list all software patches.
"""This function is used to list all software patches.
:param param: dictionary of input parameters
:return: status success/failure
Expand Down Expand Up @@ -221,12 +216,12 @@ def _handle_list_patches(self, param):

# Update summary
summary = action_result.update_summary({})
summary['total_software_patches'] = action_result.get_data_size()
summary["total_software_patches"] = action_result.get_data_size()

return action_result.set_status(phantom.APP_SUCCESS)

def _handle_list_device_groups(self, param):
""" This function is used to list all device groups.
"""This function is used to list all device groups.
:param param: dictionary of input parameters
:return: status success/failure
Expand Down Expand Up @@ -258,23 +253,23 @@ def _handle_list_device_groups(self, param):

# Update summary
summary = action_result.update_summary({})
summary['total_device_groups'] = action_result.get_data_size()
summary["total_device_groups"] = action_result.get_data_size()

return action_result.set_status(phantom.APP_SUCCESS)

def handle_action(self, param):
""" This function gets current action identifier and calls member function of its own to handle the action.
"""This function gets current action identifier and calls member function of its own to handle the action.
:param param: dictionary which contains information about the actions to be executed
:return: status success/failure
"""

# Dictionary mapping each action with its corresponding actions
action_mapping = {
'deploy_patch': self._handle_deploy_patch,
'test_connectivity': self._handle_test_connectivity,
'list_patches': self._handle_list_patches,
'list_device_groups': self._handle_list_device_groups
"deploy_patch": self._handle_deploy_patch,
"test_connectivity": self._handle_test_connectivity,
"list_patches": self._handle_list_patches,
"list_device_groups": self._handle_list_device_groups,
}

action = self.get_action_identifier()
Expand Down Expand Up @@ -316,14 +311,15 @@ def finalize(self):
return phantom.APP_SUCCESS


if __name__ == '__main__':
if __name__ == "__main__":

import sys

import pudb

pudb.set_trace()

if (len(sys.argv) < 2):
if len(sys.argv) < 2:
print("No test json specified as input")
sys.exit(0)

Expand Down
Loading

0 comments on commit d168e57

Please sign in to comment.