Lacework

Lacework provides end-to-end cloud security automation for AWS, Azure, and GCP with a comprehensive view of risks across cloud workloads and containers.

Analytics & SIEM · Lacework

Details

IDLacework
ProviderFortinet
CategoryAnalytics & SIEM
From Version5.0.0
Docker Imagedemisto/lacework:1.0.0.10133006
Supported ModulesAgentix XSIAM

README

Lacework provides end-to-end cloud security automation for AWS, Azure, and GCP with a comprehensive view of risks across cloud workloads and containers.
This integration was integrated and tested with version 2 of the Lacework APIs

Configure Lacework in Cortex

Parameter Required
Lacework Account Name (i.e. Sub-Domain of the URL: <ACCOUNT>.lacework.net) True
Lacework Sub-Account Name (If Required) False
Lacework API Key True
Lacework API Secret True
Lacework Alert Severity Threshold True
Fetch incidents False
Incident type False
Lacework Alert History to Import (in days) 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.

lw-get-alert-details


Fetch details for a specific Alert in Lacework.

Base Command

lw-get-alert-details

Input

Argument Name Description Required
alert_id The Lacework Alert ID to be retrieved. Required
scope The scope of data to retrieve from Lacework for the specified Alert ID. Possible values are: Details, Investigation, Events, RelatedAlerts, Integrations, Timeline. Default is Details. Optional

Context Output

Path Type Description
Lacework.Alert.startTime Date The start time of the alert.
Lacework.Alert.endTime Date The end time of the alert.
Lacework.Alert.alertType String The type of the alert.
Lacework.Alert.alertName String The name of the alert.
Lacework.Alert.alertId String The ID of the alert.
Lacework.Alert.severity String The severity of the alert.
Lacework.Alert.status String The status of the alert.
Lacework.Alert.alertInfo.description String The alert description provides why the potential threat occurred.
Lacework.Alert.alertInfo.subject String The alert subject. In some cases, the alert subject can be the same as the alert name.
Lacework.Alert.entityMap Unknown The entity map for the alert.

lw-get-aws-compliance-assessment


Fetch the latest AWS compliance data from Lacework.

Base Command

lw-get-aws-compliance-assessment

Input

Argument Name Description Required
account_id The AWS Account ID to use when fetching compliance data. Required
report_type The Report Type to fetch from Lacework. Possible values are: AWS_CIS_S3, HIPAA, ISO_2700, NIST_800-53_Rev4, NIST_800-171_Rev2, PCI, SOC. Default is AWS_CIS_S3. Optional
rec_id Setting the ‘rec_id’ will filter compliance results for the specified Recommendation ID. Optional

Context Output

Path Type Description
Lacework.Compliance.reportType String The Type of the compliance report.
Lacework.Compliance.reportTitle String The Title of the compliance report.
Lacework.Compliance.recommendations.SUPPRESSIONS String The suppressions for the current recommendation.
Lacework.Compliance.recommendations.INFO_LINK String The URL to the compliance violation information.
Lacework.Compliance.recommendations.ASSESSED_RESOURCE_COUNT Number The number of assessed resources for the violation.
Lacework.Compliance.recommendations.STATUS String The status of the recommendation.
Lacework.Compliance.recommendations.REC_ID String The ID of the recommendation.
Lacework.Compliance.recommendations.CATEGORY String The category of the recommendation
Lacework.Compliance.recommendations.SERVICE String The service associated with the recommendation.
Lacework.Compliance.recommendations.TITLE String The title of the recommendation.
Lacework.Compliance.recommendations.VIOLATIONS.region String The region of the violating resource.
Lacework.Compliance.recommendations.VIOLATIONS.reasons String The reason for the violation.
Lacework.Compliance.recommendations.VIOLATIONS.resource String The resource causing the violation.
Lacework.Compliance.recommendations.RESOURCE_COUNT Number The number of resources associated with the compliance failure.
Lacework.Compliance.recommendations.SEVERITY Number The severity of the compliance failure.
Lacework.Compliance.summary.NUM_RECOMMENDATIONS Number The number of recommendations contained in the report.
Lacework.Compliance.summary.NUM_SEVERITY_2_NON_COMPLIANCE Number The number of Severity 2 compliance violations.
Lacework.Compliance.summary.NUM_SEVERITY_4_NON_COMPLIANCE Number The number of Severity 4 compliance violations.
Lacework.Compliance.summary.NUM_SEVERITY_1_NON_COMPLIANCE Number The number of severity 1 compliance violations.
Lacework.Compliance.summary.NUM_COMPLIANT Number The number of compliant resources.
Lacework.Compliance.summary.NUM_SEVERITY_3_NON_COMPLIANCE Number The number of severity 3 compliance violations.
Lacework.Compliance.summary.ASSESSED_RESOURCE_COUNT Number The number of assessed resources.
Lacework.Compliance.summary.NUM_SUPPRESSED Number The number of suppressed alerts.
Lacework.Compliance.summary.NUM_SEVERITY_5_NON_COMPLIANCE Number The number of severity 5 compliance violations.
Lacework.Compliance.summary.NUM_NOT_COMPLIANT Number The number of resources not in compliance.
Lacework.Compliance.summary.VIOLATED_RESOURCE_COUNT Number The number of resources violating compliance.
Lacework.Compliance.summary.SUPPRESSED_RESOURCE_COUNT Number The number of resources with suppressed violations.
Lacework.Compliance.accountId String The AWS account ID.
Lacework.Compliance.accountAlias String The AWS account alias.
Lacework.Compliance.tenantId String The Azure tenant ID.
Lacework.Compliance.tenantName String The Azure tenant name.
Lacework.Compliance.subscriptionId String The Azure subscription ID.
Lacework.Compliance.subscriptionName String The Azure subscription name.
Lacework.Compliance.projectId String The GCP project ID.
Lacework.Compliance.projectName String The GCP project name.
Lacework.Compliance.organizationId String The GCP organization ID.
Lacework.Compliance.organizationName String The GCP organization name.
Lacework.Compliance.reportTime String The time the report completed.

lw-get-azure-compliance-assessment


Fetch the latest Azure compliance data from Lacework.

Base Command

lw-get-azure-compliance-assessment

Input

Argument Name Description Required
tenant_id The Azure Tenant ID to use when fetching compliance data. Required
subscription_id The Azure Subscription ID to use when fetching compliance data. Required
report_type The Report Type to fetch from Lacework. Possible values are: AZURE_CIS, AZURE_PCI, AZURE_SOC. Default is AZURE_CIS. Optional
rec_id Setting the ‘rec_id’ will filter compliance results for the specified Recommendation ID. Optional

Context Output

Path Type Description
Lacework.Compliance.reportType String The Type of the compliance report.
Lacework.Compliance.reportTitle String The Title of the compliance report.
Lacework.Compliance.recommendations.SUPPRESSIONS String The suppressions for the current recommendation.
Lacework.Compliance.recommendations.INFO_LINK String The URL to the compliance violation information.
Lacework.Compliance.recommendations.ASSESSED_RESOURCE_COUNT Number The number of assessed resources for the violation.
Lacework.Compliance.recommendations.STATUS String The status of the recommendation.
Lacework.Compliance.recommendations.REC_ID String The ID of the recommendation.
Lacework.Compliance.recommendations.CATEGORY String The category of the recommendation
Lacework.Compliance.recommendations.SERVICE String The service associated with the recommendation.
Lacework.Compliance.recommendations.TITLE String The title of the recommendation.
Lacework.Compliance.recommendations.VIOLATIONS.region String The region of the violating resource.
Lacework.Compliance.recommendations.VIOLATIONS.reasons String The reason for the violation.
Lacework.Compliance.recommendations.VIOLATIONS.resource String The resource causing the violation.
Lacework.Compliance.recommendations.RESOURCE_COUNT Number The number of resources associated with the compliance failure.
Lacework.Compliance.recommendations.SEVERITY Number The severity of the compliance failure.
Lacework.Compliance.summary.NUM_RECOMMENDATIONS Number The number of recommendations contained in the report.
Lacework.Compliance.summary.NUM_SEVERITY_2_NON_COMPLIANCE Number The number of Severity 2 compliance violations.
Lacework.Compliance.summary.NUM_SEVERITY_4_NON_COMPLIANCE Number The number of Severity 4 compliance violations.
Lacework.Compliance.summary.NUM_SEVERITY_1_NON_COMPLIANCE Number The number of severity 1 compliance violations.
Lacework.Compliance.summary.NUM_COMPLIANT Number The number of compliant resources.
Lacework.Compliance.summary.NUM_SEVERITY_3_NON_COMPLIANCE Number The number of severity 3 compliance violations.
Lacework.Compliance.summary.ASSESSED_RESOURCE_COUNT Number The number of assessed resources.
Lacework.Compliance.summary.NUM_SUPPRESSED Number The number of suppressed alerts.
Lacework.Compliance.summary.NUM_SEVERITY_5_NON_COMPLIANCE Number The number of severity 5 compliance violations.
Lacework.Compliance.summary.NUM_NOT_COMPLIANT Number The number of resources not in compliance.
Lacework.Compliance.summary.VIOLATED_RESOURCE_COUNT Number The number of resources violating compliance.
Lacework.Compliance.summary.SUPPRESSED_RESOURCE_COUNT Number The number of resources with suppressed violations.
Lacework.Compliance.accountId String The AWS account ID.
Lacework.Compliance.accountAlias String The AWS account alias.
Lacework.Compliance.tenantId String The Azure tenant ID.
Lacework.Compliance.tenantName String The Azure tenant name.
Lacework.Compliance.subscriptionId String The Azure subscription ID.
Lacework.Compliance.subscriptionName String The Azure subscription name.
Lacework.Compliance.projectId String The GCP project ID.
Lacework.Compliance.projectName String The GCP project name.
Lacework.Compliance.organizationId String The GCP organization ID.
Lacework.Compliance.organizationName String The GCP organization name.
Lacework.Compliance.reportTime String The time the report completed.

lw-get-gcp-compliance-assessment


Fetch the latest GCP compliance data from Lacework.

Base Command

lw-get-gcp-compliance-assessment

Input

Argument Name Description Required
project_id The GCP Project ID to use when fetching compliance data. Required
report_type The Report Type to fetch from Lacework. Possible values are: GCP_CIS, GCP_PCI, GCP_SOC. Default is GCP_CIS. Optional
rec_id Setting the ‘rec_id’ will filter compliance results for the specified Recommendation ID. Optional

Context Output

Path Type Description
Lacework.Compliance.reportType String The Type of the compliance report.
Lacework.Compliance.reportTitle String The Title of the compliance report.
Lacework.Compliance.recommendations.SUPPRESSIONS String The suppressions for the current recommendation.
Lacework.Compliance.recommendations.INFO_LINK String The URL to the compliance violation information.
Lacework.Compliance.recommendations.ASSESSED_RESOURCE_COUNT Number The number of assessed resources for the violation.
Lacework.Compliance.recommendations.STATUS String The status of the recommendation.
Lacework.Compliance.recommendations.REC_ID String The ID of the recommendation.
Lacework.Compliance.recommendations.CATEGORY String The category of the recommendation
Lacework.Compliance.recommendations.SERVICE String The service associated with the recommendation.
Lacework.Compliance.recommendations.TITLE String The title of the recommendation.
Lacework.Compliance.recommendations.VIOLATIONS.region String The region of the violating resource.
Lacework.Compliance.recommendations.VIOLATIONS.reasons String The reason for the violation.
Lacework.Compliance.recommendations.VIOLATIONS.resource String The resource causing the violation.
Lacework.Compliance.recommendations.RESOURCE_COUNT Number The number of resources associated with the compliance failure.
Lacework.Compliance.recommendations.SEVERITY Number The severity of the compliance failure.
Lacework.Compliance.summary.NUM_RECOMMENDATIONS Number The number of recommendations contained in the report.
Lacework.Compliance.summary.NUM_SEVERITY_2_NON_COMPLIANCE Number The number of Severity 2 compliance violations.
Lacework.Compliance.summary.NUM_SEVERITY_4_NON_COMPLIANCE Number The number of Severity 4 compliance violations.
Lacework.Compliance.summary.NUM_SEVERITY_1_NON_COMPLIANCE Number The number of severity 1 compliance violations.
Lacework.Compliance.summary.NUM_COMPLIANT Number The number of compliant resources.
Lacework.Compliance.summary.NUM_SEVERITY_3_NON_COMPLIANCE Number The number of severity 3 compliance violations.
Lacework.Compliance.summary.ASSESSED_RESOURCE_COUNT Number The number of assessed resources.
Lacework.Compliance.summary.NUM_SUPPRESSED Number The number of suppressed alerts.
Lacework.Compliance.summary.NUM_SEVERITY_5_NON_COMPLIANCE Number The number of severity 5 compliance violations.
Lacework.Compliance.summary.NUM_NOT_COMPLIANT Number The number of resources not in compliance.
Lacework.Compliance.summary.VIOLATED_RESOURCE_COUNT Number The number of resources violating compliance.
Lacework.Compliance.summary.SUPPRESSED_RESOURCE_COUNT Number The number of resources with suppressed violations.
Lacework.Compliance.accountId String The AWS account ID.
Lacework.Compliance.accountAlias String The AWS account alias.
Lacework.Compliance.tenantId String The Azure tenant ID.
Lacework.Compliance.tenantName String The Azure tenant name.
Lacework.Compliance.subscriptionId String The Azure subscription ID.
Lacework.Compliance.subscriptionName String The Azure subscription name.
Lacework.Compliance.projectId String The GCP project ID.
Lacework.Compliance.projectName String The GCP project name.
Lacework.Compliance.organizationId String The GCP organization ID.
Lacework.Compliance.organizationName String The GCP organization name.
Lacework.Compliance.reportTime String The time the report completed.

lw-get-gcp-projects-by-organization


Fetch a list of GCP projects that are under an organization.

Base Command

lw-get-gcp-projects-by-organization

Input

Argument Name Description Required
organization_id The GCP Organization ID to use when fetching projects data. Required

Context Output

Path Type Description
Lacework.GCP.organization String The GCP Organization.
Lacework.GCP.projects String The GCP Projects associated to the Organization.

lw-get-compliance-report


Fetch a specified compliance report from Lacework.

Base Command

lw-get-compliance-report

Input

Argument Name Description Required
primary_query_id The primary ID that is used to fetch the report; for example, AWS Account ID or Azure Tenant ID. Optional
secondary_query_id The secondary ID that is used to fetch the report; for example, GCP Project ID or Azure Subscription ID. Optional
report_name The report definition’s name that is used when generating the report. Optional
report_type The report’s notification type; for example, AZURE_NIST_CSF. Possible values are: AZURE_CIS, AZURE_CIS_131, AZURE_SOC, AZURE_SOC_Rev2, AZURE_PCI, AZURE_PCI_Rev2, AZURE_ISO_27001, AZURE_NIST_CSF, AZURE_NIST_800_53_REV5, AZURE_NIST_800_171_REV2, AZURE_HIPAA, AWS_CIS_S3, NIST_800-53_Rev4, NIST_800-171_Rev2, ISO_2700, HIPAA, SOC, AWS_SOC_Rev2, GCP_HIPAA, PCI, GCP_CIS, GCP_SOC, GCP_CIS12, GCP_K8S, GCP_PCI_Rev2, GCP_SOC_Rev2, GCP_HIPAA_Rev2, GCP_ISO_27001, GCP_NIST_CSF, GCP_NIST_800_53_REV4, GCP_NIST_800_171_REV2, GCP_PCI, AWS_CIS_14, GCP_CIS13, AWS_CMMC_1.02, AWS_HIPAA, AWS_ISO_27001:2013, AWS_NIST_CSF, AWS_NIST_800-171_rev2, AWS_NIST_800-53_rev5, AWS_PCI_DSS_3.2.1, AWS_SOC_2, LW_AWS_SEC_ADD_1_0. Default is LW_AWS_SEC_ADD_1_0. Optional
template_name The template’s name that is used for the report; for example, Default. Default is Default. Required
rec_id Setting the ‘rec_id’ will filter compliance results for the specified Recommendation ID. Optional

Context Output

Path Type Description
Lacework.Compliance.reportType String The Type of the compliance report.
Lacework.Compliance.reportTitle String The Title of the compliance report.
Lacework.Compliance.recommendations.SUPPRESSIONS String The suppressions for the current recommendation.
Lacework.Compliance.recommendations.INFO_LINK String The URL to the compliance violation information.
Lacework.Compliance.recommendations.ASSESSED_RESOURCE_COUNT Number The number of assessed resources for the violation.
Lacework.Compliance.recommendations.STATUS String The status of the recommendation.
Lacework.Compliance.recommendations.REC_ID String The ID of the recommendation.
Lacework.Compliance.recommendations.CATEGORY String The category of the recommendation
Lacework.Compliance.recommendations.SERVICE String The service associated with the recommendation.
Lacework.Compliance.recommendations.TITLE String The title of the recommendation.
Lacework.Compliance.recommendations.VIOLATIONS.region String The region of the violating resource.
Lacework.Compliance.recommendations.VIOLATIONS.reasons String The reason for the violation.
Lacework.Compliance.recommendations.VIOLATIONS.resource String The resource causing the violation.
Lacework.Compliance.recommendations.RESOURCE_COUNT Number The number of resources associated with the compliance failure.
Lacework.Compliance.recommendations.SEVERITY Number The severity of the compliance failure.
Lacework.Compliance.summary.NUM_RECOMMENDATIONS Number The number of recommendations contained in the report.
Lacework.Compliance.summary.NUM_SEVERITY_2_NON_COMPLIANCE Number The number of Severity 2 compliance violations.
Lacework.Compliance.summary.NUM_SEVERITY_4_NON_COMPLIANCE Number The number of Severity 4 compliance violations.
Lacework.Compliance.summary.NUM_SEVERITY_1_NON_COMPLIANCE Number The number of severity 1 compliance violations.
Lacework.Compliance.summary.NUM_COMPLIANT Number The number of compliant resources.
Lacework.Compliance.summary.NUM_SEVERITY_3_NON_COMPLIANCE Number The number of severity 3 compliance violations.
Lacework.Compliance.summary.ASSESSED_RESOURCE_COUNT Number The number of assessed resources.
Lacework.Compliance.summary.NUM_SUPPRESSED Number The number of suppressed alerts.
Lacework.Compliance.summary.NUM_SEVERITY_5_NON_COMPLIANCE Number The number of severity 5 compliance violations.
Lacework.Compliance.summary.NUM_NOT_COMPLIANT Number The number of resources not in compliance.
Lacework.Compliance.summary.VIOLATED_RESOURCE_COUNT Number The number of resources violating compliance.
Lacework.Compliance.summary.SUPPRESSED_RESOURCE_COUNT Number The number of resources with suppressed violations.
Lacework.Compliance.accountId String The AWS account ID.
Lacework.Compliance.accountAlias String The AWS account alias.
Lacework.Compliance.tenantId String The Azure tenant ID.
Lacework.Compliance.tenantName String The Azure tenant name.
Lacework.Compliance.subscriptionId String The Azure subscription ID.
Lacework.Compliance.subscriptionName String The Azure subscription name.
Lacework.Compliance.projectId String The GCP project ID.
Lacework.Compliance.projectName String The GCP project name.
Lacework.Compliance.organizationId String The GCP organization ID.
Lacework.Compliance.organizationName String The GCP organization name.
Lacework.Compliance.reportTime String The time the report completed.

lw-get-container-vulnerabilities


Fetch container vulnerability information from Lacework.

Base Command

lw-get-container-vulnerabilities

Input

Argument Name Description Required
start_time A “%Y-%m-%dT%H:%M:%SZ” structured timestamp to begin from. (ex. “2020-01-01T01:10:00Z”). Optional
end_time A “%Y-%m-%dT%H:%M:%SZ” structured timestamp to end at. (ex. “2020-01-01T01:10:00Z”). Optional
filters An array of objects to add information to refine your search results. Optional
returns An array of strings to specify which top-level fields of the response schema you want to receive. Optional
limit An integer representing a limit on the number or results to return. Optional

Context Output

Path Type Description
Lacework.Vulnerability.Container.evalCtx.exception_props String The exception properties that were applied in the evaluation
Lacework.Vulnerability.Container.evalCtx.image_info Date The image information for the container scanned in the evaluation
Lacework.Vulnerability.Container.evalCtx.integration_props String The properties of the integration that performed the evaluation
Lacework.Vulnerability.Container.evalCtx.is_reeval Boolean A boolean representing whether the evaluation was a re-evaluation
Lacework.Vulnerability.Container.evalCtx.request_source String The source of the evaluation request
Lacework.Vulnerability.Container.evalCtx.scan_batch_id String The scan batch ID for the evaluation
Lacework.Vulnerability.Container.evalCtx.scan_request_props String The scan request properties for the evaluation
Lacework.Vulnerability.Container.evalCtx.vuln_batch_id String The vulnerability batch ID for the evaluation
Lacework.Vulnerability.Container.evalCtx.vuln_created_time Date The time at which the vulnerability was created
Lacework.Vulnerability.Container.featureKey.name String The name of the package identified in the evaluation
Lacework.Vulnerability.Container.featureKey.namespace String The namespace of the package identified in the evaluation
Lacework.Vulnerability.Container.featureKey.version String The version of the package identified in the evaluation
Lacework.Vulnerability.Container.featureProps.feed String The type of data feed used in the evaluation
Lacework.Vulnerability.Container.featureProps.introduced_in String The Dockerfile command which introduced the vulnerability
Lacework.Vulnerability.Container.featureProps.layer String The SHA256 hash of the layer which introduced the vulnerability
Lacework.Vulnerability.Container.featureProps.src String The path within the container identifying the source of the vulnerability data
Lacework.Vulnerability.Container.featureProps.version_format String The format of the version data for the vulnerable package
Lacework.Vulnerability.Container.fixInfo.fix_available Number An integer representing whether a fix is available for the vulnerability
Lacework.Vulnerability.Container.fixInfo.fixed_version String The version in which the vulnerability is fixed for the CVE and package
Lacework.Vulnerability.Container.imageId String The image ID of the container identified in the evaluation
Lacework.Vulnerability.Container.severity String The severity of the vulnerability identified in the evaluation
Lacework.Vulnerability.Container.startTime Date The start time for the vulnerability evaluation
Lacework.Vulnerability.Container.status String The status of the vulnerability identified in the evaluation
Lacework.Vulnerability.Container.vulnId String The vulnerability ID (CVE, ALAS, etc.)
Lacework.Vulnerability.Container.vulnHash String A unique hash of all data contained in the vulnerability

lw-get-host-vulnerabilities


Fetch host vulnerability information from Lacework.

Base Command

lw-get-host-vulnerabilities

Input

Argument Name Description Required
start_time A “%Y-%m-%dT%H:%M:%SZ” structured timestamp to begin from. (ex. “2020-01-01T01:10:00Z”). Optional
end_time A “%Y-%m-%dT%H:%M:%SZ” structured timestamp to end at. (ex. “2020-01-01T01:10:00Z”). Optional
filters An array of objects to add information to refine your search results. Optional
returns An array of strings to specify which top-level fields of the response schema you want to receive. Optional
limit An integer representing a limit on the number or results to return. Optional

Context Output

Path Type Description
Lacework.Vulnerability.Host.cveProps.description String The CVE Properties description
Lacework.Vulnerability.Host.cveProps.link String The CVE Properties description URL
Lacework.Vulnerability.Host.endTime Date The end time for the vulnerability evaluation period
Lacework.Vulnerability.Host.evalCtx.exception_props.status String The status of any exception properties for the evaluation
Lacework.Vulnerability.Host.evalCtx.hostname String The hostname of the host assessed in the evaluation
Lacework.Vulnerability.Host.evalCtx.mc_eval_guid String The GUID for the evaluation
Lacework.Vulnerability.Host.featureKey.name String The name of the package identified in the evaluation
Lacework.Vulnerability.Host.featureKey.namespace String The namespace of the package identified in the evaluation
Lacework.Vulnerability.Host.featureKey.package_active Number An integer representing whether the package is Active on the host
Lacework.Vulnerability.Host.featureKey.version_installed String The version of the package identified in the evaluation
Lacework.Vulnerability.Host.fixInfo.fix_available String An integer representing whether a fix is available for the vulnerability
Lacework.Vulnerability.Host.fixInfo.fixed_version String The version in which the vulnerability is fixed for the CVE and package
Lacework.Vulnerability.Host.machineTags String A string representing the machine tags in key/value pairs
Lacework.Vulnerability.Host.mid String The machine ID for the host identified in the evaluation
Lacework.Vulnerability.Host.severity String The severity of the vulnerability identified in the evaluation
Lacework.Vulnerability.Host.startTime Date The start time for the vulnerability evaluation period
Lacework.Vulnerability.Host.status String The status of the vulnerability identified in the evaluation
Lacework.Vulnerability.Host.vulnId String The vulnerability ID (CVE, ALAS, etc.)
Lacework.Vulnerability.Host.vulnHash String A unique hash of all data contained in the vulnerability

Configuration parameters

  • lacework_account — Lacework Account Name (i.e. Sub-Domain of the URL: <ACCOUNT>.lacework.net) (required)
  • lacework_subaccount — Lacework Sub-Account Name (If Required)
  • lacework_api_key — Lacework API Key (required)
  • lacework_api_secret — Lacework API Secret (required)
  • lacework_event_severity — Lacework Alert Severity Threshold (required)
  • isFetch — Fetch incidents
  • incidentType — Incident type
  • incidentFetchInterval — Incidents Fetch Interval
  • lacework_event_history — Lacework Alert History to Import (in days)

Commands (8)

  • lw-get-alert-details

    Fetch details for a specific Alert in Lacework.

  • lw-get-aws-compliance-assessment

    Fetch the latest AWS compliance data from Lacework.

  • lw-get-azure-compliance-assessment

    Fetch the latest Azure compliance data from Lacework.

  • lw-get-compliance-report

    Fetch a specified compliance report from Lacework.

  • lw-get-container-vulnerabilities

    Fetch container vulnerability information from Lacework.

  • lw-get-gcp-compliance-assessment

    Fetch the latest GCP compliance data from Lacework.

  • lw-get-gcp-projects-by-organization

    Fetch a list of GCP projects that are under an organization.

  • lw-get-host-vulnerabilities

    Fetch host vulnerability information from Lacework.

import ast
import hashlib
import json
from datetime import UTC, datetime, timedelta

import demistomock as demisto  # noqa: F401
from CommonServerPython import *  # noqa: F401
from laceworksdk import LaceworkClient
from laceworksdk.exceptions import ApiError

handle_proxy()

""" GLOBAL VARS """
LACEWORK_ACCOUNT = demisto.params().get("lacework_account")
LACEWORK_SUBACCOUNT = demisto.params().get("lacework_subaccount", None)
LACEWORK_API_KEY = demisto.params()["lacework_api_key"]
LACEWORK_API_SECRET = demisto.params()["lacework_api_secret"]
LACEWORK_ALERT_SEVERITY = demisto.params()["lacework_event_severity"]
LACEWORK_ALERT_HISTORY_DAYS = demisto.params()["lacework_event_history"]

LACEWORK_DATE_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
LACEWORK_ROW_LIMIT = 500000

try:
    if LACEWORK_SUBACCOUNT:
        lw_client = LaceworkClient(
            account=LACEWORK_ACCOUNT, subaccount=LACEWORK_SUBACCOUNT, api_key=LACEWORK_API_KEY, api_secret=LACEWORK_API_SECRET
        )
    else:
        lw_client = LaceworkClient(account=LACEWORK_ACCOUNT, api_key=LACEWORK_API_KEY, api_secret=LACEWORK_API_SECRET)
except Exception as e:
    demisto.results(f"Lacework API authentication failed. Please validate Account, \
                    Sub-Account, API Key, and API Secret. Error: {e}")

""" HELPER FUNCTIONS """


def get_alert_severity_int(sev_string):
    """
    Convert the Alert Severity string to the appropriate integer
    """

    sev_string = sev_string.lower()

    if sev_string == "critical":
        return 1
    elif sev_string == "high":
        return 2
    elif sev_string == "medium":
        return 3
    elif sev_string == "low":
        return 4
    elif sev_string in ("info", "informational"):
        return 5
    else:
        raise Exception(f"Invalid Alert Severity Threshold was defined: {sev_string}")


def create_entry(title, data, ec, human_readable=None):
    """
    Simplify the output/contents
    """

    if human_readable is None:
        human_readable = data

    return {
        "ContentsFormat": formats["json"],
        "Type": entryTypes["note"],
        "Contents": data,
        "ReadableContentsFormat": formats["markdown"],
        "HumanReadable": tableToMarkdown(title, human_readable) if data else "No result were found",
        "EntryContext": ec,
    }


def create_search_json(start_time, end_time, filters, returns, time_delta=None):
    """
    Create a properly formatted JSON object with search parameters
    """

    json_request = {}

    now = datetime.now(tz=UTC)

    if time_delta is None:
        time_delta = timedelta(days=1)

    if start_time is None:
        start_time = now - time_delta
        start_time = start_time.strftime(LACEWORK_DATE_FORMAT)

    if end_time is None:
        end_time = now.strftime(LACEWORK_DATE_FORMAT)

    json_request["timeFilter"] = {"startTime": start_time, "endTime": end_time}

    if filters:
        json_request["filters"] = filters

    if returns:
        json_request["returns"] = returns

    return json_request


def create_vulnerability_ids(vulnerability_data):
    """
    Calculate Unique IDs for each vulnerability
    """

    for vulnerability in vulnerability_data:
        vulnerability_string = json.dumps(vulnerability).encode("utf-8")
        vulnerability["vulnHash"] = hashlib.new("md5", vulnerability_string, usedforsecurity=False).hexdigest()

    return vulnerability_data


def format_compliance_data(compliance_data, rec_id):
    """
    Simplify the output/contents for Compliance reports
    """

    if len(compliance_data["data"]) > 0:
        compliance_data = compliance_data["data"][0]

        # If the user wants to filter on a recommendation ID
        if rec_id:
            rec_id = argToList(rec_id)
            # Iterate through all recommendations, removing irrelevant ones
            for recommendation in compliance_data["recommendations"][:]:
                if recommendation["REC_ID"] not in rec_id:
                    compliance_data["recommendations"].remove(recommendation)

        # Build Human Readable Output
        readable_output = tableToMarkdown("Compliance Summary", compliance_data["summary"])

        ec = {"Lacework.Compliance(val.reportTime === obj.reportTime)": compliance_data}
        return {
            "ContentsFormat": formats["json"],
            "Type": entryTypes["note"],
            "Contents": compliance_data,
            "ReadableContentsFormat": formats["markdown"],
            "HumanReadable": readable_output,
            "EntryContext": ec,
        }
    else:
        return {"Type": entryTypes["error"], "ContentsFormat": formats["text"], "Contents": "No compliance data was returned."}


""" COMMANDS FUNCTIONS """


def get_aws_compliance_assessment():
    """
    Get the latest AWS compliance assessment
    """

    account_id = demisto.args().get("account_id")
    rec_id = demisto.args().get("rec_id")
    report_type = demisto.args().get("report_type", "AWS_CIS_S3")

    response = lw_client.reports.get(
        primary_query_id=account_id,
        format="json",
        type="COMPLIANCE",
        report_type=report_type,
        template_name="Default",
        latest=True,
    )

    results = format_compliance_data(response, rec_id)
    return_results(results)


def get_azure_compliance_assessment():
    """
    Get the latest Azure compliance assessment
    """

    tenant_id = demisto.args().get("tenant_id")
    subscription_id = demisto.args().get("subscription_id")
    rec_id = demisto.args().get("rec_id")
    report_type = demisto.args().get("report_type", "AZURE_CIS")

    response = lw_client.reports.get(
        primary_query_id=tenant_id,
        secondary_query_id=subscription_id,
        format="json",
        type="COMPLIANCE",
        report_type=report_type,
        template_name="Default",
        latest=True,
    )

    results = format_compliance_data(response, rec_id)
    return_results(results)


def get_gcp_compliance_assessment():
    """
    Get the latest GCP compliance assessment
    """

    project_id = demisto.args().get("project_id")
    rec_id = demisto.args().get("rec_id")
    report_type = demisto.args().get("report_type", "GCP_CIS")

    response = lw_client.reports.get(
        secondary_query_id=project_id,
        format="json",
        type="COMPLIANCE",
        report_type=report_type,
        template_name="Default",
        latest=True,
    )

    results = format_compliance_data(response, rec_id)
    return_results(results)


def get_gcp_projects_by_organization():
    """
    Get a list of GCP Projects that reside in an Organization
    """

    organization_id = demisto.args().get("organization_id")

    response = lw_client.configs.gcp_projects.get(org_id=organization_id)

    ec = {"Lacework.GCP(val.organization === obj.organization)": response["data"]}
    create_entry("Google Cloud Platform Projects for Organization " + str(organization_id), response["data"], ec)


def get_container_vulnerabilities():
    """
    Get Container Vulnerabilities
    """

    start_time = demisto.args().get("start_time", None)
    end_time = demisto.args().get("end_time", None)
    filters = demisto.args().get("filters", None)
    returns = demisto.args().get("returns", None)
    limit = int(demisto.args().get("limit", LACEWORK_ROW_LIMIT))

    if filters:
        filters = ast.literal_eval(filters)
    if returns:
        returns = ast.literal_eval(returns)

    json_request = create_search_json(start_time=start_time, end_time=end_time, filters=filters, returns=returns)

    try:
        response = lw_client.vulnerabilities.containers.search(json=json_request)

        response_data = []
        current_rows = 0
        for page in response:
            take = limit - current_rows
            response_data += page["data"][:take]
            response_data = create_vulnerability_ids(response_data)
            current_rows = len(response_data)
            if current_rows >= limit:
                break
    except ApiError as e:
        raise Exception(
            f"Error: {e}",
            "The vulnerability search parameters must follow the "
            "structure outlined in the Lacework API documentation: "
            "https://yourlacework.lacework.net/api/v2/docs#tag/Vulnerabilities",
        )

    ec = {"Lacework.Vulnerability.Container(val.vulnHash === obj.vulnHash)": response_data}
    return create_entry("Lacework Vulnerability Data for Containers", response_data, ec)


def get_host_vulnerabilities():
    """
    Get Host Vulnerabilities
    """

    start_time = demisto.args().get("start_time", None)
    end_time = demisto.args().get("end_time", None)
    filters = demisto.args().get("filters", None)
    returns = demisto.args().get("returns", None)
    limit = int(demisto.args().get("limit", LACEWORK_ROW_LIMIT))

    if filters:
        filters = ast.literal_eval(filters)
    if returns:
        returns = ast.literal_eval(returns)

    json_request = create_search_json(start_time=start_time, end_time=end_time, filters=filters, returns=returns)

    try:
        response = lw_client.vulnerabilities.hosts.search(json=json_request)

        response_data = []
        current_rows = 0
        for page in response:
            take = limit - current_rows
            response_data += page["data"][:take]
            response_data = create_vulnerability_ids(response_data)
            current_rows = len(response_data)
            if current_rows >= limit:
                break
    except ApiError as e:
        raise Exception(
            f"Error: {e}",
            "The vulnerability search parameters must follow the "
            "structure outlined in the Lacework API documentation: "
            "https://yourlacework.lacework.net/api/v2/docs#tag/Vulnerabilities",
        )

    ec = {"Lacework.Vulnerability.Host(val.vulnHash === obj.vulnHash)": response_data}
    return create_entry("Lacework Vulnerability Data for Hosts", response_data, ec)


def get_alert_details():
    """
    Get Alert Details
    """

    alert_id = demisto.args().get("alert_id")
    scope = demisto.args().get("scope", "Details")

    response = lw_client.alerts.get_details(alert_id, scope)

    ec = {"Lacework.Alert(val.alertId === obj.alertId)": response["data"]}
    return create_entry("Lacework Alert " + str(alert_id), response["data"], ec)


def get_compliance_report():
    """
    Get Compliance Report
    """

    primary_query_id = demisto.args().get("primary_query_id")
    secondary_query_id = demisto.args().get("secondary_query_id")
    report_name = demisto.args().get("report_name")
    report_type = demisto.args().get("report_type")
    template_name = demisto.args().get("template_name")

    # Optional filtering
    rec_id = demisto.args().get("rec_id")

    response = lw_client.reports.get(
        primary_query_id=primary_query_id,
        secondary_query_id=secondary_query_id,
        format="json",
        type="COMPLIANCE",
        report_name=report_name,
        report_type=report_type,
        template_name=template_name,
        latest=True,
    )

    results = format_compliance_data(response, rec_id)
    return_results(results)


def fetch_incidents():
    """
    Function to fetch incidents (alerts) from Lacework
    """

    # Make a placeholder for events
    new_incidents = []

    # Get data from the last run
    max_alert_id = demisto.getLastRun().get("max_alert_id", 0)

    now = datetime.now(tz=UTC)

    # Generate ISO8601 Timestamps
    end_time = now.strftime(LACEWORK_DATE_FORMAT)
    start_time = now - timedelta(days=int(LACEWORK_ALERT_HISTORY_DAYS))
    start_time = start_time.strftime(LACEWORK_DATE_FORMAT)

    # Get the alert severity threshold
    alert_severity_threshold = get_alert_severity_int(LACEWORK_ALERT_SEVERITY)

    # Get alerts from Lacework
    alerts_response = lw_client.alerts.get(start_time, end_time)
    alerts_data = alerts_response.get("data", [])

    temp_max_alert_id = max_alert_id

    # Iterate through all alerts
    for alert in alerts_data:
        # Convert the current Alert ID to an integer
        alert_id = int(alert["alertId"])
        # Get the numeric value for severity
        alert_severity = get_alert_severity_int(alert["severity"])

        # If the alert is severe enough, and If the Alert ID is newer than we've imported, then add it
        if alert_severity <= alert_severity_threshold and alert_id > max_alert_id:
            # Store our new max Alert ID
            if alert_id > temp_max_alert_id:
                temp_max_alert_id = alert_id

            # Get the event details from Lacework
            alert_details = lw_client.alerts.get_details(alert["alertId"], "Details")

            incident = {
                "name": "Lacework Event: " + alert["alertType"],
                "occurred": alert["startTime"],
                "rawJSON": json.dumps(alert_details["data"]),
            }

            new_incidents.append(incident)

    max_alert_id = temp_max_alert_id

    demisto.setLastRun({"max_alert_id": max_alert_id})
    demisto.incidents(new_incidents)


""" EXECUTION CODE """


try:
    command = demisto.command()
    demisto.debug(f"Command being called is {command}")
    if demisto.command() == "test-module":
        # This is the call made when pressing the integration test button.
        try:
            demisto.debug('Getting User Profile for "test-module" run')
            response = lw_client.user_profile.get()
            demisto.debug(response)

            keys = {"username", "url", "accounts"}
            if keys.issubset(response["data"][0].keys()):
                demisto.results("ok")
        except Exception as error:
            demisto.results(error)
    elif demisto.command() == "lw-get-aws-compliance-assessment":
        demisto.results(get_aws_compliance_assessment())
    elif demisto.command() == "lw-get-azure-compliance-assessment":
        demisto.results(get_azure_compliance_assessment())
    elif demisto.command() == "lw-get-gcp-compliance-assessment":
        demisto.results(get_gcp_compliance_assessment())
    elif demisto.command() == "lw-get-gcp-projects-by-organization":
        demisto.results(get_gcp_projects_by_organization())
    elif demisto.command() == "lw-get-container-vulnerabilities":
        demisto.results(get_container_vulnerabilities())
    elif demisto.command() == "lw-get-host-vulnerabilities":
        demisto.results(get_host_vulnerabilities())
    elif demisto.command() == "lw-get-compliance-report":
        demisto.results(get_compliance_report())
    elif demisto.command() == "lw-get-alert-details":
        demisto.results(get_alert_details())
    elif demisto.command() == "fetch-incidents":
        demisto.results(fetch_incidents())
except Exception as e:
    LOG(e)
    LOG.print_log()
    raise