Skip to main content

Python wrapper for the AttackForge API

Project description

PyAttackForge

A lightweight Python library for interacting with the AttackForge API.


Features

  • Create and fetch projects
  • Manage assets
  • Submit vulnerabilities
  • Dry-run mode for testing

Install

mkdir PyAttackForgeEnv
cd PyAttackForgeEnv
virtualenv venv
source ./venv/bin/activate
pip install git+https://github.com/Tantalum-Labs/PyAttackForge.git

Use

from pyattackforge import PyAttackForgeClient

# Initialize client - Note: Make sure to set your AttackForge URL and API Key
client = PyAttackForgeClient(api_key="your-api-key", base_url="https://demo.attackforge.com", dry_run=False)

# Create a project
project = client.create_project("My Project", scope=["Asset1", "Asset2"])

## Create a vulnerability with auto-created assets
client.create_vulnerability(
    vulnerability_data={
        "projectId": "abc123",
        "title": "Open SSH Port",
        "affected_assets": [{"assetName": "ssh-prod-1"}],
        "priority": "High",
        "likelihood_of_exploitation": 10,
    },
    auto_create_assets=True,
    default_asset_type="Cloud",
    default_asset_library_ids=["your-lib-id"]
)

API Reference

PyAttackForgeClient

  • __init__(api_key: str, base_url: str = ..., dry_run: bool = False)
  • get_assets() -> dict
  • get_asset_by_name(name: str) -> dict or None
  • create_asset(asset_data: dict) -> dict
  • get_project_by_name(name: str) -> dict or None
  • get_project_scope(project_id: str) -> set
  • update_project_scope(project_id: str, new_assets: list) -> dict
  • create_project(name: str, **kwargs) -> dict
  • update_project(project_id: str, update_fields: dict) -> dict
  • create_vulnerability(vulnerability_data: dict, auto_create_assets: bool = False, ...) -> dict

See the source code for full details and docstrings.


Contributing

Contributions are welcome! Please open issues or submit pull requests via GitHub.

  • Ensure code is PEP8-compliant and includes docstrings and type hints.
  • Add or update tests for new features or bugfixes.
  • Do not commit API keys or other secrets.

Security

Never commit your API keys or other sensitive information to version control.


License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).

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

pyattackforge-0.1.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

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

pyattackforge-0.1.0-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file pyattackforge-0.1.0.tar.gz.

File metadata

  • Download URL: pyattackforge-0.1.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for pyattackforge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1e4c09fd7945fe456a0d6322554c19c33e67fb98cbf1a60469d4efd0f43aaaab
MD5 549e0dcbc3715e6773d4dc07ac8b3322
BLAKE2b-256 89f750a2ae44a9cef910438f524b29a68658452ce7796cc4ac405f67de7db713

See more details on using hashes here.

File details

Details for the file pyattackforge-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyattackforge-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for pyattackforge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76034346f3d7a3680a9b14b7b1d512bd2e4e783a3fd8bbeba15934919af97f60
MD5 6b8d37f9809ad2afa467602be28add0d
BLAKE2b-256 63893f8a051ccc1c385d36ecfe66bd151601c8842760b74c6f0678b73a31aabb

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