Skip to content

Commit c7a977d

Browse files
committed
updated the code
1 parent c4baaf7 commit c7a977d

File tree

2 files changed

+131
-87
lines changed

2 files changed

+131
-87
lines changed

Packs/SilentPush/Integrations/SilentPush/SilentPush.py

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
import demistomock as demisto
2-
from CommonServerPython import *
3-
from CommonServerUserPython import *
4-
import requests
1+
import demistomock as demisto # noqa: F401
2+
from CommonServerPython import * # noqa: F401
3+
"""Base Integration for Cortex XSOAR (aka Demisto)
4+
5+
This is an integration to interact with the SilentPush API and provide functionality within XSOAR.
6+
7+
Developer Documentation: https://xsoar.pan.dev/docs/welcome
8+
Code Conventions: https://xsoar.pan.dev/docs/integrations/code-conventions
9+
Linting: https://xsoar.pan.dev/docs/integrations/linting
10+
"""
11+
12+
from CommonServerUserPython import * # noqa
13+
14+
import urllib3
515
from typing import Any
616

717
# Disable insecure warnings
8-
requests.packages.urllib3.disable_warnings()
18+
urllib3.disable_warnings()
19+
920

1021
def mock_debug(message):
1122
"""Print debug messages to the XSOAR logs"""
@@ -14,19 +25,20 @@ def mock_debug(message):
1425

1526
demisto.debug = mock_debug
1627

17-
class Client:
18-
"""
19-
Client class to interact with the SilentPush API.
28+
''' CONSTANTS '''
29+
30+
DATE_FORMAT = '%Y-%m-%dT%H:%M:%SZ' # ISO8601 format with UTC, default in XSOAR
31+
32+
''' CLIENT CLASS '''
33+
2034

21-
This Client handles all interactions with the SilentPush service. It performs API requests,
22-
processes the responses, and provides methods to query information about domains.
35+
class Client(BaseClient):
36+
"""Client class to interact with the SilentPush API
2337
24-
Attributes:
25-
base_url (str): The base URL for the SilentPush API.
26-
api_key (str): API key used for authentication.
27-
verify (bool): Flag to determine whether to verify SSL certificates.
28-
proxy (bool): Flag to determine whether to use a proxy.
29-
_headers (dict): HTTP headers for the requests.
38+
This Client implements API calls and does not contain any XSOAR logic.
39+
It should only perform requests and return data.
40+
It inherits from BaseClient defined in CommonServerPython.
41+
Most calls use _http_request() that handles proxy, SSL verification, etc.
3042
"""
3143

3244
def __init__(self, base_url: str, api_key: str, verify: bool = True, proxy: bool = False):
@@ -107,6 +119,10 @@ def list_domain_information(self, domain: str) -> dict:
107119
url_suffix = f'explore/domain/domaininfo/{domain}'
108120
return self._http_request('GET', url_suffix)
109121

122+
123+
''' COMMAND FUNCTIONS '''
124+
125+
110126
def test_module(client: Client) -> str:
111127
"""
112128
Tests connectivity to the SilentPush API and checks the authentication status.
@@ -161,6 +177,10 @@ def list_domain_information_command(client: Client, args: dict) -> CommandResult
161177
raw_response=raw_response
162178
)
163179

180+
181+
''' MAIN FUNCTION '''
182+
183+
164184
def main():
165185
"""
166186
Main function to initialize the client and process the commands.
@@ -206,5 +226,9 @@ def main():
206226
demisto.error(f'Failed to execute {demisto.command()} command. Error: {str(e)}')
207227
return_error(f'Failed to execute {demisto.command()} command. Error: {str(e)}')
208228

229+
230+
''' ENTRY POINT '''
231+
232+
209233
if __name__ in ('__main__', '__builtin__', 'builtins'):
210234
main()

Packs/SilentPush/Integrations/SilentPush/SilentPush.yml

Lines changed: 91 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -4,86 +4,106 @@ commonfields:
44
name: SilentPush
55
type: python
66
subType: python3
7-
description: Integration with the SilentPush API to fetch domain information and other related data.
7+
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.
9+
tags: []
810
enabled: true
9-
tags:
10-
- "SilentPush"
11-
- "Domain Info"
12-
- "API"
13-
comment: "Integration to fetch domain information from SilentPush API"
14-
15-
script:
16-
type: python
17-
id: SilentPush
18-
file: SilentPush.py
19-
args: []
20-
isArray: false
11+
manufacturer: SilentPush
12+
comment: ''
13+
minVersion: -1
14+
dependencies:
15+
- CommonServerPython
16+
- CommonServerUserPython
17+
18+
scripts:
19+
- path: SilentPush.py
20+
comment: |
21+
Integration for SilentPush that enables fetching domain information, including WHOIS data, domain age, and risk scores.
2122
2223
commands:
23-
- name: silentpush-list-domain-information
24-
description: Fetches domain information including WHOIS data, domain age, and risk scores.
25-
enabled: true
26-
hidden: false
27-
args:
28-
- isArray: false
29-
name: domain
30-
description: The domain to fetch information for (default is silentpush.com).
31-
isOptional: false
24+
- name: test-module
25+
description: |
26+
Tests the connectivity to the SilentPush API and checks the authentication status.
27+
isArray: false
28+
argContext:
29+
- id: base_url
3230
type: string
33-
implements:
34-
- get
35-
comment: "Fetch domain info, including age, registrar, WHOIS data, and risk scores."
36-
outputs:
37-
- contextPath: SilentPush.Domain
38-
description: "Domain information fetched from SilentPush API."
39-
type: dict
40-
- contextPath: SilentPush.Domain.domain
41-
description: "The domain name."
31+
description: The base URL for the SilentPush API.
32+
- id: api_key
4233
type: string
43-
tags:
44-
- domain
45-
- info
46-
- silentpush
47-
type: python3
48-
command: list_domain_information_command
49-
rawResponse: true
34+
description: The API key used to authenticate requests.
35+
- id: verify_ssl
36+
type: boolean
37+
description: Flag to determine whether SSL verification is enabled.
38+
examples: |
39+
!test-module
5040
51-
- name: test-module
52-
description: Test the connection to the SilentPush API and check API Key validity.
53-
enabled: true
54-
hidden: false
55-
args: []
56-
implements:
57-
- test
58-
outputs:
59-
- contextPath: SilentPush.Test
60-
description: "Returns 'ok' if the API connection is successful."
41+
- name: silentpush-list-domain-information
42+
description: |
43+
Fetches domain information, such as WHOIS data, domain age, and risk scores.
44+
isArray: false
45+
argContext:
46+
- id: domain
6147
type: string
62-
command: test_module
63-
rawResponse: false
48+
description: The domain name to fetch information for.
49+
examples: |
50+
!silentpush-list-domain-information domain=example.com
6451
65-
arguments:
52+
args:
6653
- id: domain
67-
name: domain
68-
description: The domain to fetch information for.
54+
isArray: false
55+
description: |
56+
The domain to fetch information for.
6957
type: string
58+
59+
outputs:
60+
- id: SilentPush.Domain
61+
type: complex
62+
description: |
63+
The domain information fetched from SilentPush API, including WHOIS data, domain age, and risk scores.
64+
contents:
65+
- name: domain
66+
type: string
67+
- name: whois_data
68+
type: string
69+
- name: domain_age
70+
type: integer
71+
- name: risk_score
72+
type: float
73+
74+
tests:
75+
- name: Test SilentPush Integration
76+
description: Test the integration with the SilentPush API.
77+
steps:
78+
- script: test-module
79+
name: Test SilentPush API Connectivity
80+
args:
81+
base_url: https://api.silentpush.com
82+
api_key: 'your_api_key'
83+
84+
# Optional: Adding the configuration section for any configuration-related parameters
85+
configurations:
86+
- default: true
7087
isArray: false
71-
isOptional: false
72-
default: silentpush.com
88+
description: The configuration parameters required for connecting to SilentPush API.
89+
context:
90+
- id: base_url
91+
type: string
92+
description: The base URL for the SilentPush API.
93+
- id: api_key
94+
type: string
95+
description: The API key used to authenticate requests.
96+
- id: verify_ssl
97+
type: boolean
98+
description: Flag to determine whether SSL verification is enabled.
99+
- id: proxy
100+
type: boolean
101+
description: Flag to determine whether to use a proxy.
73102

74-
integrationContext:
75-
outputs:
76-
SilentPush.Domain:
77-
domain: string
78-
age: number
79-
age_score: number
80-
first_seen: number
81-
is_new: bool
82-
is_new_score: number
83-
last_seen: number
84-
registrar: string
85-
whois_age: number
86-
whois_created_date: string
87-
zone: string
88-
SilentPush.Test:
89-
status: string
103+
errorHandling:
104+
- errorCode: 403
105+
description: |
106+
If an authorization error is encountered, it could indicate an incorrect or expired API key.
107+
- errorCode: 400
108+
description: |
109+
Bad Request error, likely due to incorrect input format or invalid parameters in the request.

0 commit comments

Comments
 (0)