Skip to content

Commit baf0687

Browse files
committed
Feat: API Documentation and Samples
1 parent 11672e7 commit baf0687

File tree

11 files changed

+5027
-1
lines changed

11 files changed

+5027
-1
lines changed

ossfuzz_py/README.md

Lines changed: 1499 additions & 0 deletions
Large diffs are not rendered by default.

ossfuzz_py/build/build_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import logging
3232
from typing import Any, Dict, List, Optional
3333

34-
from ossfuzz_py import BuildConfigError
3534
from ossfuzz_py.core.data_models import FuzzingEngine, ProjectConfig, Sanitizer
35+
from ossfuzz_py.errors import BuildConfigError
3636

3737
# Configure module logger
3838
logger = logging.getLogger('ossfuzz_sdk.build_config')

ossfuzz_py/samples/README.md

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
# OSS-Fuzz SDK Samples
2+
3+
This directory contains practical examples demonstrating how to use the OSS-Fuzz SDK for various fuzzing workflows and use cases.
4+
5+
## Sample Structure
6+
7+
```
8+
samples/
9+
├── README.md # This file
10+
├── basic/ # Basic usage examples
11+
│ ├── 01_quick_start.py # Getting started with the SDK
12+
│ ├── 02_configuration.py # Configuration management
13+
│ └── 03_simple_benchmark.py # Running a single benchmark
14+
├── intermediate/ # Intermediate examples
15+
│ ├── 01_build_operations.py # Build operations and management
16+
│ ├── 02_execution_workflows.py # Execution and run management
17+
│ ├── 03_result_analysis.py # Result analysis and metrics
18+
│ └── 04_pipeline_automation.py # Automated pipeline workflows
19+
├── advanced/ # Advanced use cases
20+
│ ├── 01_batch_processing.py # Batch processing multiple projects
21+
│ ├── 02_custom_workflows.py # Custom workflow orchestration
22+
│ ├── 03_monitoring_alerts.py # Monitoring and alerting systems
23+
│ └── 04_data_export_analysis.py # Data export and analysis
24+
├── production/ # Production deployment examples
25+
│ ├── 01_enterprise_config.py # Enterprise configuration setup
26+
│ ├── 02_ci_cd_integration.py # CI/CD pipeline integration
27+
│ ├── 03_monitoring_dashboard.py # Monitoring dashboard setup
28+
│ └── 04_automated_reporting.py # Automated reporting system
29+
├── utilities/ # Utility scripts and helpers
30+
│ ├── config_generator.py # Configuration file generator
31+
│ ├── health_checker.py # System health checker
32+
│ ├── data_migrator.py # Data migration utilities
33+
│ └── benchmark_validator.py # Benchmark validation tools
34+
└── data/ # Sample data and configurations
35+
├── sample_benchmarks.json # Sample benchmark definitions
36+
├── sample_configs/ # Sample configuration files
37+
└── test_data/ # Test data for examples
38+
```
39+
40+
## Getting Started
41+
42+
### Prerequisites
43+
44+
1. **Set up environment variables:**
45+
```bash
46+
export OSSFUZZ_HISTORY_STORAGE_BACKEND=local
47+
export OSSFUZZ_HISTORY_STORAGE_PATH=/tmp/ossfuzz_data
48+
export WORK_DIR=/tmp/ossfuzz_work
49+
```
50+
51+
2. **Run your first example:**
52+
```bash
53+
cd samples/basic
54+
python 01_quick_start.py
55+
```
56+
57+
## Sample Categories
58+
59+
### Basic Examples (`basic/`)
60+
61+
Perfect for users new to the OSS-Fuzz SDK. These examples cover:
62+
63+
- **Quick Start**: Initialize the SDK and run your first benchmark
64+
- **Configuration**: Set up SDK configuration for different environments
65+
- **Simple Benchmark**: Run a single benchmark with basic options
66+
67+
**Start here if you're new to the SDK!**
68+
69+
### Intermediate Examples (`intermediate/`)
70+
71+
For users familiar with basic concepts who want to explore more features:
72+
73+
- **Build Operations**: Manage build processes and artifacts
74+
- **Execution Workflows**: Control fuzzing execution and monitoring
75+
- **Result Analysis**: Analyze results and extract meaningful metrics
76+
- **Pipeline Automation**: Automate complete build → run → analyze workflows
77+
78+
### Advanced Examples (`advanced/`)
79+
80+
For experienced users implementing complex workflows:
81+
82+
- **Batch Processing**: Process multiple projects and benchmarks efficiently
83+
- **Custom Workflows**: Create custom orchestration and automation
84+
- **Monitoring & Alerts**: Set up monitoring systems and alerting
85+
- **Data Export & Analysis**: Advanced data analysis and reporting
86+
87+
### Production Examples (`production/`)
88+
89+
Enterprise-ready examples for production deployment:
90+
91+
- **Enterprise Configuration**: Production-grade configuration management
92+
- **CI/CD Integration**: Integrate with continuous integration systems
93+
- **Monitoring Dashboard**: Set up comprehensive monitoring
94+
- **Automated Reporting**: Create automated reporting systems
95+
96+
### Utilities (`utilities/`)
97+
98+
Helper scripts and tools to support your fuzzing workflows:
99+
100+
- **Configuration Generator**: Generate configuration files
101+
- **Health Checker**: Monitor system health and component status
102+
- **Data Migrator**: Migrate data between storage backends
103+
- **Benchmark Validator**: Validate benchmark definitions
104+
105+
## Use Case Guide
106+
107+
### I want to...
108+
109+
#### **Get started quickly**
110+
→ Start with `basic/01_quick_start.py`
111+
112+
#### **Set up configuration for my environment**
113+
→ Check `basic/02_configuration.py` and `production/01_enterprise_config.py`
114+
115+
#### **Run a single benchmark**
116+
→ Use `basic/03_simple_benchmark.py`
117+
118+
#### **Automate my fuzzing pipeline**
119+
→ Look at `intermediate/04_pipeline_automation.py`
120+
121+
#### **Process multiple projects**
122+
→ Try `advanced/01_batch_processing.py`
123+
124+
#### **Set up monitoring and alerts**
125+
→ Explore `advanced/03_monitoring_alerts.py`
126+
127+
#### **Integrate with CI/CD**
128+
→ Check `production/02_ci_cd_integration.py`
129+
130+
#### **Export and analyze data**
131+
→ Use `advanced/04_data_export_analysis.py`
132+
133+
#### **Deploy in production**
134+
→ Review all examples in `production/`
135+
136+
## Running the Examples
137+
138+
### Basic Usage
139+
140+
```bash
141+
# Navigate to the samples directory
142+
cd samples
143+
144+
# Run a basic example
145+
python basic/01_quick_start.py
146+
147+
# Run with custom configuration
148+
python basic/02_configuration.py --config-file data/sample_configs/dev.json
149+
150+
# Run an intermediate example
151+
python intermediate/01_build_operations.py --project libpng
152+
```
153+
154+
### Advanced Usage
155+
156+
```bash
157+
# Batch processing example
158+
python advanced/01_batch_processing.py --projects libpng,libjpeg,zlib
159+
160+
# Custom workflow with monitoring
161+
python advanced/02_custom_workflows.py --enable-monitoring
162+
163+
# Production deployment example
164+
python production/01_enterprise_config.py --environment production
165+
```
166+
167+
## Customization
168+
169+
### Modifying Examples
170+
171+
All examples are designed to be easily customizable:
172+
173+
1. **Configuration**: Modify the configuration sections at the top of each file
174+
2. **Parameters**: Adjust parameters like project names, timeouts, and options
175+
3. **Workflows**: Customize the workflow steps to match your requirements
176+
4. **Output**: Modify output formats and destinations
177+
178+
### Creating Your Own Examples
179+
180+
Use the existing examples as templates:
181+
182+
1. Copy a similar example as a starting point
183+
2. Modify the configuration and parameters
184+
3. Customize the workflow logic
185+
4. Add your specific requirements
186+
5. Test thoroughly before production use
187+
188+
## Sample Data
189+
190+
The `data/` directory contains:
191+
192+
- **Sample benchmark definitions** for testing
193+
- **Configuration templates** for different environments
194+
- **Test data** for running examples without real projects
195+
196+
## Troubleshooting
197+
198+
### Common Issues
199+
200+
1. **Import Errors**: Ensure the SDK is installed and in your Python path
201+
2. **Configuration Errors**: Check environment variables and configuration files
202+
3. **Permission Errors**: Ensure proper permissions for work directories
203+
4. **Component Unavailable**: Some examples require optional dependencies
204+
205+
### Getting Help
206+
207+
1. **Check the logs**: Most examples include detailed logging
208+
2. **Review the API documentation**: See `docs/API_DOCUMENTATION.md`
209+
3. **Run with debug mode**: Set `log_level='DEBUG'` in configuration
210+
4. **Check component availability**: Use the health checker utility
211+
212+
## Contributing
213+
214+
We welcome contributions to the samples! To add a new example:
215+
216+
1. Choose the appropriate category directory
217+
2. Follow the existing naming convention
218+
3. Include comprehensive comments and documentation
219+
4. Add error handling and logging
220+
5. Test thoroughly with different configurations
221+
6. Update this README with your example
222+
223+
## License
224+
225+
These samples are provided under the same license as the OSS-Fuzz SDK project.

0 commit comments

Comments
 (0)