Skip to content

fix: keep CrowdSec imports from disturbing live state and build exports safely - #1549

Merged
Wikid82 merged 8 commits into
developmentfrom
fix/crowdsec-export-hub-state
Oct 10, 2026
Merged

Wikid82 merged 8 commits into
developmentfrom
fix/crowdsec-export-hub-state

Conversation

@Wikid82

@Wikid82 Wikid82 commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-ups to #1542 for the CrowdSec configuration export and import, delivered as one PR.

Closes #1538, closes #1539, closes #1540

Testing

  • Backend: coverage 91.3% statements / 90.3% lines; patch coverage 93.6%; go test -race on the crowdsec package and on the import/export/rollback handler tests; full golangci-lint config clean (backend and agent). Local CodeQL: Go "4 suppressed, 0 blocking", JS 0.
  • E2E: the five CrowdSec security specs pass under --project=security-tests (92/92, no fixme).
  • Manual check in a throwaway container (not the live proxy), HEAD before the final hardening commit: 56 hub item links, cscli collections list (hash), the runtime state file and the bouncer key hash were identical before and after an export-then-import; the export held 39 entries, all under config/, with a correct Content-Length, and no hub, runtime state or bouncer entries. Recreating the container with no network logged the non-fatal hub update failure and CrowdSec started with all items intact.
  • A QA audit (docs/reports/qa_report.md) found no critical, high or medium issues; its two low findings are fixed in this PR.

Notes

The configuration export is now written to a temporary file while the data
lock is held, checked against the limits an import accepts, and only then
sent. A failure returns a clear error instead of a truncated download, a
slow download no longer blocks other operations, and unusual file types are
skipped.
Also enable the export download check now that the export is built before it
is sent.
Open each exported file without following links or blocking, confirm the
opened file is the one that was listed, stop writing the archive as soon as
it is larger than an import accepts, and document the ancestor-first rule
for live link checks.
@github-advanced-security

Copy link
Copy Markdown
Contributor

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Supply Chain Verification Results

✅ PASSED

📦 SBOM Summary

  • Components: 1870

🔍 Vulnerability Scan

Severity Count
🔴 Critical 0
🟠 High 0
🟡 Medium 0
🟢 Low 0
Total 0

📎 Artifacts

  • SBOM (CycloneDX JSON) and Grype results available in workflow artifacts

Generated by Supply Chain Verification workflow • View Details

@codecov

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.27053% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
backend/internal/api/handlers/crowdsec_handler.go 84.61% 12 Missing ⚠️
backend/internal/crowdsec/export.go 95.95% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

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