Skip to content

Commit 851a0f0

Browse files
committed
feat(docs + pre commit):
1 parent 152c876 commit 851a0f0

File tree

6 files changed

+315
-4
lines changed

6 files changed

+315
-4
lines changed

.github/workflows/pre-commit.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Pre-Commit Checks
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
pre-commit:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: '3.x'
18+
- name: Install pre-commit
19+
run: pip install pre-commit
20+
- name: Run pre-commit
21+
run: pre-commit run --all-files

.github/workflows/test.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ jobs:
2929
cache: "poetry"
3030
- name: Install dependencies
3131
run: poetry install
32-
- name: Install pre-commit
33-
run: pip install pre-commit
34-
- name: Run pre-commit
35-
run: pre-commit run --all-files
3632
- name: Run unit tests
3733
run: |
3834
poetry run pytest .

docs/abstractions.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Abstractions in Agentic Security
2+
3+
This document outlines the key abstractions used in the Agentic Security project, providing insights into the classes, interfaces, and design patterns that form the backbone of the system.
4+
5+
## Key Abstractions
6+
7+
### AgentSpecification
8+
9+
- **Purpose**: Defines the specification for a language model or agent, including its name, version, description, capabilities, and configuration settings.
10+
- **Usage**: Used to initialize and configure the `OperatorToolBox` and other components that interact with language models.
11+
12+
### OperatorToolBox
13+
14+
- **Purpose**: Serves as the main class for managing dataset operations, including validation, execution, and result retrieval.
15+
- **Methods**:
16+
- `get_spec()`: Returns the agent specification.
17+
- `get_datasets()`: Retrieves the datasets for operations.
18+
- `validate()`: Validates the toolbox setup.
19+
- `run_operation(operation: str)`: Executes a specified operation.
20+
21+
### DatasetManagerAgent
22+
23+
- **Purpose**: Provides tools for managing and executing operations on datasets through an agent-based approach.
24+
- **Tools**:
25+
- `validate_toolbox`: Validates the `OperatorToolBox`.
26+
- `execute_operation`: Executes operations on datasets.
27+
- `retrieve_results`: Retrieves operation results.
28+
- `retrieve_failures`: Retrieves any failures encountered.
29+
30+
### ProbeDataset
31+
32+
- **Purpose**: Represents a dataset used in security scans, including metadata, prompts, and associated costs.
33+
- **Methods**:
34+
- `metadata_summary()`: Provides a summary of the dataset's metadata.
35+
36+
### Refusal Classifier
37+
38+
- **Purpose**: Analyzes responses from language models to detect potential security vulnerabilities.
39+
- **Design**: Utilizes predefined rules and machine learning models for classification.
40+
41+
## Design Patterns
42+
43+
### Modular Architecture
44+
45+
- **Description**: The system is designed with a modular architecture, allowing for easy integration of new components and features.
46+
- **Benefits**: Enhances flexibility, extensibility, and scalability.
47+
48+
### Agent-Based Design
49+
50+
- **Description**: Utilizes an agent-based approach for managing and executing operations on datasets.
51+
- **Benefits**: Provides a structured framework for interacting with language models and datasets.
52+
53+
## Conclusion
54+
55+
The abstractions in Agentic Security are designed to provide a flexible and extensible framework for managing and executing security scans on language models. This document highlights the key classes, interfaces, and design patterns that contribute to the system's architecture and functionality.

docs/design.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Design Document
2+
3+
This document provides an overview of the design and architecture of the Agentic Security project. It outlines the key components, their interactions, and the design principles guiding the development of the system.
4+
5+
## Overview
6+
7+
Agentic Security is an open-source LLM vulnerability scanner designed to identify and mitigate potential security threats in language models. It integrates various modules and datasets to perform comprehensive security scans.
8+
9+
## Architecture
10+
11+
The system is built around a modular architecture, allowing for flexibility and extensibility. The core components include:
12+
13+
- **Agentic Security Core**: The main application responsible for orchestrating the security scans and managing interactions with external modules.
14+
- **Probe Actor**: Handles the execution of fuzzing and attack techniques on language models.
15+
- **Probe Data**: Manages datasets used for testing and validation, including loading and processing data.
16+
- **Refusal Classifier**: Analyzes responses from language models to identify potential security issues.
17+
18+
## Key Components
19+
20+
### Agentic Security Core
21+
22+
The core application is responsible for initializing the system, managing configurations, and coordinating the execution of security scans. It provides a command-line interface for users to interact with the system.
23+
24+
### Probe Actor
25+
26+
The Probe Actor module implements various fuzzing and attack techniques. It is designed to test the robustness of language models by simulating different attack scenarios.
27+
28+
### Probe Data
29+
30+
The Probe Data module manages datasets used in security scans. It supports loading data from local files and external sources, providing a flexible framework for testing different scenarios.
31+
32+
### Refusal Classifier
33+
34+
The Refusal Classifier analyzes responses from language models to detect potential security vulnerabilities. It uses predefined rules and machine learning models to classify responses.
35+
36+
## Design Principles
37+
38+
- **Modularity**: The system is designed to be modular, allowing for easy integration of new components and features.
39+
- **Extensibility**: New modules and datasets can be added to the system without significant changes to the core architecture.
40+
- **Scalability**: The system is built to handle large datasets and complex security scans efficiently.
41+
42+
## Interaction Flow
43+
44+
1. **Initialization**: The system is initialized with the necessary configurations and datasets.
45+
2. **Execution**: The Probe Actor executes security scans on the language models using the datasets provided by the Probe Data module.
46+
3. **Analysis**: The Refusal Classifier analyzes the responses to identify potential security issues.
47+
4. **Reporting**: Results are compiled and presented to the user, highlighting any vulnerabilities detected.
48+
49+
## Conclusion
50+
51+
The design of Agentic Security emphasizes flexibility, extensibility, and scalability, providing a robust framework for identifying and mitigating security threats in language models. This document serves as a guide to understanding the system's architecture and key components.

docs/operator.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Operator Module
2+
3+
The `operator.py` module provides tools for managing and operating on datasets using an agent-based approach. It is designed to facilitate the execution of operations on datasets through a structured and validated process.
4+
5+
## Classes
6+
7+
### AgentSpecification
8+
9+
Defines the specification for an LLM/agent:
10+
11+
- `name`: Name of the LLM/agent
12+
- `version`: Version of the LLM/agent
13+
- `description`: Description of the LLM/agent
14+
- `capabilities`: List of capabilities
15+
- `configuration`: Configuration settings
16+
17+
### OperatorToolBox
18+
19+
Main class for dataset operations:
20+
21+
- `__init__(spec: AgentSpecification, datasets: list[dict[str, Any]])`: Initialize with agent spec and datasets. This sets up the toolbox with the necessary specifications and datasets for operation.
22+
- `get_spec()`: Get the agent specification. Returns the `AgentSpecification` object associated with the toolbox.
23+
- `get_datasets()`: Get the datasets. Returns a list of datasets that the toolbox operates on.
24+
- `validate()`: Validate the toolbox. Checks if the toolbox is correctly set up with valid specifications and datasets.
25+
- `stop()`: Stop the toolbox. Halts any ongoing operations within the toolbox.
26+
- `run()`: Run the toolbox. Initiates the execution of operations as defined in the toolbox.
27+
- `get_results()`: Get operation results. Retrieves the results of operations performed by the toolbox.
28+
- `get_failures()`: Get failures. Provides a list of any failures encountered during operations.
29+
- `run_operation(operation: str)`: Run a specific operation. Executes a given operation on the datasets, returning the result or failure message.
30+
31+
## Agent Tools
32+
33+
The `dataset_manager_agent` provides these tools:
34+
35+
### validate_toolbox
36+
37+
Validates the OperatorToolBox:
38+
39+
```python
40+
@dataset_manager_agent.tool
41+
async def validate_toolbox(ctx: RunContext[OperatorToolBox]) -> str
42+
```
43+
44+
### execute_operation
45+
46+
Executes an operation on a dataset:
47+
48+
```python
49+
@dataset_manager_agent.tool
50+
async def execute_operation(ctx: RunContext[OperatorToolBox], operation: str) -> str
51+
```
52+
53+
### retrieve_results
54+
55+
Retrieves operation results:
56+
57+
```python
58+
@dataset_manager_agent.tool
59+
async def retrieve_results(ctx: RunContext[OperatorToolBox]) -> str
60+
```
61+
62+
### retrieve_failures
63+
64+
Retrieves failures:
65+
66+
```python
67+
@dataset_manager_agent.tool
68+
async def retrieve_failures(ctx: RunContext[OperatorToolBox]) -> str
69+
```
70+
71+
## Usage Examples
72+
73+
### Initializing the OperatorToolBox
74+
75+
To initialize the `OperatorToolBox`, you need to provide an `AgentSpecification` and a list of datasets:
76+
77+
```python
78+
spec = AgentSpecification(
79+
name="GPT-4",
80+
version="4.0",
81+
description="A powerful language model",
82+
capabilities=["text-generation", "question-answering"],
83+
configuration={"max_tokens": 100},
84+
)
85+
86+
datasets = [{"name": "dataset1"}, {"name": "dataset2"}]
87+
88+
toolbox = OperatorToolBox(spec=spec, datasets=datasets)
89+
```
90+
91+
### Synchronous Usage
92+
93+
```python
94+
def run_dataset_manager_agent_sync():
95+
prompts = [
96+
"Validate the toolbox.",
97+
"Execute operation on 'dataset2'.",
98+
"Retrieve the results.",
99+
"Retrieve any failures."
100+
]
101+
102+
for prompt in prompts:
103+
result = dataset_manager_agent.run_sync(prompt, deps=toolbox)
104+
print(f"Response: {result.data}")
105+
```
106+
107+
### Asynchronous Usage
108+
109+
```python
110+
async def run_dataset_manager_agent_async():
111+
prompts = [
112+
"Validate the toolbox.",
113+
"Execute operation on 'dataset2'.",
114+
"Retrieve the results.",
115+
"Retrieve any failures."
116+
]
117+
118+
for prompt in prompts:
119+
result = await dataset_manager_agent.run(prompt, deps=toolbox)
120+
print(f"Response: {result.data}")
121+
```
122+
123+
These updates provide a more detailed and comprehensive understanding of the `operator.py` module, its classes, and its usage.

docs/quickstart.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Quickstart Guide
2+
3+
Welcome to the Quickstart Guide for Agentic Security. This guide will help you set up and start using the project quickly.
4+
5+
## Installation
6+
7+
To get started with Agentic Security, install the package using pip:
8+
9+
```shell
10+
pip install agentic_security
11+
```
12+
13+
## Initial Setup
14+
15+
After installation, you can start the application using the following command:
16+
17+
```shell
18+
agentic_security
19+
```
20+
21+
This will initialize the server and prepare it for use.
22+
23+
## Basic Usage
24+
25+
To run the main application, use:
26+
27+
```shell
28+
python -m agentic_security
29+
```
30+
31+
You can also view help options with:
32+
33+
```shell
34+
agentic_security --help
35+
```
36+
37+
## Running as a CI Check
38+
39+
Initialize the configuration for CI checks:
40+
41+
```shell
42+
agentic_security init
43+
```
44+
45+
This will generate a default configuration file named `agesec.toml`.
46+
47+
## Additional Commands
48+
49+
- List available modules:
50+
51+
```shell
52+
agentic_security ls
53+
```
54+
55+
- Run a security scan:
56+
57+
```shell
58+
agentic_security ci
59+
```
60+
61+
## Further Information
62+
63+
For more detailed information, refer to the [Documentation](index.md) or the [API Reference](api_reference.md).
64+
65+
This quickstart guide should help you get up and running with Agentic Security efficiently.

0 commit comments

Comments
 (0)