Ollama Integration
DSO uses Ollama for local AI-powered analysis. This guide covers setup, configuration, and troubleshooting.
What is Ollama?
Ollama is a tool for running large language models locally on your machine. DSO uses it to:
- Analyze security scan results intelligently
- Explain vulnerabilities in natural language
- Prioritize issues based on business impact
- Identify false positives
Installation
macOS
brew install ollamaLinux
curl -fsSL https://ollama.ai/install.sh | shWindows
Download from ollama.ai or:
winget install Ollama.Ollama
# or
scoop install ollamaStarting Ollama
macOS / Linux
ollama serveThis starts Ollama in the foreground. For background:
# macOS (using launchd)
brew services start ollama
# Linux (using systemd)
systemctl --user start ollamaWindows
Ollama runs as a service automatically after installation.
Downloading Models
DSO works with various models. The installation script automatically installs qwen2.5:7b by default.
Default: qwen2.5:7b
ollama pull qwen2.5:7b- Size: ~4.7 GB
- Speed: Fast
- Quality: Excellent for security analysis
- Default: Automatically installed if no models exist
Alternative: llama3.1:8b
ollama pull llama3.1:8b- Size: ~4.7 GB
- Speed: Fast
- Quality: Excellent for security analysis
Lightweight: phi3
ollama pull phi3- Size: ~2.3 GB
- Speed: Very fast
- Quality: Good for basic analysis
Other Options
ollama pull mistral:7b # ~4.1 GB - Good balance
ollama pull gemma:7b # ~5.2 GB - Google's model
ollama pull llama3.1:70b # ~40 GB - Best quality (requires more RAM)Configuration
Model Selection
DSO uses the following priority order:
- Environment variable
DSO_MODEL - Configuration file
~/.dso/config - Default:
qwen2.5:7b
Via Environment Variable
# macOS / Linux
export DSO_MODEL=phi3
dso audit .
# Windows (PowerShell)
$env:DSO_MODEL="phi3"
dso audit .Via Configuration File
The installation script automatically saves the default model to ~/.dso/config:
# View current config
cat ~/.dso/config
# Output: DSO_MODEL=qwen2.5:7b
# Change model
echo "DSO_MODEL=llama3.1:8b" > ~/.dso/config
dso audit .Interactive Model Selection
During installation, you can select models interactively. The selected model is saved to ~/.dso/config.
Remote Ollama
If Ollama is on a different machine:
export OLLAMA_HOST=http://192.168.1.100:11434
dso audit .Permanent Configuration
Add to your shell profile:
macOS / Linux (~/.zshrc or ~/.bashrc):
export DSO_MODEL=qwen2.5:7b # Default model
export OLLAMA_HOST=http://localhost:11434Windows (PowerShell profile):
$env:DSO_MODEL="qwen2.5:7b"
$env:OLLAMA_HOST="http://localhost:11434"Or use configuration file (recommended):
# ~/.dso/config
DSO_MODEL=qwen2.5:7bThe configuration file is automatically created during installation.
Verification
Check that everything works:
dso checkThis verifies:
- Ollama connection
- Available models
- Configured model is installed
How DSO Uses Ollama
1. Analysis
When you run dso audit, DSO:
- Scans your codebase
- Formats results for AI
- Sends to Ollama with a security-focused prompt
- Receives intelligent analysis
- Displays prioritized findings
2. Explanation
When you run dso why, DSO:
- Sends vulnerability details to Ollama
- Receives natural language explanation
- Displays context-aware analysis
Performance Tips
Model Selection
- Development: Use
phi3for faster feedback - Production: Use
qwen2.5:7b(default) for excellent analysis - Large Projects: Use
llama3.1:70bfor best quality (requires ~40 GB RAM)
Resource Usage
Models use RAM:
phi3: ~2.3 GB RAMqwen2.5:7b: ~4.7 GB RAM (default)llama3.1:8b: ~4.7 GB RAMmistral:7b: ~4.1 GB RAMgemma:7b: ~5.2 GB RAMllama3.1:70b: ~40 GB RAM
Ensure you have enough RAM available.
First Run
The first analysis may be slower as the model loads. Subsequent analyses are faster.
Troubleshooting
Ollama Not Responding
Problem: connection refused
Solutions:
- Start Ollama:
ollama serve - Check if running:
ollama list - Verify port: Default is
11434 - Check firewall settings
Model Not Found
Problem: model not found
Solution: Download the model:
ollama pull llama3.1:8bSlow Responses
Problem: AI analysis is slow
Solutions:
- Use a lighter model:
export DSO_MODEL=phi3 - Ensure enough RAM available
- Close other applications
- Use a GPU if available (Ollama supports GPU acceleration)
Out of Memory
Problem: Model doesn't fit in RAM
Solutions:
- Use a smaller model:
phi3 - Increase available RAM
- Close other applications
Advanced Configuration
Custom Prompts
You can customize the AI prompt by creating:
templates/prompt_system.txtOr in your home directory:
~/.dso/templates/prompt_system.txtStreaming Responses
DSO uses streaming for real-time output. This is handled automatically.
Context Management
DSO maintains conversation context for better analysis. This is handled automatically.
Integration with CI/CD
For CI/CD, you can:
- Install Ollama in CI:
- name: Install Ollama
run: curl -fsSL https://ollama.ai/install.sh | sh- Download Model:
- name: Pull model
run: ollama pull qwen2.5:7b- Run DSO:
- name: Run audit
run: dso audit . --format jsonNote: CI environments may have limited resources. Consider using smaller models or running without AI analysis.
About the Developer
DSO is developed by Ismail MOUYAHADA, a DevSecOps Engineer and Multi-Platform Software Developer.
With expertise in security automation, cloud infrastructure, and cross-platform development, Ismail created DSO to bring enterprise-grade security analysis to developers' terminals with zero configuration and complete privacy.
See Also
check: Verify Ollama setupaudit: Run security audit with AIwhy: Get AI explanations- Ollama Documentation