IntSights Deprecated

Deprecated. Use Rapid7 Threat Command instead.

Data Enrichment & Threat Intelligence · Rapid7 - Threat Command (IntSights)

Details

IDIntSights
ProviderRapid7
CategoryData Enrichment & Threat Intelligence
From Version5.0.0
Docker Imagedemisto/python3:3.10.10.51930
Supported ModulesAgentix XSIAM

README

Use IntSights to manage and mitigate threats.
This integration was tested with Intsights API version 3.

Configure IntSights in Cortex

Parameter Required
Server URL (e.g. https://192.168.0.1) True
Credentials True
Password True
Alert type to fetch as incidents, allowed: “AttackIndication”, “DataLeakage”, “Phishing”, “BrandSecurity”, “ExploitableData”, “VIP” False
Minimum Alert severity level to fetch incidents incidents from, allowed values are: ‘All’, ‘Low’, ‘Medium’,’High’(Setting to All will fetch all incidents) False
Trust any certificate (not secure) False
Use system proxy settings False
Fetch incidents False
First fetch timestamp (<number> <time unit>, e.g., 12 hours, 7 days) False
Max fetch False
Incident type False
Sub Account ID (MSSP accounts only) False

Commands

You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.

intsights-get-alert-image


Returns an image of an alert by ID.

Base Command

intsights-get-alert-image

Input

Argument Name Description Required
image-id The ID of the image to return. Required

Context Output

There is no context output for this command.

intsights-get-alert-activities


Returns alert activities.

Base Command

intsights-get-alert-activities

Input

Argument Name Description Required
alert-id The ID of the alert. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.
IntSights.Alerts.Activities.Type string The type of the activity.
IntSights.Alerts.Activities.Initiator string The initiator of the alert.
IntSights.Alerts.Activities.CreatedDate date The date the alert was created.
IntSights.Alerts.Activities.UpdateDate date The date the alert was updated.
IntSights.Alerts.Activities.RemediationBlocklistUpdate string The remediation blocked list update.
IntSights.Alerts.Activities.AskTheAnalyst.Replies string The replies to questions of the analyst.
IntSights.Alerts.Activities.Mail.Replies string The replies to an email.
IntSights.Alerts.Activities.ReadBy string The alert that was read by.

intsights-assign-alert


Assigns an alert.

Base Command

intsights-assign-alert

Input

Argument Name Description Required
alert-id The unique ID of the Alert. Required
assignee-email The user email of the assignee. Required
is-mssp-optional Whether the assigned user is an MSSP user. Possible values are: true, false. Default is false. Optional

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.
IntSights.Alerts.Assignees.AssigneeID string The ID of the assignee.

intsights-unassign-alert


Unassigns an alert from a user.

Base Command

intsights-unassign-alert

Input

Argument Name Description Required
alert-id The unique ID of the alert. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.

intsights-send-mail


Sends an email containing a question and details of the alert.

Base Command

intsights-send-mail

Input

Argument Name Description Required
alert-id The unique ID of the alert. Required
emails The destination email addresses array (comma-separated). Required
content The content added to the alert details. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the Alert.
IntSights.Alerts.Mail.EmailID string The ID of the email.
IntSights.Alerts.Question string Details of the question.

intsights-ask-the-analyst


Sends a question to the IntSights analyst about the requested alert.

Base Command

intsights-ask-the-analyst

Input

Argument Name Description Required
alert-id The unique ID of the alert. Required
question Question to ask the Intsights analyst about the requested alert. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the Alert.
IntSights.Alerts.Question string Details of the question.

intsights-add-tag-to-alert


Adds a tag to the alert.

Base Command

intsights-add-tag-to-alert

Input

Argument Name Description Required
alert-id The ID of the unique alert. Required
tag-name The new tag string. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.
IntSights.Alerts.Tags.TagName string The name of the tag.
IntSights.Alerts.Tags.ID string The ID of the Tag.

intsights-remove-tag-from-alert


Removes a tag from the specified alert.

Base Command

intsights-remove-tag-from-alert

Input

Argument Name Description Required
alert-id The unique ID of the alert. Required
tag-id The unique ID of the tag to remove. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.
IntSights.Alerts.Tags.ID string The ID of the tag.

intsights-add-comment-to-alert


Adds a comment to a specified alert.

Base Command

intsights-add-comment-to-alert

Input

Argument Name Description Required
alert-id The unique ID of the alert. Required
comment The comment to add to the alert. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.
IntSights.Alerts.Comment string The comment in the alert.

intsights-update-alert-severity


Changes the severity of a specified alert.

Base Command

intsights-update-alert-severity

Input

Argument Name Description Required
alert-id The unique ID of the alert. Required
severity The severity of the alert. Can be: “High”, “Medium”, or “Low”. Possible values are: High, Medium, Low. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.
IntSights.Alerts.Severity string The severity of the alert.

intsights-get-alert-by-id


Returns the alert object by alert ID.

Base Command

intsights-get-alert-by-id

Input

Argument Name Description Required
alert-id The unique ID of the alert. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.
IntSights.Alerts.Severity string The severity of the alert.
IntSights.Alerts.Type string The type of the alert.
IntSights.Alerts.FoundDate date The date that the alert was found.
IntSights.Alerts.SourceType string The source type of the alert.
IntSights.Alerts.SourceURL string The source URL of the alert.
IntSights.Alerts.SourceEmail string The source email of the alert.
IntSights.Alerts.SourceNetworkType string The network type of the alert.
IntSights.Alerts.IsClosed boolean Whether or not the alert is closed.
IntSights.Alerts.IsFlagged boolean Whether or not the alert is flagged.
IntSights.Alerts.Tags.CreatedBy string Name of the service for which the tag was created.
IntSights.Alerts.Tag.Name string Name of the tag.
IntSights.Alerts.Tag.ID string The ID of the tag.
IntSights.Alerts.Images string The ID of the images.
IntSights.Alerts.Description string The description of the alert.
IntSights.Alerts.Title string The title of the alert.
IntSights.Alerts.TakedownStatus string The TakedownStatus of the alert.
IntSights.Alerts.SubType string The sub type of the alert.

intsights-get-ioc-by-value


Searches for an exact IOC value.

Base Command

intsights-get-ioc-by-value

Input

Argument Name Description Required
value The IOC value for which to search. Required

Context Output

Path Type Description
IntSights.Iocs.Value string The value of the IOC.
IntSights.Iocs.Type string The type of the IOC.
IntSights.Iocs.FirstSeen date The date the IOC was first seen.
IntSights.Iocs.LastSeen date The date the IOC was last seen.
IntSights.Iocs.LastUpdatedDate date The date the IOC was last updated.
IntSights.Iocs.SourceID string The source ID of the IOC.
IntSights.Iocs.SourceName string The source name of the IOC.
IntSights.Iocs.SourceConfidenceLevel string The confidence level of the IOC source.
IntSights.Iocs.Severity string The severity of the IOC.
IntSights.Iocs.Status string The status of the IOC.
IntSights.Iocs.Sources.name string The source name of the IOC.
IntSights.Iocs.Sources.confidenceLevel string The confidence level of the IOC source.
IntSights.Iocs.Sources.id string The source id of the IOC.
IntSights.Iocs.tags Array The tags of the IOC.
DBotScore.Indicator String The indicator that was tested.
DBotScore.Type String The type of the indicator.
DBotScore.Vendor String The vendor used to calculate the score.
DBotScore.Score Number The actual score.
File.Name String The full file name (including file extension).
File.Malicious.Vendor String The vendor that reported the file as malicious.
File.Malicious.Description String A description explaining why the file was determined to be malicious.
File.MD5 String The MD5 hash of the file.
File.SHA1 String The SHA1 hash of the file.
File.SHA256 String The SHA256 hash of the file.
URL.Data String The URL.
URL.Malicious.Vendor String The vendor reporting the URL as malicious.
URL.Malicious.Description String A description of the malicious URL.
IP.Malicious.Vendor String The vendor reporting the IP address as malicious.
IP.Malicious.Description String A description explaining why the IP address was reported as malicious.
IP.Address String IP address.
Domain.Name String The domain name. For example, “google.com”.
Domain.Malicious.Vendor String The vendor reporting the domain as malicious.
Domain.Malicious.Description String A description explaining why the domain was reported as malicious.

intsights-get-iocs


Returns count totals of the available IOCs.

Base Command

intsights-get-iocs

Input

Argument Name Description Required
type The type of the IOC. Can be: “Urls”, “Hashes”, “IpAddresses”, or “domains”. Possible values are: Urls, Hashes, IpAddresses, Domains. Optional
limit The maximum number of results from 1-1000. Default is 1000. Optional
severity The severity level of the IOC. Can be: “High”, “Medium”, or “Low”. Possible values are: High, Medium, Low. Optional
source-ID The source of the IOC. Optional
first-seen-from Beginning of the date range when the IOC was first seen (MM/DD/YYYY). Default is 0. Optional
first-seen-to End of the date range when the IOC was first seen (MM/DD/YYYY). Default is 0. Optional
last-seen-from Beginning of the date range when the IOC was last seen (MM/DD/YYYY). Default is 0. Optional
last-updated-from Beginning of the date range when the IOC was last updated (YYYY-MM-DD). Optional
last-seen-to End of the date range when the IOC was last seen (MM/DD/YYYY). Default is 0. Optional

Context Output

Path Type Description
IntSights.Iocs.Value string The value of the IOC.
IntSights.Iocs.Type string The type of the IOC.
IntSights.Iocs.FirstSeen date The date the IOC was first seen.
IntSights.Iocs.LastSeen date The date the IOC was last seen.
IntSights.Iocs.LastUpdatedDate date The date the IOC was last updated.
IntSights.Iocs.SourceID string The source ID of the IOC.
IntSights.Iocs.SourceName string The source name of the IOC.
IntSights.Iocs.SourceConfidenceLevel string The confidence level of the IOC source.
IntSights.Iocs.Severity string The severity of the IOC.
IntSights.Iocs.Status string The status of the IOC.
IntSights.Iocs.Sources.name string The source name of the IOC.
IntSights.Iocs.Sources.confidenceLevel string The confidence level of the IOC source.
IntSights.Iocs.Sources.id string The source id of the IOC.
IntSights.Iocs.tags Array The tags of the IOC.
DBotScore.Indicator String The indicator that was tested.
DBotScore.Type String The type of the indicator.
DBotScore.Vendor String The vendor used to calculate the score.
DBotScore.Score Number The actual score.
File.Name String The full file name (including file extension).
File.Malicious.Vendor String The vendor that reported the file as malicious.
File.Malicious.Description String A description explaining why the file was determined to be malicious.
File.MD5 String The MD5 hash of the file.
File.SHA1 String The SHA1 hash of the file.
File.SHA256 String The SHA256 hash of the file.
URL.Data String The URL.
URL.Malicious.Vendor String The vendor reporting the URL as malicious.
URL.Malicious.Description String A description of the malicious URL.
IP.Malicious.Vendor String The vendor reporting the IP address as malicious.
IP.Malicious.Description String A description explaining why the IP address was reported as malicious.
IP.Address String IP address.
Domain.Name String The domain name. For example, “google.com”.
Domain.Malicious.Vendor String The vendor reporting the domain as malicious.
Domain.Malicious.Description String A description explaining why the domain was reported as malicious.

intsights-get-alerts


Returns alerts.

Base Command

intsights-get-alerts

Input

Argument Name Description Required
alert-type The type of the alert. Can be: “AttackIndication”, “DataLeakage”, “Phishing”, “BrandSecurity”, “ExploitableData”, “VIP”. Possible values are: AttackIndication, DataLeakage, Phishing, BrandSecurity, ExploitableData, VIP. Optional
severity The severity of the alert. Can be: “High”, “Medium”, or “Low”. Possible values are: High, Medium, Low. Optional
source-type The source type of the alert. Can be: “ApplicationStores”, “BlackMarkets”, “HackingForums”, “SocialMedia”, “PasteSites”, or “Others”. Possible values are: ApplicationStores, BlackMarkets, HackingForums, SocialMedia, PasteSites, Others. Optional
network-type The network type of the alert. Can be: “ClearWeb”, or “DarkWeb”. Possible values are: ClearWeb, DarkWeb. Optional
source-date-from The start date for which to fetch in Millisecond Timestamp in UNIX. Optional
source-date-to The end date for which to fetch in Millisecond Timestamp in UNIX. Optional
found-date-from The start date for which fetch in Millisecond Timestamp in UNIX. Optional
found-date-to The end date for which fetch in Millisecond Timestamp in UNIX. Optional
assigned Whether to show assigned or unassigned alerts. Optional
is-flagged Whether to show flagged or unflagged alerts. Optional
is-closed Whether to show closed/open alerts. Optional
time-delta Shows alerts within a specified time delta, given in days. Optional

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.
IntSights.Alerts.Severity string The severity of the alert.
IntSights.Alerts.Type string The type of the alert.
IntSights.Alerts.FoundDate date The date that the alert was found.
IntSights.Alerts.SourceType string The source type of the alert.
IntSights.Alerts.SourceURL string The source URL of the alert.
IntSights.Alerts.SourceEmail string The source email of the alert.
IntSights.Alerts.SourceNetworkType string The network type of the alert.
IntSights.Alerts.IsClosed boolean Whether or not the alert is closed.
IntSights.Alerts.IsFlagged boolean Whether or not the alert is flagged.
IntSights.Alerts.Tags.CreatedBy string Name of the service that the tag was created.
IntSights.Alerts.Tag.Name string Name of the tag.
IntSights.Alerts.Tag.ID string The ID of the tag.
IntSights.Alerts.Images string The ID of each image.
IntSights.Alerts.Description string The description of the alert.
IntSights.Alerts.Title string The title of the alert.
IntSights.Alerts.TakedownStatus string The TakedownStatus of the alert.
IntSights.Alerts.SubType string The sub type of the alert.

intsights-alert-takedown-request


Requests an alert takedown.

Base Command

intsights-alert-takedown-request

Input

Argument Name Description Required
alert-id The ID of the alert. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.

intsights-get-alert-takedown-status


Returns the alert takedown status.

Base Command

intsights-get-alert-takedown-status

Input

Argument Name Description Required
alert-id The ID of the alert. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.
IntSights.Alerts.TakedownStatus string The status of the takedown.

intsights-update-ioc-blocklist-status


Updates the IOC block list status.

Base Command

intsights-update-ioc-blocklist-status

Input

Argument Name Description Required
alert-id The ID of the alert. Required
type A comma separated list of each type of IOC. Options: Domains, IPs, URLs. Required
value A comma separated list of the value of the IOCs. Required
blocklist-status A comma separated list of the IOCs block list status. Options: Sent, NotSent. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.
IntSights.Alerts.Status string The status of the block list.

intsights-get-ioc-blocklist-status


Returns the status of the IOC block list.

Base Command

intsights-get-ioc-blocklist-status

Input

Argument Name Description Required
alert-id The ID of the alert. Required

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.
IntSights.Alerts.Status string The status of the block list.

intsights-close-alert


Closes an alert

Base Command

intsights-close-alert

Input

Argument Name Description Required
alert-id The ID of the alert. Required
reason The reason to close the alert. Can be: “ProblemSolved”, “InformationalOnly”, “ProblemWeAreAlreadyAwareOf”, “CompanyOwnedDomain”, “LegitimateApplication/Profile”, “NotRelatedToMyCompany”, “FalsePositive”, or “Other”. Possible values are: ProblemSolved, InformationalOnly, ProblemWeAreAlreadyAwareOf, CompanyOwnedDomain, LegitimateApplication/Profile, NotRelatedToMyCompany, FalsePositive, Other. Required
free-text The comments in the alert. Optional
is-hidden The hidden status of the alert. Deletes an alert from the account instance - only when reason is a FalsePositive). Possible values are: True, False. Default is False. Optional
rate The rate of the alert. Optional

Context Output

Path Type Description
IntSights.Alerts.ID string The ID of the alert.
IntSights.Alerts.Closed.Reason string The closed reason of the alert.

intsights-mssp-get-sub-accounts


Returns all Managed Security Service Provider’s (MSSP) sub accounts.

Base Command

intsights-mssp-get-sub-accounts

Input

| Argument Name | Description | Required |
| — | — | — |

Context Output

Path Type Description
IntSights.MsspAccount.ID String The ID of IntSights MSSP sub account.
IntSights.MsspAccount.Status String The enabled status of IntSights MSSP sub account
IntSights.MsspAccount.AssetsCount Number The assets count of IntSights MSSP sub account.
IntSights.MsspAccount.AssetLimit Number The asset limit of IntSights MSSP sub account.
IntSights.MsspAccount.CompanyName String The company name of IntSights MSSP sub account.

intsights-request-ioc-enrichment


Request and receive enrichment of an IOC.

Base Command

intsights-request-ioc-enrichment

Input

Argument Name Description Required
value The IOC value for which to enrich. Required

Context Output

Path Type Description
Domain.Name String domain name
Domain.DNS String domain dns
Domain.Resolutions String domain resolutions
Domain.Subdomains String domain subdomains
Domain.WHOIS/History String domain whois
Domain.Malicious String domain malicious
IP.Address String ip address
IP.IpDetails String ip details
IP.RelatedHashes String ip related hashes
IP.WHOIS String ip whois
IP.Malicious String ip malicious
URL.Data String URL Data
URL.AntivirusDetectedEngines String URL Antivirus Detected Engines
URL.AntivirusDetectionRatio String URL Antivirus Detection Ratio
URL.AntivirusDetections String URL Antivirus Detections
URL.AntivirusScanDate String URL Antivirus Scan Date
URL.RelatedHashes String URL Related Hashes
URL.Malicious String URL Malicious
File.Name String File Name
File.AntivirusDetectedEngines String File Antivirus Detected Engines
File.AntivirusDetectionRatio String File Antivirus Detection Ratio
File.AntivirusDetections String File Antivirus Detections
File.AntivirusScanDate String File Antivirus Scan Date
File.Malicious String File Malicious
IntSights.Iocs.Type String IntSights Iocs Type
IntSights.Iocs.Value String IntSights Iocs Value
IntSights.Iocs.FirstSeen String IntSights Iocs First Seen
IntSights.Iocs.LastSeen String IntSights Iocs Last Seen
IntSights.Iocs.Status String IntSights Iocs Status
IntSights.Iocs.Severity String IntSights Iocs Severity
IntSights.Iocs.RelatedMalwares String IntSights Iocs Related Malwares
IntSights.Iocs.Sources String IntSights Iocs Sources
IntSights.Iocs.IsKnownIoc String IntSights Iocs Is Known Ioc
IntSightsIocs.RelatedThreatActors String IntSights Iocs Related Threat Actors
IntSights.Iocs.SystemTags String IntSights Iocs SystemTags
IntSights.Iocs.Tags String IntSights Iocs Tags
IntSights.Iocs.Whitelisted String IntSights Iocs Whitelisted
IntSights.Iocs.OriginalValue String IntSights Iocs Original Value
Domain.WHOIS String Domain WHOIS

Configuration parameters

  • server — Server URL (e.g. https://192.168.0.1) (required)
  • credentials — Credentials (required)
  • type — Alert type to fetch as incidents, allowed: "AttackIndication", "DataLeakage", "Phishing", "BrandSecurity", "ExploitableData", "VIP"
  • severity_level — Minimum Alert severity level to fetch incidents incidents from, allowed values are: 'All', 'Low', 'Medium','High'(Setting to All will fetch all incidents)
  • insecure — Trust any certificate (not secure)
  • proxy — Use system proxy settings
  • isFetch — Fetch incidents
  • first_fetch — First fetch timestamp (<number> <time unit>, e.g., 12 hours, 7 days)
  • max_fetch — Max fetch
  • incidentType — Incident type
  • mssp_sub_account_id — Sub Account ID (MSSP accounts only)

Commands (21)

  • intsights-add-comment-to-alert

    Adds a comment to a specified alert.

  • intsights-add-tag-to-alert

    Adds a tag to the alert.

  • intsights-alert-takedown-request

    Requests an alert takedown.

  • intsights-ask-the-analyst

    Sends a question to the IntSights analyst about the requested alert.

  • intsights-assign-alert

    Assigns an alert.

  • intsights-close-alert

    Closes an alert

  • intsights-get-alert-activities

    Returns alert activities.

  • intsights-get-alert-by-id

    Returns the alert object by alert ID.

  • intsights-get-alert-image

    Returns an image of an alert by ID.

  • intsights-get-alert-takedown-status

    Returns the alert takedown status.

  • intsights-get-alerts

    Returns alerts.

  • intsights-get-ioc-blocklist-status

    Returns the status of the IOC block list.

  • intsights-get-ioc-by-value

    Searches for an exact IOC value.

  • intsights-get-iocs

    Returns count totals of the available IOCs.

  • intsights-mssp-get-sub-accounts

    Returns all Managed Security Service Provider's (MSSP) sub accounts.

  • intsights-remove-tag-from-alert

    Removes a tag from the specified alert.

  • intsights-request-ioc-enrichment

    Request and receive enrichment of an IOC.

  • intsights-send-mail

    Sends an email containing a question and details of the alert.

  • intsights-unassign-alert

    Unassigns an alert from a user.

  • intsights-update-alert-severity

    Changes the severity of a specified alert.

  • intsights-update-ioc-blocklist-status

    Updates the IOC block list status.

from unittest.mock import Mock, patch
import pytest

import demistomock as demisto

INTSIGHTS_PARAMS = {
    'server': 'https://api.test.com',
    'proxy': 'no_proxy',
    'insecure': True,
    'credentials': {
        'identifier': "some_id",
        'password': 'some_password'
    }
}


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_add_comment(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    comment = 'Test Comment'
    mocker.patch.object(demisto, 'args', return_value={
        'alert-id': '5e7b0b5620d02a00085ab21e',
        'comment': comment
    })

    import IntSight

    mocker.patch('IntSight.http_request', Mock())
    IntSight.add_comment()
    assert (comment == mocker_results.call_args[0][0]['Contents']['Comment'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_add_tag(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    mocker.patch.object(demisto, 'args', return_value={
        'alert-id': '5e7b0b5620d02a00085ab21e',
        'tag-name': 'Test Tag'
    })

    import IntSight

    tag_id = '1234'
    mocker.patch('IntSight.http_request', return_value={
        'Details': {
            'Tags': [
                {
                    'Name': 'Test Tag',
                    '_id': tag_id
                }
            ]
        }
    })
    IntSight.add_tag()
    assert (tag_id == mocker_results.call_args[0][0]['Contents']['Tags']['ID'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_get_alert_takedown_status(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    mocker.patch.object(demisto, 'args', return_value={'alert-id': '5e7b0b5620d02a00085ab21e'})
    import IntSight

    mocker.patch('IntSight.http_request', return_value=MockResponse(text='text'))
    IntSight.get_alert_takedown_status()
    assert ('TakedownStatus' in mocker_results.call_args[0][0]['Contents'] and not None)


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_ask_analyst(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    question = 'What is the status?'
    mocker.patch.object(demisto, 'args', return_value={'alert-id': '5e7b0b5620d02a00085ab21e', 'question': question})

    import IntSight

    mocker.patch('IntSight.http_request')
    IntSight.ask_analyst()
    assert (question == mocker_results.call_args[0][0]['Contents']['Question'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_close_alert(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    reason = 'Solved Internally'
    mocker.patch.object(demisto, 'args', return_value={'alert-id': '5e7b0b5620d02a00085ab21e', 'reason': reason})

    import IntSight

    mocker.patch('IntSight.http_request')
    IntSight.close_alert()
    assert (reason == mocker_results.call_args[0][0]['Contents']['Closed']['Reason'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
def test_get_alert_image(mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)

    image_id = '123456789'
    mocker.patch.object(demisto, 'args', return_value={'image-id': image_id})

    import IntSight
    mocker.patch('IntSight.http_request', return_value=MockResponse(content='abc'))
    mocker_results = mocker.patch.object(IntSight, 'fileResult')

    mocker.patch('demistomock.results')
    IntSight.get_alert_image()
    assert (image_id + '-image.jpeg' == mocker_results.call_args[0][0])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_takedown_request(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    alert_id = '123456789'
    mocker.patch.object(demisto, 'args', return_value={'alert-id': alert_id})

    import IntSight

    mocker.patch('IntSight.http_request')
    IntSight.takedown_request()
    assert (alert_id == mocker_results.call_args[0][0]['Contents']['ID'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_get_ioc_blocklist_status(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    alert_id = '123456789'
    mocker.patch.object(demisto, 'args', return_value={'alert-id': alert_id})

    import IntSight

    mock_response = {
        "Value": "example.com",
        "Status": "Sent"
    }
    mocker.patch('IntSight.http_request', return_value=[mock_response])
    IntSight.get_ioc_blocklist_status()
    assert (mock_response in mocker_results.call_args[0][0]['Contents'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_search_for_ioc(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    value = 'test_value'
    mocker.patch.object(demisto, 'args', return_value={'value': value})

    import IntSight

    mock_response = {
        "firstSeen": "2018-07-20T01:00:49.000Z",
        "geolocation": "AU",
        "lastSeen": "2022-07-14T20:03:08.256Z",
        "lastUpdateDate": "2022-10-31T16:02:41.781Z",
        "relatedCampaigns": [],
        "relatedMalware": [
            "agent",
            "arkei",
            "zegost"
        ],
        "relatedThreatActors": [],
        "reportedFeeds": [
            {
                "confidenceLevel": 3,
                "id": "123123123",
                "name": "Cyber"
            },
            {
                "confidenceLevel": 3,
                "id": "123123",
                "name": "Cyber1"
            },
            {
                "confidenceLevel": 2,
                "id": "123123123123123",
                "name": "Cyber111"
            },
            {
                "confidenceLevel": 3,
                "id": "123123123123",
                "name": "Cyber11"
            }
        ],
        "score": 80,
        "severity": "High",
        "status": "Retired",
        "tags": [
            "njrat",
            "Installation"
        ],
        "type": "IpAddresses",
        "value": "test_value",
        "whitelisted": True
    }
    mocker.patch('IntSight.http_request', return_value=mock_response)
    IntSight.search_for_ioc()
    assert (value == mocker_results.call_args[0][0]['Contents']['value'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_remove_tag(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    tag_id = '12345'
    mocker.patch.object(demisto, 'args', return_value={'alert-id': '5e7b0b5620d02a00085ab21e', 'tag-id': tag_id})

    import IntSight

    mocker.patch('IntSight.http_request')
    IntSight.remove_tag()
    assert (tag_id == mocker_results.call_args[0][0]['Contents']['Tags']['ID'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_request_for_ioc_enrichment(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    value = "test_value.com"

    mocker.patch.object(demisto, 'args', return_value={'value': value})

    import IntSight

    mock_response = {
        "OriginalValue": value,
        "Status": "Done",
        "Data": {
            "Value": "securitywap.com",
            "Type": "Domains",
            "IsKnownIoc": "false",
            "Whitelisted": "false",
            "Tags": [],
            "SystemTags": [],
            "Sources": [],
            "Severity": {
                "Value": "Low"
            },
            "RelatedMalwares": [],
            "RelatedThreatActors": [],
            "DnsRecords": [
                {
                    "Value": "a.sinkhole.yourtrap.com.",
                    "Type": "CNAME",
                    "FirstResolved": "2017-06-10T04:44:48.000Z",
                    "LastResolved": "2019-06-09T15:08:50.000Z"
                },
            ],
            "Subdomains": [
                "www"
            ],
            "Whois": {
                "Current": {
                    "RegistrationDetails": {
                        "CreatedDate": "2017-06-09T10:47:02.000Z",
                        "UpdatedDate": "2018-06-09T10:47:02.000Z",
                        "ExpiresDate": "2019-06-09T10:47:02.000Z",
                        "Statuses": [],
                        "NameServers": [
                            "NS1.STAR-DOMAIN.JP",
                            "NS2.STAR-DOMAIN.JP",
                            "NS3.STAR-DOMAIN.JP"
                        ]
                    },
                    "RegistrantDetails": [
                        {
                            "Organization": "Netowl,Inc.",
                            "Name": "Star Domain",
                            "Email": "some_email",
                            "Telephone": "81752568553",
                            "Fax": "",
                            "City": "Kyoto",
                            "State": "Kyoto",
                            "Country": "JAPAN"
                        }
                    ]
                },
                "History": [
                    {
                        "RegistrationDetails": {
                            "CreatedDate": "2017-06-09T10:47:02.000Z",
                            "ExpiresDate": "2018-06-09T10:47:02.000Z",
                            "Statuses": [
                                "clientTransferProhibited"
                            ],
                            "NameServers": [
                                "NS1.STAR-DOMAIN.JP",
                                "NS2.STAR-DOMAIN.JP",
                                "NS3.STAR-DOMAIN.JP"
                            ]
                        },
                        "RegistrantDetails": [
                            {
                                "Organization": "Netowl,Inc.",
                                "Name": "Star Domain",
                                "Email": "some_email",
                                "Telephone": "81752568553",
                                "Fax": "",
                                "City": "Kyoto",
                                "State": "Kyoto",
                                "Country": "JAPAN"
                            },
                        ]
                    }
                ]
            },
            "Resolutions": [
                {
                    "ResolvedIpAddress": "some_ip",
                    "Location": "JP",
                    "ASN": "17506",
                    "Operator": "ARTERIA Networks Corporation",
                    "FirstResolved": "2015-07-29T18:46:24.000Z",
                    "LastResolved": "2016-08-02T01:12:51.000Z"
                }
            ]
        }
    }
    mocker.patch('IntSight.http_request', return_value=mock_response)
    IntSight.request_for_ioc_enrichment()
    assert (mock_response['OriginalValue'] == mocker_results.call_args[0][0]['Contents']['OriginalValue'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_send_mail(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)

    alert_id = '5e7b0b5620d02a00085ab21e'
    mocker.patch.object(demisto, 'args', return_value={
        'alert-id': alert_id,
        'emails': ['me@domain.com', 'you@domain.com'],
        'content': 'API Question'
    })

    import IntSight

    mocker.patch('IntSight.http_request')
    IntSight.send_mail()
    assert (alert_id == mocker_results.call_args[0][0]['Contents']['ID'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_unassign_alert(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)

    alert_id = '5e7b0b5620d02a00085ab21e'
    mocker.patch.object(demisto, 'args', return_value={
        'alert-id': alert_id
    })

    import IntSight

    mocker.patch('IntSight.http_request')
    IntSight.unassign_alert()
    assert (alert_id == mocker_results.call_args[0][0]['Contents']['ID'])


@patch.object(demisto, "results")
def test_change_severity(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)

    severity = 'Low'
    mocker.patch.object(demisto, 'args', return_value={
        'alert-id': '5e7b0b5620d02a00085ab21e',
        'severity': 'Low'
    })

    import IntSight

    mocker.patch('IntSight.http_request')
    IntSight.change_severity()
    assert (severity == mocker_results.call_args[0][0]['Contents']['Severity'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_update_ioc_blocklist_status(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)

    alert_id = '5e7b0b5620d02a00085ab21e'
    mocker.patch.object(demisto, 'args', return_value={
        'alert-id': alert_id,
        'type': 'Domains',
        'value': 'example.com',
        'blocklist-status': 'Sent'
    })

    import IntSight

    mocker.patch('IntSight.http_request')
    IntSight.update_ioc_blocklist_status()
    assert (alert_id == mocker_results.call_args[0][0]['Contents']['ID'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
def get_mssp_sub_accounts_http_response(method, path, **kwargs):
    if path == 'public/v1/account/used-assets':
        return {
            "AssetsLimit": 10,
            "AssetsCount": 1
        }
    elif path == 'public/v1/mssp/customers':
        return [
            {
                "_id": "123456789",
                "CompanyName": "Example",
                "Status": "Enabled"
            }
        ]
    else:
        return None


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch('IntSight.http_request')
def run_mocked_https_request(mocked_http_request, action, side_effect=None, return_value=None):
    if side_effect:
        mocked_http_request.side_effect = side_effect
    else:
        mocked_http_request.return_value = side_effect

    action()


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_get_mssp_sub_accounts(mocker_results, mocker):
    INTSIGHTS_PARAMS['mssp_sub_account_id'] = '123456789'

    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)

    import IntSight

    run_mocked_https_request(
        action=IntSight.get_mssp_sub_accounts,
        side_effect=get_mssp_sub_accounts_http_response
    )
    assert (10 == mocker_results.call_args[0][0]['Contents'][0]['AssetsLimit'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_get_iocs(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    value = 'test_value'
    mocker.patch.object(demisto, 'args', return_value={'value': value})

    import IntSight

    mock_response = {
        "firstSeen": "2018-07-20T01:00:49.000Z",
        "geolocation": "AU",
        "lastSeen": "2022-07-14T20:03:08.256Z",
        "lastUpdateDate": "2022-10-31T16:02:41.781Z",
        "relatedCampaigns": [],
        "relatedMalware": [
            "agent",
            "arkei",
            "zegost"
        ],
        "relatedThreatActors": [],
        "reportedFeeds": [
            {
                "confidenceLevel": 3,
                "id": "123123123",
                "name": "Cyber"
            },
            {
                "confidenceLevel": 3,
                "id": "123123",
                "name": "Cyber1"
            },
            {
                "confidenceLevel": 2,
                "id": "123123123123123",
                "name": "Cyber111"
            },
            {
                "confidenceLevel": 3,
                "id": "123123123123",
                "name": "Cyber11"
            }
        ],
        "score": 80,
        "severity": "High",
        "status": "Retired",
        "tags": [
            "njrat",
            "Installation"
        ],
        "type": "IpAddresses",
        "value": value,
        "whitelisted": True
    }

    mocker.patch('IntSight.http_request', return_value=mock_response)
    IntSight.search_for_ioc()
    assert (value == mocker_results.call_args[0][0]['Contents']['value'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
def get_alerts_http_response(method, path, **kwargs):
    if path == 'public/v1/data/alerts/get-complete-alert/123456789':
        return {
            "_id": "123456789",
            "Assets": [
                {
                    "Type": "CompanyNames",
                    "Value": "Name"
                }
            ],
            "Assignees": [],
            "Details": {
                "Type": "Phishing",
                "SubType": "RegisteredSuspiciousDomain",
                "Title": "Alert's title",
                "Description": "Alert's description",
                "Severity": "High",
                "Images": [
                    "5b1576593a21b34c6d6e6195"
                ],
                "Source": {
                    "Type": "WHOIS servers",
                    "URL": "http://example.com",
                    "Email": "",
                    "NetworkType": "ClearWeb",
                    "Date": "2018-01-10T00:00:00.000Z"
                },
                "Tags": [
                    {
                        "CreatedBy": "API",
                        "Name": "Phishing",
                        "_id": "5acda9f68602ef0006b1b593"
                    }
                ],
                "RelatedIocs": [
                    "example.com"
                ]
            },
            "FoundDate": "2018-01-01T20:01:27.344Z",
            "UpdateDate": "2019-01-01T20:01:27.344Z",
            "TakedownStatus": "NotSent",
            "IsClosed": "false",
            "IsFlagged": "false"
        }
    elif path == 'public/v1/data/alerts/alerts-list':
        return [
            '123456789'
        ]
    else:
        return None


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_get_alerts(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)

    import IntSight

    alert_id = '123456789'
    run_mocked_https_request(
        action=IntSight.get_alerts,
        side_effect=get_alerts_http_response
    )
    assert (alert_id == mocker_results.call_args[0][0]['Contents'][0]['ID'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_get_alert_by_id(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    mocker.patch.object(demisto, 'args', return_value={'alert-id': '5e7b0b5620d02a00085ab21e'})

    import IntSight

    complete_alert = {
        "_id": "5b154ceb3a21b34c6d6e6194",
        "Assets": [
            {
                "Type": "CompanyNames",
                "Value": "Name"
            }
        ],
        "Assignees": [],
        "Details": {
            "Type": "Phishing",
            "SubType": "RegisteredSuspiciousDomain",
            "Title": "Alert's title",
            "Description": "Alert's description",
            "Severity": "High",
            "Images": [
                "5b1576593a21b34c6d6e6195"
            ],
            "Source": {
                "Type": "WHOIS servers",
                "URL": "http://example.com",
                "Email": "",
                "NetworkType": "ClearWeb",
                "Date": "2018-01-10T00:00:00.000Z"
            },
            "Tags": [
                {
                    "CreatedBy": "API",
                    "Name": "Phishing",
                    "_id": "5acda9f68602ef0006b1b593"
                }
            ],
            "RelatedIocs": [
                "example.com"
            ]
        },
        "FoundDate": "2018-01-01T20:01:27.344Z",
        "UpdateDate": "2019-01-01T20:01:27.344Z",
        "TakedownStatus": "NotSent",
        "IsClosed": "false",
        "IsFlagged": "false"
    }
    mocker.patch('IntSight.http_request', return_value=complete_alert)
    IntSight.get_alert_by_id()
    assert (complete_alert['_id'] == mocker_results.call_args[0][0]['Contents']['ID'])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_get_alert_activity(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    mocker.patch.object(demisto, 'args', return_value={'alert-id': '5e7b0b5620d02a00085ab21e'})

    import IntSight

    activity = {
        "Type": "AlertRead",
        "Initiator": "5b1641983a21b34c6d6e6197",
        "CreatedDate": "2018-01-01T13:09:39.305Z",
        "UpdateDate": "2018-01-01T13:09:39.305Z",
        "_id": "5e7b0b5620d02a00085ab21e",
        "AdditionalInformation": {
            "RemediationBlocklistUpdate": [],
            "AskTheAnalyst": {
                "Replies": []
            },
            "Mail": {
                "Replies": []
            }
        },
        "ReadBy": [
            "5b1641983a21b34c6d6e6897"
        ],
        "SubTypes": []
    }

    mocker.patch('IntSight.http_request', return_value=[
        {
            'ID': '5e7b0b5620d02a00085ab21e',
            'Activities': [
                activity
            ]
        }
    ])
    IntSight.get_alert_activity()
    assert ('Activities' in mocker_results.call_args[0][0]['Contents'][0])


@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@patch.object(demisto, "results")
def test_assign_alert(mocker_results, mocker):
    mocker.patch.object(demisto, 'command', return_value='intsights-test-action')
    mocker.patch.object(demisto, 'params', return_value=INTSIGHTS_PARAMS)
    mocker.patch.object(demisto, 'args', return_value={
        'alert-id': '5e7b0b5620d02a00085ab21e',
        'assignee-email': 'email@domain.com',
        'is-mssp-optional': 'false'
    })

    import IntSight

    assignee_id = '12345'
    mocker.patch('IntSight.http_request', return_value=[
        {
            "Email": "email@domain.com",
            "_id": assignee_id
        }
    ])
    IntSight.assign_alert()
    assert (assignee_id == mocker_results.call_args[0][0]['Contents']['Assignees.AssigneeID'])


class MockResponse:
    def __init__(self, text='', content=''):
        self.text = text
        self.content = content