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

Using uvx (Recommended)

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

# Run directly without installation
uvx --from security-lake-tools security-lake-create-source --help

# Or with a shorter alias
alias sl-create='uvx --from security-lake-tools security-lake-create-source'
sl-create 1001 --external-id your-external-id

Traditional Installation

Using pip:

pip install security-lake-tools

Using uv:

uv pip install security-lake-tools

Quick Start

Create a custom source

# Using uvx (no installation needed)
uvx --from security-lake-tools security-lake-create-source 1001 \
  --external-id your-external-id \
  --region us-east-1

# Or if installed traditionally
security-lake-create-source 1001 \
  --external-id your-external-id \
  --region us-east-1

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

List available OCSF event classes

# Using uvx
uvx --from security-lake-tools security-lake-create-source --list

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

Detailed Usage

Prerequisites

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

    • aws configure
    • 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-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:

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-create-source 1001 \
  --external-id your-external-id \
  --glue-role-arn arn:aws:iam::123456789012:role/MyExistingGlueRole

To prevent automatic role creation:

security-lake-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-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.1.1.tar.gz (43.2 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.1.1-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: security_lake_tools-0.1.1.tar.gz
  • Upload date:
  • Size: 43.2 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.1.1.tar.gz
Algorithm Hash digest
SHA256 42703059e51dc976dfc45e83fc1154bdb5c839e5c0e9c1006171ed0985e5c68c
MD5 8190e25ebb1127097b918da7dc28ee27
BLAKE2b-256 064ce449cc58bc0c3e89451e36a83dab33b019207d3ca791b570fc220b29cd00

See more details on using hashes here.

Provenance

The following attestation bundles were made for security_lake_tools-0.1.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.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for security_lake_tools-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fbfd97610e4e7b79cfca087663891a95854f153717952d398c2555c7149528ca
MD5 31a1ebf379cbec96d8a75e137c21668f
BLAKE2b-256 1b452e9976be0f9bd5dd1bd0fd79a6e0bf895c705dcf1b63413e70f9603d06c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for security_lake_tools-0.1.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