wish-core
Core business logic and state management for the wish penetration testing support system.
Overview
wish-core provides the central business logic, state management, and event processing capabilities for wish. It acts as the coordination layer between the AI components, tools, and user interface.
Key Features
- State Management: Centralized management of engagement state and session data
- Event System: Event-driven architecture for component communication
- Tool Coordination: Integration layer for penetration testing tools
- Workflow Management: Handles the flow between different testing phases
- Job Management: Asynchronous job execution and monitoring
Installation
# Install dependencies in development environment
uv sync --dev
# Install as package (future release)
pip install wish-core
Quick Start
Basic Usage Example
from wish_core import StateManager, EventBus, JobManager
from wish_models import EngagementState, SessionMetadata
# Initialize core components
state_manager = StateManager()
event_bus = EventBus()
job_manager = JobManager()
# Create and manage engagement state
session = SessionMetadata(engagement_name="Example Pentest")
engagement = EngagementState(name="Internal Network Assessment", session_metadata=session)
state_manager.set_engagement(engagement)
# Subscribe to events
@event_bus.subscribe("host.discovered")
async def on_host_discovered(event):
print(f"New host discovered: {event.data['ip_address']}")
# Execute tools asynchronously
job = await job_manager.execute_tool(
tool_name="nmap",
command="nmap -sS -p- 192.168.1.0/24",
callback=lambda result: process_nmap_results(result)
)
# Monitor job progress
status = await job_manager.get_job_status(job.id)
print(f"Job {job.id} status: {status}")
Architecture
Core Components
StateManager
Manages the central engagement state and provides thread-safe access to shared data.
from wish_core import StateManager
manager = StateManager()
# Get current state
state = manager.get_current_state()
# Update specific parts
manager.update_hosts(new_hosts)
manager.add_finding(finding)
# Transaction support
with manager.transaction():
manager.update_hosts(hosts)
manager.update_services(services)
EventBus
Provides event-driven communication between components.
from wish_core import EventBus
bus = EventBus()
# Subscribe to events
@bus.subscribe("tool.completed")
async def handle_tool_completion(event):
print(f"Tool {event.data['tool']} completed")
# Publish events
await bus.publish("scan.started", {"target": "192.168.1.0/24"})
JobManager
Handles asynchronous execution of tools and long-running operations.
from wish_core import JobManager
job_manager = JobManager()
# Execute tool
job = await job_manager.execute_tool(
tool_name="nikto",
command="nikto -h http://target.com",
timeout=300
)
# Check status
status = await job_manager.get_job_status(job.id)
# Cancel job
await job_manager.cancel_job(job.id)
Development Guide
Running Tests
# Run all tests
uv run pytest
# Run with coverage
uv run pytest --cov=src --cov-report=html
# Run specific test file
uv run pytest tests/test_state_manager.py
# Run with verbose output
uv run pytest -v
Code Quality Checks
# Run linting
uv run ruff check src/ tests/
# Format code
uv run ruff format src/ tests/
# Type checking
uv run mypy src/
Project Structure
packages/wish-core/
├── src/wish_core/
│ ├── __init__.py # Package exports
│ ├── state_manager.py # State management
│ ├── event_bus.py # Event system
│ ├── job_manager.py # Job execution
│ ├── workflow/ # Workflow management
│ │ ├── __init__.py
│ │ └── coordinator.py
│ └── utils/ # Utility functions
│ ├── __init__.py
│ └── threading.py
├── tests/
│ ├── test_state_manager.py
│ ├── test_event_bus.py
│ ├── test_job_manager.py
│ └── test_workflow.py
└── README.md
API Reference
StateManager API
get_current_state(): Get the current engagement stateset_engagement(engagement): Set a new engagementupdate_hosts(hosts): Update host informationadd_finding(finding): Add a new findingtransaction(): Context manager for atomic updates
EventBus API
subscribe(event_type, handler): Subscribe to an event typeunsubscribe(event_type, handler): Unsubscribe from eventspublish(event_type, data): Publish an eventclear(): Clear all subscriptions
JobManager API
execute_tool(tool_name, command, **kwargs): Execute a toolget_job_status(job_id): Get job statuscancel_job(job_id): Cancel a running jobget_job_logs(job_id): Get job output logslist_active_jobs(): List all active jobs
License
This project is published under [appropriate license].
Related Packages
wish-models: Core data models and validationwish-ai: AI-driven inference enginewish-tools: Pentest tool integrationwish-knowledge: Knowledge base managementwish-c2: C2 server integrationwish-cli: Command line interface
Support
If you have issues or questions, you can get support through:
- Issues: Bug reports and feature requests
- Discussions: General questions and discussions
- Documentation: Review API documentation and examples
Metadata
Release files for wish-core 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wish_core-0.7.0.tar.gz | 22.7 kB | Without provenance | Details for wish_core-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wish_core-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for wish_core-0.7.0-py3-none-any.whl |
Total release size: 40.6 kB
Release files / wish_core-0.7.0.tar.gz
| Download URL | wish_core-0.7.0.tar.gz |
|---|---|
| Size | 22.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c412edce72dc3287e4c051fbc991289a8163eb739e7e31e7d2f6c09442c2925
|
|
BLAKE2b-256 checksum How to use checksums |
bcbddaf28ab7989264cf5796a95b79355f573ed14e3f240bd03e32a21e5bf037
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Release files / wish_core-0.7.0-py3-none-any.whl
| Download URL | wish_core-0.7.0-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14c295918f46bd5b69fcda4dc02c0dc55277f1f9c6e2a180cf0a0c636815d9d2
|
|
BLAKE2b-256 checksum How to use checksums |
9ec0ba65bfe801884dcfa8cddd81b075aa64f0615ba38f434e650ab30863d5a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.11
|
Security for wish-core 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.