Skip to content

feat: add LAPI capability detection and harden destructive tools - #123

Open
thib3113 wants to merge 5 commits into
mainfrom
feat/lapi-capability-hardening
Open

thib3113 wants to merge 5 commits into
mainfrom
feat/lapi-capability-hardening

Conversation

@thib3113

@thib3113 thib3113 commented Nov 3, 2026

Copy link
Copy Markdown
Owner

What changed

  • client: LAPI capability detection/probing (lapiVersion, detectCapabilities, strictCapabilities), typed FeatureNotSupportedError/LapiVersionUnknownError, safe contains:false defaults for ip/range, per-stream timers, stop()/login hardening, stricter parseExpiration, Decision.endAt from until.
  • mcp: dual bouncer+watcher credentials, passthrough auth, lazy per-client readiness, bounded deletes, explicit confirm=true guards for all and total ranges (/0, including scope=Range + whitespace), allowlist-over-denylist precedence, simulated coherence + old-LAPI fallback, _FILE secrets and credential redaction.
  • middleware / scenarios: optional-scenarios type shim (no runtime devDependency import), client option propagation, XFF cache keyed by remote address, IPv4-mapped normalization only for mapped /96+, IPv6 subnetLevel mapping (/128, /120, /112), MaxMind OpenOpts + loaded, safer live checks, HTTP URL parsing guard.
  • docs / CI: new docs/api-compatibility.md, live LAPI matrix workflow/script, release/docs corrections (SBOM, pnpm pinned via packageManager), examples and README updates.

Affected packages

  • crowdsec-client
  • crowdsec-http-middleware
  • crowdsec-client-scenarios
  • crowdsec-mcp
  • docs / examples / CI

Checklist

  • Tests added or updated (pnpm -F <package> test)
  • Lint passes (pnpm -F <package> lint)
  • README / docs updated if behavior or configuration changed
  • package.json metadata updated if the public API changed
  • No secrets or credentials committed

Verification

  • pnpm typecheck -> OK
  • pnpm -F crowdsec-client test -> 238 passed / 17 skipped
  • pnpm -F crowdsec-mcp test -> 282 passed / 11 skipped
  • pnpm -F crowdsec-http-middleware test -> 53 passed
  • pnpm -F crowdsec-client-scenarios test -> 19 passed
  • pnpm -r build -> OK
  • pnpm audit --prod --audit-level=high -> no known vulnerabilities
  • pnpm format:check -> OK
  • lint -> 0 errors (7 pre-existing warnings in generated files)

Security notes

  • Destructive tools require explicit confirmation for all=true and total ranges (/0), including scope=Range + value.
  • Deletes are bounded and fallbacks re-check the target set before deleting by id.
  • Credentials are redacted from logs/errors; _FILE secrets are supported and URL userinfo is masked.

Related issues

None.

- client: capability probing, version guard rails, safe delete defaults
- mcp: dual credentials, passthrough auth, bounded deletes, total-range guards
- middleware/scenarios: IPv4-mapped handling, XFF cache isolation, MaxMind options
- ci/docs: live LAPI matrix, compatibility matrix, release/docs fixes
- refactor cognitive-complexity hotspots and nested ternaries
- use String.raw, Object.hasOwn, node:http and readonly members
- drop unnecessary async from collectProbes, simplify secret file trimming
- group GITHUB_OUTPUT writes in the live matrix
- restore truthy narrow-target semantics and add empty-string test
- remove await on synchronous collectProbes and sync the test mock
- cover multi-newline _FILE secrets
- add .github/scripts/lapi-matrix/versions.txt as the single source
- workflow reads it (PR uses first/last, explicit dispatch still overrides)
- local script reads the same file (VERSIONS_FILE override), docs point to it
- keep the reduced pull_request matrix and the full workflow_dispatch matrix
- update api-compatibility docs
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants