Skip to content

Commit 707d212

Browse files
committed
updated the code
1 parent b15caf8 commit 707d212

File tree

2 files changed

+85
-10
lines changed

2 files changed

+85
-10
lines changed

Packs/SilentPush/Integrations/SilentPush/SilentPush.py

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from CommonServerUserPython import * # noqa
1313

14+
import requests
1415
import urllib3
1516
from typing import Any
1617

@@ -119,6 +120,20 @@ def list_domain_information(self, domain: str) -> dict:
119120
url_suffix = f'explore/domain/domaininfo/{domain}'
120121
return self._http_request('GET', url_suffix)
121122

123+
def get_domain_certificates(self, domain: str) -> dict:
124+
"""
125+
Fetches SSL/TLS certificate data for a given domain.
126+
127+
Args:
128+
domain (str): The domain to fetch certificate information for.
129+
130+
Returns:
131+
dict: A dictionary containing certificate information fetched from the API.
132+
"""
133+
demisto.debug(f'Fetching certificate information for domain: {domain}')
134+
url_suffix = f'explore/domain/certificates/{domain}'
135+
return self._http_request('GET', url_suffix)
136+
122137

123138
def test_module(client: Client) -> str:
124139
"""
@@ -179,6 +194,30 @@ def list_domain_information_command(client: Client, args: dict) -> CommandResult
179194
)
180195

181196

197+
def get_domain_certificates_command(client: Client, args: dict) -> CommandResults:
198+
"""
199+
Command handler for fetching domain certificate information.
200+
"""
201+
domain = args.get('domain', 'silentpush.com')
202+
demisto.debug(f'Processing certificates for domain: {domain}')
203+
204+
205+
demisto.debug('Entering get_domain_certificates_command function')
206+
207+
raw_response = client.get_domain_certificates(domain)
208+
demisto.debug(f'Response from API: {raw_response}')
209+
210+
readable_output = tableToMarkdown('Domain Certificates', raw_response)
211+
212+
return CommandResults(
213+
outputs_prefix='SilentPush.Certificates',
214+
outputs_key_field='domain',
215+
outputs=raw_response,
216+
readable_output=readable_output,
217+
raw_response=raw_response
218+
)
219+
220+
182221
''' MAIN FUNCTION '''
183222

184223

@@ -213,13 +252,19 @@ def main():
213252
command = demisto.command()
214253
demisto.debug(f'Command being called is {command}')
215254

216-
if command == 'test-module':
217-
result = test_module(client)
218-
return_results(result)
219-
220-
elif command == 'silentpush-list-domain-information':
221-
return_results(list_domain_information_command(client, demisto.args()))
222-
255+
command_handlers = {
256+
257+
'test-module': test_module,
258+
'silentpush-list-domain-information': list_domain_information_command,
259+
'silentpush-get-domain-certificates': get_domain_certificates_command,
260+
}
261+
262+
if command in command_handlers:
263+
if command == 'test-module':
264+
result = command_handlers[command](client)
265+
return_results(result)
266+
else:
267+
return_results(command_handlers[command](client, demisto.args()))
223268
else:
224269
raise DemistoException(f'Unsupported command: {command}')
225270

Packs/SilentPush/Integrations/SilentPush/SilentPush.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ commonfields:
55
type: python
66
subType: python3
77
description: |
8-
This integration allows fetching domain information from the SilentPush API. It includes commands to get domain-related information such as WHOIS data, domain age, and risk scores.
8+
This integration allows fetching domain information from the SilentPush API. It includes commands to get domain-related information such as WHOIS data, domain age, and risk scores, as well as SSL/TLS certificate data.
99
tags: []
1010
enabled: true
1111
manufacturer: SilentPush
@@ -18,7 +18,7 @@ commonfields:
1818
scripts:
1919
- path: SilentPush.py
2020
comment: |
21-
Integration for SilentPush that enables fetching domain information, including WHOIS data, domain age, and risk scores.
21+
Integration for SilentPush that enables fetching domain information, including WHOIS data, domain age, risk scores, and certificates.
2222
2323
commands:
2424
- name: test-module
@@ -49,6 +49,17 @@ commands:
4949
examples: |
5050
!silentpush-list-domain-information domain=example.com
5151
52+
- name: silentpush-get-domain-certificates
53+
description: |
54+
Fetches SSL/TLS certificate data for a given domain.
55+
isArray: false
56+
argContext:
57+
- id: domain
58+
type: string
59+
description: The domain to fetch certificate information for.
60+
examples: |
61+
!silentpush-get-domain-certificates domain=example.com
62+
5263
args:
5364
- id: domain
5465
isArray: false
@@ -71,6 +82,25 @@ outputs:
7182
- name: risk_score
7283
type: float
7384

85+
- id: SilentPush.Certificates
86+
type: complex
87+
description: |
88+
The certificate information fetched from SilentPush API for the domain.
89+
contents:
90+
- name: domain
91+
type: string
92+
- name: certificates
93+
type: list
94+
items:
95+
- name: certificate_issuer
96+
type: string
97+
- name: valid_from
98+
type: string
99+
- name: valid_to
100+
type: string
101+
- name: certificate_serial_number
102+
type: string
103+
74104
tests:
75105
- name: Test SilentPush Integration
76106
description: Test the integration with the SilentPush API.
@@ -81,7 +111,7 @@ tests:
81111
base_url: https://api.silentpush.com
82112
api_key: 'your_api_key'
83113

84-
# Optional: Adding the configuration section for any configuration-related parameters
114+
85115
configurations:
86116
- default: true
87117
isArray: false

0 commit comments

Comments
 (0)