Skip to content

Read-Only CLI JSON/SARIF Contract for api_executor MCP Integration

Contract Version: cis.mcp.contract.v1 Preset Catalog: conf/mcp_api_executor_presets.json Runtime: 100% PSL ONLY

1. Strict Read-Only Guarantee

  • Every MCP preset MUST enforce "read_only": true and "mutating": false.
  • Allowed presets: cis_list_targets, cis_audit_json, cis_audit_sarif, cis_remediate_dry_run.
  • Forbidden flags: -p, --password, --db-password, --apply, --allow-ephemeral-apply, --force, --sync-cis, --all, --auto-detect.
  • cis_remediate_dry_run runs remediation_generator.py with dry_run=True and executes zero system or database commands.

2. CLI Invocation, Targets & Exit Codes

  • Entrypoint: python3 audit_cis.py ... (or console script audit-cis ...).
  • Exit Codes: 0 = success, 1 = audit/runtime error, 2 = invalid CLI arguments.
  • 18 Canonical Targets (887 Controls): mariadb106, mariadb1011, mysql80, mysql-community84, mysql-enterprise84, mysql-community97, mysql-enterprise97, postgresql16, postgresql17, postgresql18, mongodb7, mongodb8, cassandra40, cassandra41, cassandra50, rhel8, rhel9, rhel10.
  • Preset Commands:
  • audit-cis --list-targets
  • audit-cis --target <target> --format json --lang <en|fr> --mode <local|ssh> --output <path.json>
  • audit-cis --target <target> --format sarif --lang <en|fr> --mode <local|ssh> --output <path.sarif>
  • audit-cis --remediate-dry-run --from-report <report.json> --remediation-format <diff|sql|shell|ansible|json> --remediation-output <out_path>
  • Optional Connection Flags: --docker, --remote, --ssh-port, --ssh-key, --db-host, --db-port, --db-user, --db-name, --defaults-file, --auth-db, --sudo.

3. Output Schemas & 5-State Taxonomy

  • 5-State Compliance Taxonomy: Pass, Fail, Error, Manual, Not Applicable.

JSON Report (--format json)

  • Top-level keys: benchmark (target on MariaDB), report_date, overall_score, total_checks, and results.
  • MariaDB emits results as dict[category, list[control]].
  • Other targets emit a flat list[control].
  • Normalize rows with sarif_exporter.normalize_control_results.

SARIF v2.1.0 (--format sarif)

  • Schema: https://json.schemastore.org/sarif-2.1.0.json, version: "2.1.0", runs[0].tool.driver.name: "cis-benchmarks-tools".
  • rules[] uses CIS-<RULE_SPEC>-<ID>.
  • results[] includes ruleId, kind, level, message.text, locations[0].physicalLocation.artifactLocation.uri, partialFingerprints.cisControlFingerprint/v1, properties.complianceState.
  • runs[0].properties includes target, ruleSpec, overallScore, counts, and executionContext.
  • Validate output via sarif_exporter.validate_sarif_document(doc).

Dry-Run Remediation JSON (--remediation-format json)

  • Top-level keys: dry_run: true, target, rule_spec, family, total_items, and items[].
  • Each item has control_id, compliance_state, action_type, requires_restart, risk_level, config_file, sql, shell, diff, verification_command, and optional manual_guidance.

4. Credential & Redaction Boundary

  • Inject database passwords strictly via the CIS_DB_PASSWORD environment variable. Never pass credentials in argv.
  • SecretSanitizer redacts all report strings from untrusted outputs.
  • api_executor traces must record preset name, sanitized args, exit code, and SHA-256 digest of generated output files.

5. Native JSON-RPC 2.0 Stdio MCP Server

  • Entrypoints: python3 mcp_server.py or cis-mcp-server (100% PSL ONLY, MCP protocol 2024-11-05, stdio loop with stderr diagnostics).
  • CLI Flags: --check (JSON health summary), --print-client-config (mcpServers JSON snippet), --version, or no flags (JSON-RPC 2.0 loop).
  • Methods: initialize, notifications/initialized, ping, tools/list, tools/call, resources/list, resources/read.
  • 5 Read-Only Tools (readOnlyHint: true, destructiveHint: false): cis_list_targets, cis_verify_specs, cis_audit_json, cis_audit_sarif, and cis_remediate_dry_run.
  • 3 Read-Only Resources: cis://targets (application/json), cis://presets (application/json), cis://contract (text/markdown).
  • Boundary: Reject unknown methods/tools (-32601), invalid params (-32602), parse errors (-32700), and forbidden flags. Inject passwords via CIS_DB_PASSWORD only, redact via SecretSanitizer, and emit output_sha256 digests.