nucleus-security-api-wrapper


Namenucleus-security-api-wrapper JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/nucleus/nucleus-python-sdk
SummaryUnofficial Python SDK for the Nucleus Security API - A third-party implementation
upload_time2024-11-08 13:39:08
maintainerNone
docs_urlNone
authorNucleus SDK Team
requires_python>=3.7
licenseMIT License Copyright (c) 2024 Nucleus SDK Contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords nucleus security api sdk vulnerability management third-party unofficial api wrapper
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Unofficial Nucleus Security Python API Wrapper

This is an **unofficial** third-party Python SDK for interacting with the Nucleus Security API. This SDK provides a simple and intuitive interface to access Nucleus Security's vulnerability management platform, with support for both synchronous and asynchronous operations.

> **Note**: This is not an official Nucleus Security product. This SDK is maintained by Loc Mai and is not affiliated with, officially maintained, or endorsed by Nucleus Security. For official Nucleus Security products, please visit [nucleussec.com](https://nucleussec.com).

## Features

- Full support for Nucleus Security API endpoints
- Async support for high-performance operations
- Built-in caching to reduce API calls
- Rate limiting to prevent API throttling
- Comprehensive error handling
- Type hints and data validation using Pydantic
- Detailed logging for debugging
- Retry mechanism with exponential backoff
- Interactive Jupyter notebook tutorial

## Installation

```bash
pip install nucleus-security-api-wrapper
```

## Quick Start

### Synchronous Usage

```python
from nucleus import NucleusClient
from nucleus.models import Severity, AssetType

# Initialize the client
client = NucleusClient(api_key="your-api-key")

# Get list of projects
projects = client.get_projects()

# Get specific project
project = client.get_project(project_id=123)

# Get assets in a project
assets = client.get_project_assets(project_id=123)
```

### Asynchronous Usage

```python
import asyncio
from nucleus.async_client import AsyncNucleusClient

async def main():
    async with AsyncNucleusClient(api_key="your-api-key") as client:
        # Fetch multiple resources concurrently
        projects, findings = await asyncio.gather(
            client.get_projects(),
            client.search_findings(
                project_id=123,
                filters=[{
                    "property": "finding_severity",
                    "value": "Critical",
                    "exact_match": True
                }]
            )
        )

asyncio.run(main())
```

## Interactive Tutorial

We provide a Jupyter notebook tutorial that walks you through all the features of the SDK. To use it:

1. Install Jupyter if you haven't already:
```bash
pip install jupyter
```

2. Navigate to the examples directory and start Jupyter:
```bash
cd examples
jupyter notebook
```

3. Open `nucleus_sdk_tutorial.ipynb` in your browser

The tutorial covers:
- Basic SDK operations
- Working with projects, assets, and findings
- Async operations for improved performance
- Bulk operations and parallel processing
- Error handling and best practices
- Real-world usage examples

## Advanced Features

### Caching

The SDK includes built-in caching to reduce API calls:

```python
from nucleus.async_client import AsyncNucleusClient

async with AsyncNucleusClient(
    api_key="your-api-key",
    cache_ttl=300  # Cache TTL in seconds
) as client:
    # First call hits the API
    projects = await client.get_projects()
    
    # Second call uses cached data
    projects_cached = await client.get_projects()
```

### Rate Limiting

Built-in rate limiting prevents API throttling:

```python
from nucleus.async_client import AsyncNucleusClient

async with AsyncNucleusClient(
    api_key="your-api-key",
    rate_limit_calls=100,  # Number of calls allowed
    rate_limit_period=60   # Period in seconds
) as client:
    # SDK automatically handles rate limiting
    for i in range(200):
        await client.get_projects()  # Will pause if rate limit is reached
```

### Logging

Enable detailed logging for debugging:

```python
import logging
from nucleus.utils import logger

# Set logging level
logger.setLevel(logging.DEBUG)

# Add custom handler if needed
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
logger.addHandler(handler)
```

### Error Handling

Comprehensive error handling with custom exceptions:

```python
from nucleus import NucleusClient
from nucleus.exceptions import (
    NucleusAPIError,
    NucleusAuthError,
    NucleusNotFoundError,
    NucleusPermissionError
)

client = NucleusClient(api_key="your-api-key")

try:
    project = client.get_project(project_id=999999)
except NucleusNotFoundError:
    print("Project not found")
except NucleusAuthError:
    print("Authentication failed")
except NucleusPermissionError:
    print("Permission denied")
except NucleusAPIError as e:
    print(f"API error: {e}")
```

### Bulk Operations

Efficiently handle multiple operations:

```python
async with AsyncNucleusClient(api_key="your-api-key") as client:
    # Bulk update findings
    updates = [
        {
            "finding_number": "VULN-001",
            "finding_status": "In Progress",
            "comment": "Working on fix"
        },
        {
            "finding_number": "VULN-002",
            "finding_status": "In Progress",
            "comment": "Under review"
        }
    ]
    
    result = await client.bulk_update_findings(project_id, updates)
```

## Examples

The SDK comes with several examples:
- `examples/basic_usage.py`: Basic synchronous operations
- `examples/advanced_usage.py`: Advanced features including async operations
- `examples/nucleus_sdk_tutorial.ipynb`: Interactive Jupyter notebook tutorial

## API Documentation

For official API documentation, please visit the [Nucleus Security API Documentation](https://api-docs.nucleussec.com/nucleus/docs/).

## Contributing

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

## Disclaimer

This is a third-party implementation and is not officially supported by Nucleus Security. Use at your own risk. While we strive to maintain compatibility with the Nucleus Security API, we cannot guarantee immediate updates when the API changes.

## Author

Maintained by Loc Mai (jobs@locm.ai)

## License

This SDK is released under the MIT License. See the LICENSE file for details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/nucleus/nucleus-python-sdk",
    "name": "nucleus-security-api-wrapper",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "nucleus, security, api, sdk, vulnerability management, third-party, unofficial, api wrapper",
    "author": "Nucleus SDK Team",
    "author_email": "Loc Mai <jobs@locm.ai>",
    "download_url": "https://files.pythonhosted.org/packages/43/d2/6d45cd7040d776d4ea911d79107132156ab90989b66b3ed510002cc86611/nucleus_security_api_wrapper-0.1.0.tar.gz",
    "platform": null,
    "description": "# Unofficial Nucleus Security Python API Wrapper\n\nThis is an **unofficial** third-party Python SDK for interacting with the Nucleus Security API. This SDK provides a simple and intuitive interface to access Nucleus Security's vulnerability management platform, with support for both synchronous and asynchronous operations.\n\n> **Note**: This is not an official Nucleus Security product. This SDK is maintained by Loc Mai and is not affiliated with, officially maintained, or endorsed by Nucleus Security. For official Nucleus Security products, please visit [nucleussec.com](https://nucleussec.com).\n\n## Features\n\n- Full support for Nucleus Security API endpoints\n- Async support for high-performance operations\n- Built-in caching to reduce API calls\n- Rate limiting to prevent API throttling\n- Comprehensive error handling\n- Type hints and data validation using Pydantic\n- Detailed logging for debugging\n- Retry mechanism with exponential backoff\n- Interactive Jupyter notebook tutorial\n\n## Installation\n\n```bash\npip install nucleus-security-api-wrapper\n```\n\n## Quick Start\n\n### Synchronous Usage\n\n```python\nfrom nucleus import NucleusClient\nfrom nucleus.models import Severity, AssetType\n\n# Initialize the client\nclient = NucleusClient(api_key=\"your-api-key\")\n\n# Get list of projects\nprojects = client.get_projects()\n\n# Get specific project\nproject = client.get_project(project_id=123)\n\n# Get assets in a project\nassets = client.get_project_assets(project_id=123)\n```\n\n### Asynchronous Usage\n\n```python\nimport asyncio\nfrom nucleus.async_client import AsyncNucleusClient\n\nasync def main():\n    async with AsyncNucleusClient(api_key=\"your-api-key\") as client:\n        # Fetch multiple resources concurrently\n        projects, findings = await asyncio.gather(\n            client.get_projects(),\n            client.search_findings(\n                project_id=123,\n                filters=[{\n                    \"property\": \"finding_severity\",\n                    \"value\": \"Critical\",\n                    \"exact_match\": True\n                }]\n            )\n        )\n\nasyncio.run(main())\n```\n\n## Interactive Tutorial\n\nWe provide a Jupyter notebook tutorial that walks you through all the features of the SDK. To use it:\n\n1. Install Jupyter if you haven't already:\n```bash\npip install jupyter\n```\n\n2. Navigate to the examples directory and start Jupyter:\n```bash\ncd examples\njupyter notebook\n```\n\n3. Open `nucleus_sdk_tutorial.ipynb` in your browser\n\nThe tutorial covers:\n- Basic SDK operations\n- Working with projects, assets, and findings\n- Async operations for improved performance\n- Bulk operations and parallel processing\n- Error handling and best practices\n- Real-world usage examples\n\n## Advanced Features\n\n### Caching\n\nThe SDK includes built-in caching to reduce API calls:\n\n```python\nfrom nucleus.async_client import AsyncNucleusClient\n\nasync with AsyncNucleusClient(\n    api_key=\"your-api-key\",\n    cache_ttl=300  # Cache TTL in seconds\n) as client:\n    # First call hits the API\n    projects = await client.get_projects()\n    \n    # Second call uses cached data\n    projects_cached = await client.get_projects()\n```\n\n### Rate Limiting\n\nBuilt-in rate limiting prevents API throttling:\n\n```python\nfrom nucleus.async_client import AsyncNucleusClient\n\nasync with AsyncNucleusClient(\n    api_key=\"your-api-key\",\n    rate_limit_calls=100,  # Number of calls allowed\n    rate_limit_period=60   # Period in seconds\n) as client:\n    # SDK automatically handles rate limiting\n    for i in range(200):\n        await client.get_projects()  # Will pause if rate limit is reached\n```\n\n### Logging\n\nEnable detailed logging for debugging:\n\n```python\nimport logging\nfrom nucleus.utils import logger\n\n# Set logging level\nlogger.setLevel(logging.DEBUG)\n\n# Add custom handler if needed\nhandler = logging.StreamHandler()\nhandler.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))\nlogger.addHandler(handler)\n```\n\n### Error Handling\n\nComprehensive error handling with custom exceptions:\n\n```python\nfrom nucleus import NucleusClient\nfrom nucleus.exceptions import (\n    NucleusAPIError,\n    NucleusAuthError,\n    NucleusNotFoundError,\n    NucleusPermissionError\n)\n\nclient = NucleusClient(api_key=\"your-api-key\")\n\ntry:\n    project = client.get_project(project_id=999999)\nexcept NucleusNotFoundError:\n    print(\"Project not found\")\nexcept NucleusAuthError:\n    print(\"Authentication failed\")\nexcept NucleusPermissionError:\n    print(\"Permission denied\")\nexcept NucleusAPIError as e:\n    print(f\"API error: {e}\")\n```\n\n### Bulk Operations\n\nEfficiently handle multiple operations:\n\n```python\nasync with AsyncNucleusClient(api_key=\"your-api-key\") as client:\n    # Bulk update findings\n    updates = [\n        {\n            \"finding_number\": \"VULN-001\",\n            \"finding_status\": \"In Progress\",\n            \"comment\": \"Working on fix\"\n        },\n        {\n            \"finding_number\": \"VULN-002\",\n            \"finding_status\": \"In Progress\",\n            \"comment\": \"Under review\"\n        }\n    ]\n    \n    result = await client.bulk_update_findings(project_id, updates)\n```\n\n## Examples\n\nThe SDK comes with several examples:\n- `examples/basic_usage.py`: Basic synchronous operations\n- `examples/advanced_usage.py`: Advanced features including async operations\n- `examples/nucleus_sdk_tutorial.ipynb`: Interactive Jupyter notebook tutorial\n\n## API Documentation\n\nFor official API documentation, please visit the [Nucleus Security API Documentation](https://api-docs.nucleussec.com/nucleus/docs/).\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Disclaimer\n\nThis is a third-party implementation and is not officially supported by Nucleus Security. Use at your own risk. While we strive to maintain compatibility with the Nucleus Security API, we cannot guarantee immediate updates when the API changes.\n\n## Author\n\nMaintained by Loc Mai (jobs@locm.ai)\n\n## License\n\nThis SDK is released under the MIT License. See the LICENSE file for details.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Nucleus SDK Contributors  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Unofficial Python SDK for the Nucleus Security API - A third-party implementation",
    "version": "0.1.0",
    "project_urls": {
        "Documentation": "https://github.com/locm-ai/Nucleus-Security-Python-API-Wrapper#readme",
        "Homepage": "https://github.com/locm-ai/Nucleus-Security-Python-API-Wrapper",
        "Issues": "https://github.com/locm-ai/Nucleus-Security-Python-API-Wrapper/issues",
        "Nucleus Security": "https://nucleussec.com",
        "Repository": "https://github.com/locm-ai/Nucleus-Security-Python-API-Wrapper.git"
    },
    "split_keywords": [
        "nucleus",
        " security",
        " api",
        " sdk",
        " vulnerability management",
        " third-party",
        " unofficial",
        " api wrapper"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "704a76f85cecb2df59b9a346d4d6f500f6e415572b8bb50efa577f670db74f69",
                "md5": "8d7c8b0e0a5fb8ec6684167724f8df1b",
                "sha256": "2c42a39f22004b0333cce3f6a33a6bc02346f125f0f20aaaead6fd8cb2c39113"
            },
            "downloads": -1,
            "filename": "nucleus_security_api_wrapper-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8d7c8b0e0a5fb8ec6684167724f8df1b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 15879,
            "upload_time": "2024-11-08T13:39:07",
            "upload_time_iso_8601": "2024-11-08T13:39:07.128904Z",
            "url": "https://files.pythonhosted.org/packages/70/4a/76f85cecb2df59b9a346d4d6f500f6e415572b8bb50efa577f670db74f69/nucleus_security_api_wrapper-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "43d26d45cd7040d776d4ea911d79107132156ab90989b66b3ed510002cc86611",
                "md5": "c6dc72d3ff0a6ca1ab8a62ce6f3282a2",
                "sha256": "49aeca449ee7fec4658d6f86d9ac759947ece8608c3cf5379abe519fae016877"
            },
            "downloads": -1,
            "filename": "nucleus_security_api_wrapper-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c6dc72d3ff0a6ca1ab8a62ce6f3282a2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 15081,
            "upload_time": "2024-11-08T13:39:08",
            "upload_time_iso_8601": "2024-11-08T13:39:08.381438Z",
            "url": "https://files.pythonhosted.org/packages/43/d2/6d45cd7040d776d4ea911d79107132156ab90989b66b3ed510002cc86611/nucleus_security_api_wrapper-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-08 13:39:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "nucleus",
    "github_project": "nucleus-python-sdk",
    "github_not_found": true,
    "lcname": "nucleus-security-api-wrapper"
}
        
Elapsed time: 2.54529s