Skip to main content

Tools for managing AWS Security Lake custom sources

Project description

Security Lake Tools

CI PyPI version Python versions License

Tools for managing AWS Security Lake custom sources with OCSF (Open Cybersecurity Schema Framework) support.

Features

  • ✨ Create Security Lake custom sources for all OCSF event classes
  • 🔧 Automatic IAM role creation for AWS Glue crawlers
  • 📋 Built-in OCSF event class mapping
  • 🔍 Detailed error messages and troubleshooting guidance
  • 🚀 Simple command-line interface

Installation

The easiest way to use this tool is with uvx, which runs the tool in an isolated environment:

uvx security-lake-tools --help

Alternatively, install it with:

uv pip install security-lake-tools

Quick Start

Create a custom source

uvx security-lake-tools create-source \
  --external-id your-external-id \
  --region us-east-1 \
  --account-id 123456789012 \
  --profile production \
  1001

List available OCSF event classes

uvx security-lake-tools create-source --list

# Or if installed
security-lake-tools create-source --list

Detailed Usage

Prerequisites

  1. AWS Credentials: Configure AWS credentials using one of:

    • aws configure (for access keys)
    • aws configure sso (for SSO authentication)
    • Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
    • IAM role (if running on EC2)
  2. Security Lake: Ensure Security Lake is enabled in your target region

  3. IAM Permissions: You need permissions to:

    • Create IAM roles and policies
    • Create Security Lake custom sources
    • Create and manage Glue crawlers

Command-Line Options

security-lake-tools create-source [OPTIONS] CLASS_UID

Arguments:
  CLASS_UID          OCSF class UID (e.g., 1001 for File System Activity)

Options:
  --region           AWS region (default: us-east-1)
  --account-id       AWS account ID (default: auto-detected)
  --external-id      External ID for trust relationship (required)
  --glue-role-arn    ARN of existing Glue service role
  --profile          AWS profile to use
  --no-create-role   Don't auto-create Glue role if missing
  --skip-role-check  Skip Glue role verification
  --list             List all available OCSF class UIDs
  --help             Show help message

OCSF Event Classes

The tool supports all standard OCSF event classes that are accepted by Security Lake.

[!NOTE] AWS Security Lake does not support the OCSF Base Event (class_uid 0). While Base Event exists in the OCSF specification as an abstract parent class, Security Lake only accepts concrete event types.

System Activity (1xxx)

  • 1001: File System Activity
  • 1002: Kernel Extension Activity
  • 1003: Kernel Activity
  • 1004: Memory Activity
  • 1005: Module Activity
  • 1006: Scheduled Job Activity
  • 1007: Process Activity
  • 1008: Event Log Activity
  • 1009: Script Activity

Findings (2xxx)

  • 2001: Security Finding
  • 2002: Vulnerability Finding
  • 2003: Compliance Finding
  • 2004: Detection Finding
  • 2005: Incident Finding
  • 2006: Data Security Finding
  • 2007: Application Security Posture Finding

[See full list with --list option]

IAM Role Management

By default, the tool automatically creates a Glue service role with:

  • Trust relationship with glue.amazonaws.com
  • AWS managed policy AWSGlueServiceRole
  • Custom S3 policy for Security Lake buckets
  • Lake Formation permissions

To use an existing role:

security-lake-tools create-source 1001 \
  --external-id your-external-id \
  --glue-role-arn arn:aws:iam::123456789012:role/MyExistingGlueRole

To prevent automatic role creation:

security-lake-tools create-source 1001 \
  --external-id your-external-id \
  --no-create-role

What Gets Created

For each custom source, Security Lake creates:

  1. Provider Role: AmazonSecurityLake-Provider-{source-name}-{region}

    • Allows the specified account to write logs to Security Lake
  2. S3 Location: s3://aws-security-data-lake-{region}-{id}/ext/{source-name}/

    • Where your OCSF-formatted logs should be written
  3. Glue Resources:

    • Crawler: Discovers and catalogs your data
    • Database: Stores metadata
    • Table: Defines the schema

Troubleshooting

Common Issues

  1. "The Glue role does not exist"

    • Let the tool create it automatically (default behavior)
    • Or create manually with proper permissions
    • Or specify existing role with --glue-role-arn
  2. "Source already exists"

    • Delete the existing source first
    • Or use a different class UID
  3. "Security Lake not enabled"

    • Enable Security Lake in the AWS Console
    • Ensure you're using the correct region
  4. "Invalid principal" error

    • Ensure the account ID is correct
    • Check that the external ID matches your configuration

Debug Mode

For more detailed output, set the AWS_DEBUG environment variable:

AWS_DEBUG=1 security-lake-tools create-source 1001 --external-id test

Development

Setup

# Clone the repository
git clone https://github.com/yourusername/security-lake-tools
cd security-lake-tools

# Install with development dependencies using uv
uv pip install -e ".[dev]"

Running Tests

# Run tests
uv run pytest

# With coverage
uv run pytest --cov=security_lake_tools

Code Quality

# Format code
uv run black src tests

# Lint
uv run ruff check src tests

# Type checking
uv run mypy src

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Acknowledgments

  • AWS Security Lake team for the service
  • OCSF community for the schema framework
  • Contributors and users of this tool

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

security_lake_tools-0.2.1.tar.gz (42.7 kB view details)

Uploaded Source

Built Distribution

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

security_lake_tools-0.2.1-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file security_lake_tools-0.2.1.tar.gz.

File metadata

  • Download URL: security_lake_tools-0.2.1.tar.gz
  • Upload date:
  • Size: 42.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for security_lake_tools-0.2.1.tar.gz
Algorithm Hash digest
SHA256 1940fe76cf831f13fd05ce8a740a063d9f007f73859a754682783b0528b95be3
MD5 0834cbf605ac6459a74eb5e740cad726
BLAKE2b-256 8dc1f3ea24f6215e314acb7cdc6176c9ad5b2a60b67698cfa88eefd0f7d65d74

See more details on using hashes here.

Provenance

The following attestation bundles were made for security_lake_tools-0.2.1.tar.gz:

Publisher: publish.yml on tenzir/security-lake-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file security_lake_tools-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for security_lake_tools-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 46400547663be50b43e8b1a0df5f64691fe5bddc5be66a3bab92ad4468bfb2af
MD5 96b901c96971501023648cdc9649b277
BLAKE2b-256 1d0a3b1a0108bed3921b653d143dcede84e0352985a5b66031d3fc68e2b7899d

See more details on using hashes here.

Provenance

The following attestation bundles were made for security_lake_tools-0.2.1-py3-none-any.whl:

Publisher: publish.yml on tenzir/security-lake-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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