Skip to content

Latest commit

 

History

History
1053 lines (826 loc) · 39.3 KB

configuration.md

File metadata and controls

1053 lines (826 loc) · 39.3 KB

Configuration

Table of Contents

Quick Start

Minimal working configuration — copy-paste this block and fill in your API key:

[project]
name = "my-project"
path = "/path/to/target"
languages = ["c"]

[llm.phases.discovery]
base_url = "https://api.mistral.ai/v1"
api_key = "${MISTRAL_API_KEY}"
model = "mistral-small"

[scanner.performance]
max_parallel_tasks = 4

Unknown Keys Are Rejected

A config key that no setting owns fails the load, with the key named and the keys that section does accept:

unknown field `enabled`, expected one of `rulesets`, `exclude_rules`, `custom_rules`

This applies to nested keys too. The alternative, which is what baco did before, is that an unknown key parses cleanly and is then dropped — leaving a config that looks applied and does nothing. That failure mode is silent and it hides settings that were renamed or removed, so the load fail instead.

If a config you carried over is rejected, the message names the key that is no longer recognised.

Project Settings

[project]
name = "my-project"
path = "/path/to/target"
languages = ["c", "cpp", "python"]

Scanner Settings

The [scanner] and [scanner.performance] sections control scanning behavior, pipeline phases, and performance tuning.

Performance Settings

[scanner.performance]
# Skip unchanged files based on SHA256 hash comparison (hashes persisted to output dir)
# Maximum number of parallel tasks for scanning operations
max_parallel_tasks = 4
# Early termination: stop scanning when Medium-and-above finding count exceeds this value
# Info findings are NOT counted toward the threshold (flood-resistant). Default: 1000.0
# Set to 0.0 to disable early termination
early_termination_threshold = 1000.0
# Enable file filtering to reduce false positives

# Root-cause deduplication (collapses findings that share the same root cause)
enable_root_cause_dedup = true
# Confidence refinement (re-calibrates finding confidence based on multi-source/cross-file signals)
enable_confidence_refinement = true
# Never-submit pattern filter - heavily penalizes findings matching known false-positive patterns
never_submit_enabled = true
# Multiplier applied to confidence when never-submit pattern matches (default 0.1)
never_submit_multiplier = 0.1
# CVE bootstrap (enriches findings with CVE data from external sources)
enable_cve_bootstrap = true
# Domain-routed hunt prompts: select per-attack-class prompt modules from prompts/hunt/
enable_hunt_prompts = true
Flag Default Side effects
early_termination_threshold 1000.0 None
max_parallel_tasks 4 None
enable_root_cause_dedup true None
enable_confidence_refinement true None
never_submit_enabled true None
never_submit_multiplier 0.1 None
enable_cve_bootstrap true External network requests to NVD/CISA
enable_hunt_prompts true None

See docs/architecture.md for the full 15-phase pipeline description.

Semgrep Configuration

[scanner.semgrep]
# Rulesets to use (array of strings). If empty, defaults are derived from project.languages:
#   - python -> "p/python"
#   - javascript/js -> "p/javascript"  
#   - php -> "p/php"
#   - c/cpp -> "p/c"
# Explicit rulesets are never overridden. Custom rules can be inlined via custom_rules.
# Recommended: pin semgrep version with `semgrep --version` in your CI/CD.
rulesets = [
    # "p/python",
    # "p/javascript",
]
# Rules to exclude (supports exact match and prefix match)
exclude_rules = ["html.security.plaintext-http-link"]
# Max file size (in bytes) passed to semgrep via --max-target-bytes.
# Files larger than this are skipped by semgrep without aborting the scan.
# When unset, semgrep uses its own default (~1 MiB).
max_target_bytes = 1048576
# Inline rule YAML documents (full `rules:` blocks) - materialized to temp files at scan time
custom_rules = ['''
rules:
  - id: my-custom-rule
    languages: [python]
    severity: ERROR
    message: example rule
    pattern: eval($X)
''']
# When true, pass `--no-git-ignore` to semgrep to scan files ignored by `.gitignore`
force_scan = false

Semgrep Severity Mapping

Semgrep findings have their severity determined by:

  1. First: extra.severity from semgrep output (ERROR→High, WARNING→Medium, INFO/INVENTORY→Low)
  2. Fallback: check_id keywords (e.g., "critical" in ID raises severity)
  3. Important: check_id keywords can only raise severity, never lower it

Router Configuration (MoE)

The [router] section configures the Mixture-of-Experts routing for per-CWE and per-language prompt/model selection.

[router]
enabled = false

# CWE-specific model overrides
[router.cwe_overrides]
"CWE-79" = { model_override = "mistral-small" }
"CWE-89" = { model_override = "qwen35" }
Field Type Default Description
enabled bool false Enable MoE routing
cwe_overrides map {} CWE ID → model override for that CWE's domain

LLM Configuration

BACO supports single or multiple models per phase. When multiple models are configured, they are used in round-robin fashion to distribute load across different models/providers.

Default temperature: 0.5 (controlled randomness for better security analysis)

Default max_reasoning_tokens: unset (None — no cap unless configured)

Global fallback: [llm] base_url applies to every phase without its own base_url:

[llm]
base_url = "https://api.mistral.ai/v1"
timeout_secs = 60
max_retries = 3
retry_backoff_ms = 1000
max_concurrent = 4
temperature = 0.5
enable_llm_cache = false
cache_dir = null

Per-phase overrides: Each phase supports optional timeout_secs and temperature overrides:

[llm.phases.discovery]
base_url = "https://api.mistral.ai/v1"
api_key = "${MISTRAL_API_KEY}"
model = "mistral-small"
timeout_secs = 120      # Per-phase timeout override
temperature = 0.3       # Per-phase temperature override

Timeout Semantics

Timeout configuration operates at two levels:

Level Config Path Type Default Behavior
Global [llm] timeout_secs u64 60 (in config.example.toml) Applied to all phases without a per-phase override
Per-phase [llm.phases.<phase>] timeout_secs Option<u64> None When set, overrides the global timeout for that phase

Runtime behavior:

  • HTTP request timeout: Duration::from_secs(timeout_secs) (source: src/llm/mod.rs:236)
  • Connection timeout: Fixed at 10 seconds (source: src/llm/mod.rs:192)
  • Default runtime timeout (if no config provided): 30 seconds (source: src/llm/mod.rs:170)

What value 0 means: Setting timeout_secs = 0 results in Duration::from_secs(0), which causes an immediate timeout on every request. Use only for testing.

Retry behavior: Failed requests (429, 5xx, network errors) are retried with exponential backoff:

  • Base delay: Configured via [llm] retry_backoff_ms (default: 1000ms)
  • Formula: base_ms * 2^attempt, capped at 30 seconds
  • Max retries: Configured via [llm] max_retries (default: 3)
  • Source: src/llm/mod.rs:254-269

Retries are bounded; after exhausting retries on one model, the client fails over to the next configured model (if multiple models are specified).

Single model:

[llm.phases.discovery]
base_url = "https://api.mistral.ai/v1"
api_key = "${MISTRAL_API_KEY}"  # or set env var
model = "mistral-small"
temperature = 0.5
max_reasoning_tokens = 2048

Multiple models:

[llm.phases.discovery]
base_url = "https://api.mistral.ai/v1"
api_key = "${MISTRAL_API_KEY}"
# 'models' takes precedence over 'model' if both are present
models = ["mistral-small", "mistral-medium", "codestral-latest"]

[llm.phases.verification]
base_url = "https://api.qwen.ai/v1"
api_key = "${QWEN_API_KEY}"
model = "qwen35"  # single model

[llm.phases.aggregation]
base_url = "https://api.openai.com/v1"
api_key = "${OPENAI_API_KEY}"
models = ["gpt-4o", "gpt-4o-mini"]  # multiple models for distributed load

Note: The models array takes precedence over model if both are present. Models are selected in round-robin fashion to distribute load across different providers.

Agent Mode

BACO has two distinct agent modes:

Discovery Agent

When enabled, the LLM Discovery phase reads source files directly before analyzing findings:

[agent]
enabled = false
max_turns = 10           # Max conversation turns with tools
tool_timeout_secs = 60   # Timeout for tool execution
run_compiled_code = false  # Allow the agent to run code it compiled (see below)

run_compiled_code gates the test_run tool. While it is false (the default) the agent can still compile a test case, but the tool that would execute it is neither registered nor offered to the model, so generated code never runs on the host. Set it to true only where executing model-authored code on the scanning machine is an accepted risk.

Benefits:

  • LLM reads actual source code before enriching findings
  • Uses tools (file_read, pattern_search) for deeper analysis
  • Provides more accurate vulnerability descriptions with context

SecurityAgent Verification (Phase 10)

A separate verification phase that uses an embedded security agent with tools to prove or disprove findings:

  • file_read: Examine vulnerable code in context
  • pattern_search: Look for related vulnerability patterns
  • file_write: Create proof-of-concept test cases
  • run_test: Execute tests to verify exploitability

The agent automatically removes false positives when tests pass, reducing noise in the final report. This phase runs after Validate (Phase 9) and before Ticket Cross-Reference (Phase 11).

Prompt Customization

BACO uses prompt templates for each phase loaded from markdown files at runtime. You can override these via configuration:

Default prompts are stored in prompts/phases/ as markdown files:

  • prompts/phases/indexing.md
  • prompts/phases/semgrep.md
  • prompts/phases/llm_static_analysis.md
  • prompts/phases/llm_discovery.md
  • prompts/phases/llm_verification.md
  • prompts/phases/reporting.md

View the full prompt templates on GitHub to understand default behavior.

Inline override in config.toml:

[llm.phases.prompt_overrides.phases]
llm_static_analysis = """Analyze this %%LANGUAGE%% code for security vulnerabilities.
Focus on: memory safety, injection risks, and insecure API usage.

File: %%FILE_PATH%%
Code:
%%CODE_CONTENT%%
"""

llm_discovery = """Given this finding, determine if it's a true vulnerability:
Title: %%FINDING_TITLE%%
Location: %%FILE_PATH%%:%%LINE_NUMBER%%
Current Description: %%CURRENT_DESCRIPTION%%
Description: %%VULNERABILITY_DESCRIPTION%%
"""

Template Variables

Available template variables:

  • %%PROJECT_PATH%% - Target project path
  • %%PROJECT_NAME%% - Project name
  • %%FILE_EXTENSIONS%% - Detected file extensions
  • %%LANGUAGES%% - Target languages
  • %%CODE_CONTENT%% - Code snippet being analyzed
  • %%LANGUAGE%% - Programming language of the file
  • %%FILE_PATH%% - File path
  • %%LINE_NUMBER%% - Specific line number
  • %%LINE_RANGE%% - Line numbers range
  • %%CURRENT_DESCRIPTION%% - Current vulnerability description (for iterative phases)
  • %%FINDING_TITLE%% - Vulnerability title
  • %%VULNERABILITY_DESCRIPTION%% - Description text
  • %%FINDINGS_COUNT%% - Total findings count
  • %%SCAN_DATE%% - Scan date
  • %%TOTAL_FINDINGS%% - Total findings count (alias)
  • %%TOTAL_FILES%% - Total files scanned
  • %%FILES_COUNT%% - Files count (alias)
  • %%SOURCE_LIST%% - List of source files
  • %%CONTEXT_LINES%% - Context lines around finding
  • %%CWE_SPECS%% - CWE specification details
  • %%EXCLUDE_PATHS%% - Excluded paths
  • %%MAX_FILE_SIZE%% - Maximum file size limit
  • %%PROJECT_TYPE%% - Project type
  • %%SCAN_DURATION%% - Scan duration
  • %%TICKET_SYSTEMS%% - Configured ticket systems
  • %%TOOLS_USED%% - Tools used in analysis
  • %%VULNERABILITY_LIST%% - List of vulnerabilities
  • %%VULNERABILITY_TITLE%% - Vulnerability title
  • %%FINDINGS_LIST%% - Full findings list

Prompts are validated (max 10,000 characters, no null bytes) before use.

Ticket Systems

[[tickets.systems]]
system_type = "github"
url = "https://api.github.com"
api_key = "${GITHUB_TOKEN}"

Output Configuration

[output]
# Directory where reports and checkpoints will be written
dir = "./baco-output"
# Evidence gate (default: false). When true, only findings classified as
# verified or supported reach report.html, report.sarif, and report.md;
# findings.json always contains every finding with its verification_tier attached
# and is never filtered.
evidence_gate = false
# Include rejected findings (investigated & dismissed) in JSON/HTML reports
include_rejected = false
Field Type Default Description
dir str "./baco-output" Output directory for reports and checkpoints
evidence_gate bool false When true, only findings classified as verified or supported by the evidence gate reach report.html, report.sarif, and report.md. findings.json is never filtered and always contains every finding with its verification_tier attached.
include_rejected bool false When true, rejected findings (investigated & dismissed) are persisted in the JSON report's rejected array and shown in the HTML report's "Investigated & Dismissed" appendix.

Environment Variables

Env Var Usage
LLM_API_KEY Fallback for any llm.phases.<slot>.api_key when the slot-specific LLM_<SLOT>_KEY is unset
LLM_DISCOVERY_KEY Overrides llm.phases.discovery.api_key
LLM_VERIFICATION_KEY Overrides llm.phases.verification.api_key
LLM_AGGREGATION_KEY Overrides llm.phases.aggregation.api_key
LLM_STATIC_ANALYSIS_KEY Overrides llm.phases.static_analysis.api_key
LLM_CONFIG_PATH Overrides config path for baco verify (source: src/cli/verify.rs:24)
NO_COLOR Disables colored output (source: src/ui.rs:46)
TICKET_GITHUB_KEY Overrides [[tickets.systems]] api_key for GitHub
TICKET_GITLAB_KEY Overrides [[tickets.systems]] api_key for GitLab

Output Formats

  • findings.json: Complete vulnerability data with all fields. Never filtered by the evidence gate; it carries a verification_tier so you can filter it yourself
  • report.html: Visual report with severity colors, code snippets, AI summary
  • report.sarif: SARIF format for CI/CD integration, written by baco report --format sarif (a scan does not produce it)

Scan Options

Dry Run

The --dry-run flag performs indexing and prioritization without executing any LLM or semgrep phases. It prints an estimate of the resources a full scan would consume, then exits.

What it does:

  1. Indexes the project (counts files, calculates total size, estimates tokens)
  2. Computes priority scores for each file
  3. Estimates LLM calls based on budget and triage configuration
  4. Prints the summary and exits

What it does NOT do:

  • No LLM API calls
  • No semgrep scanning
  • No findings produced
  • No report generation

Example usage:

baco scan --config baco.toml --dry-run

Output example:

[Dry Run] Project Estimate
═══════════════════════════════════════
Target: ./my-project

Files by language:
  python: 42 files
  javascript: 18 files

Total files: 60
Total size: 1234567 bytes
Estimated tokens (~4 chars/token): 308641

Planned LLM calls: 45
  (budget max: 100, normal cap: 75, high-risk: 25)

Average priority score: 0.67

Use --dry-run before a full scan to:

  • Estimate costs (LLM call count, token usage)
  • Verify your configuration is correct
  • Check which files will be analyzed
  • Decide if you need to adjust budget/triage settings

Source: src/cli/scan.rs:360-492 (run_dry_run function).

Aggregation Configuration

The [aggregation] section configures the AI Aggregation phase settings.

[aggregation]
# Path to the false positive store JSON file
fp_store_path = "./fp-store.json"
Field Type Default Description
fp_store_path str None Path to JSON file storing false positive patterns

Validate (CORRECT paper)

LLM-as-judge rationale validation: evaluates the soundness of reasoning behind each finding and adjusts confidence accordingly (+0.10 sound, -0.20 flawed).

Field Type Default Description
enabled bool false Enable Validate phase
[validate]
enabled = false

VulTriage (P1)

Triple-path context augmentation. Prepends control path (AST/CFG/DFG), knowledge path (CWE pattern RAG), and semantic path (function summary) to the LLM prompt before the vulnerability judgement.

Field Type Default Description
enabled bool false Enable triple-path augmentation
semantic_path bool true Include function summary
[vultriage]
enabled = false
semantic_path = true

VulnLLM-R Policy Sampling (P2.2)

Policy-based CWE generation. Queries the LLM N times to build a candidate set, then a final call picks one label. Increases LLM cost ~5x.

Field Type Default Description
enabled bool false Enable policy sampling
samples int 4 Number of candidate samples
[policy_sampling]
enabled = false
samples = 4

VulnLLM-R Agent Scaffold (P2.5)

Builds 3-path call-graph context + function-lookup tool per target for agent-assisted analysis.

Field Type Default Description
enabled bool false Enable agent scaffold
max_rounds int 5 Max agent conversation rounds
paths_per_target int 3 Call-graph paths per target
[agent_scaffold]
enabled = false
max_rounds = 5
paths_per_target = 3

Truncated Generation (P2.1)

Caps reasoning tokens before forcing the final answer. Configured in the [llm] section.

Field Type Default Description
max_reasoning_tokens int None Max tokens for reasoning phase
[llm]
max_reasoning_tokens = 2048

PacVD Primitive-API Abstraction (P4)

Appends callee abstraction at one of four granularity levels to the LLM prompt. Level 1 = fuzzy branches only; Level 4 = concrete branches + key variables.

Field Type Default Description
enabled bool false Enable primitive-API abstraction
level int 2 Abstraction granularity (1-4)
auto_level bool false Auto-select optimal level
[pacvd]
enabled = false
level = 2
auto_level = false

Citation Verification Gate

Deterministic verification that report citations (file paths + line ranges) match the scanned source tree before rendering. Findings failing the check have confidence halved and a note added.

Field Type Default Description
enabled bool false Enable citation verification gate
[citation_verification]
enabled = false

See docs/argus-analysis.md for the technique rationale.

Prior-Runs Store

Cross-run findings history: Confirmed/FalsePositive findings from prior scans are injected as skip-lists into discovery prompts, reducing redundant analysis. Runs saved under {output_dir}/runs/.

Field Type Default Description
enabled bool false Enable prior-runs store
max_runs int 5 Number of recent runs to load (most recent first)
[prior_runs]
enabled = false
max_runs = 5

Org-Context Profile

Organizational policy profile injected into discovery and verification prompts for calibration. Prevents false positives by encoding where secrets live, stack/infra context, and severity preferences.

Field Type Default Description
enabled bool false Enable org-context profile
stack array [] Technology stack (e.g., ["php", "javascript"])
infra array [] Infrastructure (e.g., ["aws", "docker"])
data_sensitivity str None Data classification (e.g., "pii" → treat personal data as High)
secret_storage str None Secret management location (e.g., "vault" → ${VAULT_TOKEN} refs are placeholders, NOT leaks)
risk_tolerance str None Risk posture (e.g., "low" → prioritize ruthlessly, report everything real)
severity_rules map {} Per-rule severity overrides (e.g., { "XSS" = "Critical" })
[org_context]
enabled = false
stack = ["php", "javascript"]
infra = ["aws", "docker"]
data_sensitivity = "pii"
secret_storage = "vault"
risk_tolerance = "low"
severity_rules = { "XSS" = "Critical", "SQLi" = "Critical" }

See docs/argus-analysis.md for technique #5 (prompt calibration).

Domain-Routed Hunt Prompts

Per-attack-class prompt modules from prompts/hunt/ selected by target languages during LLM discovery. Each module includes scope/lane discipline sections; verification prompt has skeptical self-refutation gate + untrusted-content framing.

Field Type Default Description
enable_hunt_prompts bool true Enable domain-routed hunt prompts
[scanner.performance]
enable_hunt_prompts = true

Available modules: injection.md, auth.md, authz_absence.md, xss.md, path_traversal.md, crypto.md, resource.md, deserialization.md, memory_safety.md.

Taint Rules

Taint rules are always derived from the project languages (python, javascript/typescript, go, php, c/cpp, java, ruby, csharp). Explicit custom_rules no longer suppress them; when a rule id exists in both, the explicit one wins.

CWE classes covered per language:

  • SQLi: CWE-89 (all languages)
  • Command injection: CWE-78 (all languages)
  • Path traversal: CWE-22 (all languages)
  • Deserialization: CWE-502 (php, java, csharp)
  • Code injection: CWE-94 (ruby)

Confidence Normalization

Normalizes confidence scores using project baselines or isotonic regression.

Field Type Default Description
enabled bool false Enable normalization
normalization_tier str "None" Normalization tier (None, ProjectRelative, Isotonic)
project_baseline_path str None Path to project baseline file
[normalization]
enabled = false
normalization_tier = "None"
project_baseline_path = null

Triage Configuration

The [triage] section configures the triage cascade (T17). First pass: cheap model triage per file to filter out non-suspicious files. Second pass: deep analysis only on files that pass the suspicion threshold.

Field Type Default Description
enabled bool false Enable triage cascade
model str "mistral-small" Model to use for triage pass
batch_size u8 8 Batch size for triage requests
suspicion_threshold f32 0.35 Suspicion threshold for deep analysis
[triage]
enabled = false
model = "mistral-small"
batch_size = 8
suspicion_threshold = 0.35

Priority Configuration

The [priority] section configures file prioritization (T18). Scores files based on recency, entry-point status, and size to prioritize LLM budget.

Field Type Default Description
enabled bool false Enable prioritization
git_recent_boost f32 2.0 Boost factor for recently modified files (git or mtime < 7 days)
entry_point_boost f32 1.5 Boost factor for entry-point files (main., index., app., server., init.*)
small_file_boost f32 1.2 Boost factor for small files (< 10KB)
entry_point_patterns array [] Path/content patterns that mark a file as an entry point (empty = built-in defaults)
sink_patterns array [] Content substrings that mark a file as security-relevant; a match boosts priority
[priority]
enabled = false
git_recent_boost = 2.0
entry_point_boost = 1.5
small_file_boost = 1.2
entry_point_patterns = []
sink_patterns = []

Budget Configuration

The [budget] section configures LLM budget enforcement (T18). Limits total LLM calls and reserves budget for high-risk files.

Field Type Default Description
enabled bool false Enable budget enforcement
max_llm_calls usize 200 Maximum total LLM calls (triage + deep analysis)
reserve_percent_for_high_risk u8 20 Percent of budget to reserve for high-risk files
[budget]
enabled = false
max_llm_calls = 200
reserve_percent_for_high_risk = 20

Knowledge Configuration

The [knowledge] section configures the knowledge base: per-CWE false-positive indicator patterns, required security primitives, and framework-specific hook registries.

[knowledge]
# CWE id ("CWE-79") -> literal code substrings indicating a likely false positive
fp_patterns = { "CWE-79" = ["esc_html(", "esc_attr(", "wp_kses_post("] }
# Language-keyed primitives that must guard privileged actions; verification prompt references them.
required_security_primitives = { "php" = ["wp_verify_nonce", "check_admin_referer", "current_user_can"] }
# Per-language hook registry configuration for framework-specific entry point detection
hook_registry = { "php" = { hook_label = "entry_point", registrations = ["(?si)add_action\\s*\\("] } }
Field Type Default Description
fp_patterns map {} CWE ID → list of false-positive indicator strings
required_security_primitives map {} Language → list of required security primitives
hook_registry map {} Language → HookRegistryLanguageConfig with hook_label, registrations regexes, and optional handler_patterns override

VulnSpec Configuration

The [vuln_spec] section configures the VulInSpec security specification extraction and retrieval system (arXiv:2511.04014).

Field Type Default Description
enabled bool false Enable VulInSpec
db_path str "vuln_spec_db.json" Path to the specification database (JSON file)
auto_extract_from_patches bool false Automatically extract specs from incoming patches
[vuln_spec]
enabled = false
db_path = "vuln_spec_db.json"
auto_extract_from_patches = false

Presets

Presets are bundled TOML overlays that pre-configure BACO for a target project type. They set language lists, exclude paths, semgrep rulesets, triage, budget, and per-CWE false-positive patterns in one step.

Loading order: built-in defaults → preset file → user config.toml → environment → CLI flags. A key set in your config.toml wins over the same key in the preset, so a preset is a starting point rather than an override. Only the keys a preset actually declares are touched; [scanner.performance] is merged key by key.

Built-in Presets

Preset Target Languages
wordpress-core WordPress core audit php, javascript
wordpress-plugin WordPress plugin audit php
django Django web application audit python
laravel Laravel web application audit php
cpp C/C++ security audit (memory safety, command injection) cpp
litellm LiteLLM proxy codebase python
oss-python Generic OSS Python project python
oss-monorepo Polyglot OSS monorepo python, rust
# List available presets (built-in + ~/.config/baco/presets/*.toml)
baco preset list

Preset TOML Structure

A preset file is a partial ScannerConfig. Every section is optional; unset sections fall through to defaults or the user config.

# presets/wordpress-core.toml
[project]
name = "wordpress-core"
path = "./wordpress"
languages = ["php", "javascript"]

[scanner]
max_file_size_kb = 256
exclude_paths = ["wp-content/*", "tests/*", "*.min.js"]

[scanner.semgrep]
rulesets = ["p/wordpress", "p/php", "p/security"]
# Inline semgrep rule YAML (full `rules:` blocks), materialized to temp files
# at scan time and passed as extra --config args. Keeps presets self-contained.
custom_rules = ['''
rules:
  - id: my-custom-rule-high
    languages: [php]
    severity: ERROR
    message: example rule
    pattern: eval($X)
''']

[scanner.performance]
enable_root_cause_dedup = true

[llm]
timeout_secs = 90
max_concurrent = 6
temperature = 0.2

[llm.phases.discovery]
models = ["mistral-small"]

[llm.phases.verification]
model = "mistral-medium"

[triage]
enabled = true
model = "mistral-small"
batch_size = 8
suspicion_threshold = 0.35

[priority]
entry_point_patterns = ["wp-admin/admin-post.php", "xmlrpc.php"]
sink_patterns = ["$wpdb->query", "unserialize(", "eval("]

[budget]
enabled = true
max_llm_calls = 600

[knowledge.fp_patterns]
"CWE-79"  = ["esc_html(", "esc_attr(", "wp_kses_post("]
"CWE-89"  = ["$wpdb->prepare("]
"CWE-352" = ["check_admin_referer(", "wp_verify_nonce("]
"CWE-862" = ["current_user_can(", "is_admin()"]

[knowledge.required_security_primitives]
"php" = ["wp_verify_nonce", "check_admin_referer", "check_ajax_referer", "current_user_can", "user_can"]

[knowledge.hook_registry.php]
hook_label = "rest_route"
registrations = [
    '''(?si)add_action\s*\(\s*[\x27\x22]((?:wp_ajax|wp_ajax_nopriv|admin_post|admin_post_nopriv)[^\x27\x22]*)[\x27\x22]\s*,\s*''',
    '''(?si)register_rest_route\s*\([^;]*?[\x27\x22]callback[\x27\x22]\s*=>\s*''',
]

[agent]
enabled = false
max_turns = 10
tool_timeout_secs = 60

Custom Presets

Drop a *.toml file in ~/.config/baco/presets/ and it appears in baco preset list and is loadable via --preset <name>:

mkdir -p ~/.config/baco/presets
cp presets/wordpress-core.toml ~/.config/baco/presets/my-project.toml
# Edit ~/.config/baco/presets/my-project.toml, then:
baco scan --config my.toml --preset my-project

Name the preset in the config instead of on the command line:

preset = "my-project"

[project]
name = "my-project"
path = "."

--preset wins when both are present, since passing it is a deliberate override. A name that does not resolve fails the load and names the preset, rather than quietly scanning with no preset applied.

Presets matter more than the flag suggests: they carry required_security_primitives and the hook registry, which is what the entry-point primitive check reads. A scan run without the WordPress preset finds no missing-nonce findings, because it has no list of nonce functions to check against.

Fields a Preset Can Override

Section Key fields
project name, path, languages
scanner max_file_size_kb, exclude_paths, semgrep.rulesets, semgrep.custom_rules, performance.*
llm timeout_secs, max_concurrent, temperature, phases.*
triage enabled, model, batch_size, suspicion_threshold
priority enabled, git_recent_boost, entry_point_boost, small_file_boost, entry_point_patterns, sink_patterns
budget enabled, max_llm_calls, reserve_percent_for_high_risk
agent enabled, max_turns, tool_timeout_secs
knowledge fp_patterns (map of CWE → list of false-positive indicator strings), required_security_primitives (map of language → list of required primitives), hook_registry (map of language → HookRegistryLanguageConfig with hook_label, registrations regexes with optional (?P<hook>) capture, handler_patterns override)

Unset fields keep the base ScannerConfig default; CLI flags still override the preset.

Eval Suite

The [eval] section configures the detection-regression suite run by baco eval.

Key Type Default Description
floor f32 0.70 Minimum aggregate pass-rate (0.0-1.0). The suite fails when the aggregate does not strictly exceed it. BACO_EVAL_FLOOR overrides it per invocation.
[eval]
floor = 0.9

Agent Scaffold

The [agent_scaffold] section configures the call-graph-guided agent scaffold used during security-agent verification.

Key Type Default Description
enabled bool false Enables the agent scaffold modules
max_rounds u8 built-in Maximum interaction rounds per target function
paths_per_target u8 built-in Number of call-graph paths to sample per target
[agent_scaffold]
enabled = false

Citation Verification

The [citation_verification] section controls verification that finding citations (file + line) actually resolve in the target source.

A citation that does not resolve gets verification_status = failed and a note in verification_notes. The finding is kept and its confidence is left alone: confidence is the model's own estimate, and multiplying it by a constant corrupts that estimate without saying anything about how wrong the citation is. Whether failed findings reach the report is decided by [output] evidence_gate; include_rejected keeps them visible when it is on.

Key Type Default Description
enabled bool true Verify finding citations against source files
[citation_verification]
enabled = true

Prior Runs

The [prior_runs] section configures the cross-run findings history used for skip directives and coverage-gap targeting on subsequent scans.

Key Type Default Description
enabled bool false Enable the prior-runs store
max_runs usize built-in Maximum number of prior runs retained
[prior_runs]
enabled = false

Policy Sampling

The [policy_sampling] section configures policy-based sampling rounds (VulnLLM-R style generation).

Key Type Default Description
enabled bool false Enable policy-based generation
samples u8 4 Number of sampling rounds used to build the policy
[policy_sampling]
enabled = false

Tickets

The [tickets] section configures cross-referencing findings against external ticket systems.

Each entry in systems describes one ticket backend:

Key Type Description
system_type string "github" or "gitlab"
url string Base URL of the system
api_key string (option) API token; TICKET_GITHUB_KEY / TICKET_GITLAB_KEY environment variables override it
[[tickets.systems]]
system_type = "github"
url = "https://github.com/org/repo"