Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implemented the get domain command #18

Open
wants to merge 19 commits into
base: SilentPush-v1.0.0
Choose a base branch
from

Conversation

karand-metron
Copy link

implemented the get domain command

@karand-metron karand-metron self-assigned this Jan 16, 2025
Copy link
Collaborator

@meghak-metron meghak-metron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karand-metron Please check the review comments

demisto.error('Job status URL not found in the response')
return response


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karand-metron Check what if job status is null/empty.

Returns:
dict: A dictionary containing the search results
"""
demisto.debug(f'Searching domains with query: {query}')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karand-metron Please remove the debug prints

if len(domains) > 100:
raise DemistoException("Maximum of 100 domains can be submitted in a single request")

demisto.debug(f'Processing domains in bulk: {domains}')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
demisto.debug(f'Processing domains in bulk: {domains}')
demisto.debug(f'Processing domains in bulk: {domains}')

Please remove these prints

"""
Command handler for fetching domain information.
domain = args.get('domain', 'silentpush.com')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
domain = args.get('domain', 'silentpush.com')
domain = args.get('domain', 'silentpush.com')

@karand-metron Please remove hard coded values


domain = domain_list[0]
try:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need separate API for getting single domain.



job_complete = False
while not job_complete:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like wrong logic for response receive for domain certificate.

demisto.debug(f'Headers: {masked_headers}')
demisto.debug(f'Params: {params}')
demisto.debug(f'Data: {data}')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not remove all the logs, can we have some logs, those are useful for debugging.

domains = [domain.strip() for domain in domains_arg.split(',') if domain.strip()]
if len(domains) > 100:
raise DemistoException("A maximum of 100 domains can be submitted in a single request.")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove so many empty lines in the code.

fetch_whois_info = argToBoolean(args.get('fetch_whois_info', False))


raw_response = client.list_domain_information(domains, fetch_risk_score, fetch_whois_info)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty lines from everywhere.

if as_of:
params['as_of'] = as_of

try:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain why do we need an try except block here? are you handling any specific situation?


url_suffix = "explore/bulk/ip2asn"

try:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain why do we need an try except block here?




try:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain why do we need an try except block here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karand-metron Let's try to add YMLMetadataCollector. This is the only way we can generate the .yml from .py file with all the validations. Here is the link for reference




def test_module(client: Client) -> str:
try:
client.list_domain_information('silentpush.com')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a specific reason you are using this function for the test command? In this command, we only need to verify that we can connect to the Client instance. If possible, try adding a simple method to test the connection.

'Common Name': cert.get('common_name', 'N/A'),
'Subject Alternative Names': ', '.join(cert.get('subject_alt_names', [])),
}
markdown.append(tableToMarkdown('Certificate Information', [cert_info]))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add tableToMarkdown() inside loop. Please update this in all the functions.

limit = arg_to_number(args.get('limit'))

if not nameserver:
raise DemistoException("nameserver is a required parameter")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise DemistoException("nameserver is a required parameter")
raise DemistoException("Nameserver is a required parameter.")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants