Skip to content

fix: check the CrowdSec diagnostics paths against the data folder properly - #1563

Merged
Wikid82 merged 1 commit into
developmentfrom
fix/crowdsec-diagnostics-path-containment
Oct 11, 2026
Merged

Wikid82 merged 1 commit into
developmentfrom
fix/crowdsec-diagnostics-path-containment

Conversation

@Wikid82

@Wikid82 Wikid82 commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Summary

The two path checks in the CrowdSec diagnostics config handler now use the existing pathWithin helper instead of a string-prefix test, so a sibling folder such as <data dir>_sibling can no longer pass. Extra pathWithin cases cover a ..foo name (accepted), real parent traversal and a sibling folder (rejected).

This takes over #1543 (opened against main; the ReadFile/WriteFile hunks were already moved on development). The original idea is credited with a Co-authored-by trailer.

Verification

  • go test ./internal/api/handlers/... -run 'Diagnostics|PathWithin|Crowdsec' -count=2 passes; full golangci-lint on the handlers package clean.
  • Hardening only: the paths are built from the data folder plus fixed names, so there is no failing handler test to write first.

Issue #1541 is already closed.

Claude Code helped produce this change.

…perly

The CrowdSec diagnostics now confirm the config and acquisition files
are really inside the data folder, so a neighbouring folder whose name
merely starts the same way is no longer accepted. Reuses the existing
path containment helper, and its tests now also cover names such as
"..foo" being accepted while real parent traversal is rejected.

Closes #1541

Co-authored-by: AdamMagued <AdamMagued@users.noreply.github.com>
@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

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 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Wikid82
Wikid82 marked this pull request as ready for review October 11, 2026 16:59
@Wikid82
Wikid82 merged commit d0de01b into development Oct 11, 2026
56 of 57 checks passed
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