Skip to main content

Snyk module for Clearskies

Project description

clearskies-snyk

A clearskies module for interacting with the Snyk API.

This module provides pre-built models and backends for seamless integration with both the Snyk REST API and the legacy v1 API, allowing you to easily query and manage Snyk resources like organizations, projects, groups, issues, and more.

Installation

pip install clearskies-snyk

Or with uv:

uv add clearskies-snyk

Quick Start

Authentication

Set up authentication using environment variables:

# Option 1: Direct API key
export SNYK_AUTH_KEY=your-snyk-api-key

# Option 2: Secret manager path (recommended for production)
export SNYK_AUTH_SECRET_PATH=/path/to/secret

Basic Usage

import clearskies
from clearskies_snyk.models import SnykOrg, SnykProject, SnykGroup

def my_handler(snyk_org: SnykOrg, snyk_project: SnykProject, snyk_group: SnykGroup):
    """Example handler using dependency injection."""
    # List all organizations
    for org in snyk_org:
        print(f"Org: {org.name} ({org.slug})")

    # Get projects for an organization
    projects = snyk_project.where("org_id=your-org-id")
    for project in projects:
        print(f"Project: {project.name} - {project.project_type}")

    # List groups
    for group in snyk_group:
        print(f"Group: {group.name}")

Working with Issues

import clearskies
from clearskies_snyk.models import SnykOrgIssue, SnykGroupIssue

def my_handler(snyk_org_issue: SnykOrgIssue, snyk_group_issue: SnykGroupIssue):
    """Example handler using dependency injection."""
    # Get issues for an organization
    org_issues = snyk_org_issue.where("org_id=your-org-id")
    for issue in org_issues:
        print(f"Issue: {issue.title} - Severity: {issue.effective_severity_level}")

    # Get issues across a group
    group_issues = snyk_group_issue.where("group_id=your-group-id")
    for issue in group_issues:
        print(f"Issue: {issue.title}")

Using the V1 API

Some endpoints are only available through the legacy v1 API:

import clearskies
from clearskies_snyk.models.v1 import SnykIntegration, SnykWebhook, SnykLicense

def my_handler(snyk_integration: SnykIntegration, snyk_webhook: SnykWebhook):
    """Example handler using dependency injection."""
    # List integrations for an organization
    integrations = snyk_integration.where("org_id=your-org-id")
    for integration in integrations:
        print(f"Integration: {integration.name} ({integration.integration_type})")

    # List webhooks
    webhooks = snyk_webhook.where("org_id=your-org-id")
    for webhook in webhooks:
        print(f"Webhook: {webhook.url}")

Custom Backend Configuration

import clearskies
from clearskies_snyk.backends import SnykBackend

# Custom authentication
backend = SnykBackend(
    authentication=clearskies.authentication.SecretBearer(
        environment_key="MY_SNYK_KEY",
        header_prefix="token ",
    )
)

# Custom API version
backend = SnykBackend(api_version="2024-10-15")

Available Models

REST API Models

Category Models
Organizations SnykOrg, SnykOrgMember, SnykOrgMembership, SnykOrgUser, SnykOrgInvite
Projects SnykProject, SnykProjectHistory, SnykProjectIgnore, SnykProjectSbom
Groups SnykGroup, SnykGroupMember, SnykGroupMembership, SnykGroupUser, SnykGroupOrgMembership
Issues SnykOrgIssue, SnykGroupIssue
Policies SnykOrgPolicy, SnykOrgPolicyEvent, SnykGroupPolicy
Service Accounts SnykOrgServiceAccount, SnykGroupServiceAccount
Apps SnykOrgApp, SnykOrgAppBot, SnykOrgAppInstall, SnykGroupAppInstall, SnykSelfApp
Cloud SnykCloudEnvironment, SnykCloudResource, SnykCloudScan
Containers SnykContainerImage, SnykCustomBaseImage
Settings SnykOrgSettingsIac, SnykOrgSettingsSast, SnykOrgSettingsOpenSource, SnykGroupSettingsIac
Tenants SnykTenant, SnykTenantMembership, SnykTenantRole
Other SnykCollection, SnykTarget, SnykPackage, SnykAiBom, SnykLearnAssignment, and more

V1 API Models

Model Description
SnykIntegration SCM and CI/CD integrations
SnykIntegrationSetting Integration configuration settings
SnykWebhook Webhook configurations
SnykLicense License information
SnykDependency Project dependencies
SnykEntitlement Organization entitlements
SnykGroupRoleV1 Group roles (v1 format)
SnykGroupSettings Group settings
SnykGroupTag Group tags
SnykImportJob Project import jobs

Development

To set up your development environment:

# Install uv if not already installed
pip install uv

# Create a virtual environment and install all dependencies
uv sync

# Install dev dependencies
uv pip install .[dev]

# Install pre-commit hooks
uv run pre-commit install

# Run pre-commit on all files
uv run pre-commit run --all-files

Documentation

For full API documentation, visit the Snyk API Documentation.

License

MIT License - see LICENSE for details.

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

clear_skies_snyk-2.0.5.tar.gz (796.2 kB view details)

Uploaded Source

Built Distribution

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

clear_skies_snyk-2.0.5-py3-none-any.whl (120.3 kB view details)

Uploaded Python 3

File details

Details for the file clear_skies_snyk-2.0.5.tar.gz.

File metadata

  • Download URL: clear_skies_snyk-2.0.5.tar.gz
  • Upload date:
  • Size: 796.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for clear_skies_snyk-2.0.5.tar.gz
Algorithm Hash digest
SHA256 6cf100e0fe25ce77c3f4acbba0c3af2ece704050f66b25910a3694349a77785b
MD5 0cc741182a74632f8dbc7108d44cb264
BLAKE2b-256 487a8dbeaba08461006be2af04aa48e813852f49bfc156c20d62ecc9ddddb244

See more details on using hashes here.

File details

Details for the file clear_skies_snyk-2.0.5-py3-none-any.whl.

File metadata

  • Download URL: clear_skies_snyk-2.0.5-py3-none-any.whl
  • Upload date:
  • Size: 120.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for clear_skies_snyk-2.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cff0cfe1613e464cd525ec3aa41d7046504101ab7f99ca0b05c8a62f335bae77
MD5 958912a2c8604c91db43acc0b0b55263
BLAKE2b-256 bc0c4a23e43dfabae6550cd61766396e504a1b11010b777b06d8ab97c6360cfc

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