Skip to main content

Community-developed Python SDK for the Lacework APIs

Project description

Lacework Python SDK

Build Status Downloads

laceworksdk is a community developed Python library for interacting with the Lacework APIs.

The purpose of this library is to simplify the common tasks required for interacting with the Lacework API, and allow users write simple code to automate tasks related to their Lacework instance(s). From data retrieval to configuration, this library aims to expose all publicly available APIs. For example, the following code would authenticate, fetch events, fetch host vulnerabilities, and fetch container vulnerabilities. The latest version of the SDK supports expressive searches as enabled by v2 of the Lacework APIs.

For more information read the documentation

from laceworksdk import LaceworkClient

lw = LaceworkClient() # This would leverage your default Lacework CLI profile.
lw = LaceworkClient(account="ACCOUNT",
                    subaccount="SUBACCOUNT",
                    api_key="API KEY",
                    api_secret="API SECRET")

events = lw.events.search(json={
  "timeFilter": {
    "startTime": start_time,
    "endTime": end_time
  }
})

host_vulns = lw.vulnerabilities.hosts.search(json={
    "timeFilter": {
        "startTime": start_time,
        "endTime": end_time
    }
})

container_vulns = lw.vulnerabilities.containers.search(json={
    "timeFilter": {
        "startTime": start_time,
        "endTime": end_time
    },
    "filters": [
        {
            "field": "imageId",
            "expression": "eq",
            "value": "sha256:657922eb2d64b0a34fe7339f8b48afb9f2f44635d7d6eaa92af69591d29b3330"
        }
    ]
})

Requirements

  • Python 3.8 or higher
  • Lacework API Credentials
    • Account Name
    • API Key
    • API Secret

How-To

The following information is required to instantiate a LaceworkClient instance:

  • account: The Lacework account/organization domain. (xxxxx.lacework.net)
  • api_key: The API Key that was generated from the Lacework UI/API.
  • api_secret: The API Secret that was generated from the Lacework UI/API.

Optionally, you can also set a Lacework Sub-Account using the subaccount parameter.

To generate API credentials, you'll need to do the following in Lacework:

  1. In the Lacework web interface, go to Settings -> API Keys
  2. Create a new API Key and download information the credentials.

Environment Variables

If you wish to configure the LaceworkClient instance using environment variables, this module honors the same variables used by the Lacework CLI. The account, subaccount, api_key, api_secret, and profile parameters can all be configured as specified below.

Environment Variable Description Required
LW_PROFILE Lacework CLI profile to use (configured at ~/.lacework.toml) N
LW_ACCOUNT Lacework account/organization domain (i.e. <account>.lacework.net) Y
LW_SUBACCOUNT Lacework sub-account N
LW_API_KEY Lacework API Access Key Y
LW_API_SECRET Lacework API Access Secret Y

Installation

Installing and upgrading laceworksdk is easy:

Install via PIP

$ pip install laceworksdk

Upgrading to the latest Version

$ pip install laceworksdk --upgrade

Examples

Are you looking for some sample scripts? Check out the examples folder!

Contributing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

laceworksdk-3.1.0.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

laceworksdk-3.1.0-py3-none-any.whl (56.8 kB view details)

Uploaded Python 3

File details

Details for the file laceworksdk-3.1.0.tar.gz.

File metadata

  • Download URL: laceworksdk-3.1.0.tar.gz
  • Upload date:
  • Size: 33.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-1016-azure

File hashes

Hashes for laceworksdk-3.1.0.tar.gz
Algorithm Hash digest
SHA256 998c4ac7c8bc922b21f824048bb48ac38b7f8a0a594e4416725b2ccffdb2db0d
MD5 d16039523ae1120bc0eb23dd78765d1f
BLAKE2b-256 b9fffe3407246e6d38c6b97cf52fb30532083fd4bc52cf0f9e0a13e61fcfbcf4

See more details on using hashes here.

File details

Details for the file laceworksdk-3.1.0-py3-none-any.whl.

File metadata

  • Download URL: laceworksdk-3.1.0-py3-none-any.whl
  • Upload date:
  • Size: 56.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.10.12 Linux/6.5.0-1016-azure

File hashes

Hashes for laceworksdk-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5a2c65524c72a651ef3004cd55b38f1bbf8154098b13b1b57391384fa003ed6
MD5 49055b38011ac4180c1ede5f8c8f893f
BLAKE2b-256 dc12d1140ada4a1a9108e12d8047d15f5bbfd88e07a88967a34ce89c946fdf67

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page