Skip to content

DLP: honour a file policy's file_filters (backend contract #326) - #372

Merged
neamul602 merged 2 commits into
devfrom
feat/326-file-filters
Nov 2, 2026
Merged

neamul602 merged 2 commits into
devfrom
feat/326-file-filters

Conversation

@neamul602

Copy link
Copy Markdown
Contributor

Follow-up to the backend's merged file DLP contract (BrainStation-23/Compliance-OS#562, #566), which @Warhammer4000 confirmed on #326.

I compared the merged docs/dlp.md with the agent field by field. The bundle's modules.files, the exception shapes, the event objects and the capability gating all match. One gap: policies can carry file_filters (types, min_bytes, max_bytes), which the agent ignored. A policy meant only for some file types would have applied to every file.

Change

  • Types are lowercase extensions or detected types, as the backend validates them. A policy matches a file by:

    • its extension;
    • its detected type (ooxml.xlsx);
    • or the detected type's last part (xlsx), so a renamed file is still caught by its content.

    Archive entries are filtered on their own name and type, so an xlsx policy also catches a spreadsheet inside a zip.

  • Sizes apply before the scan: a file outside every policy's size range isn't read at all.

  • Unreadable filters are reported as a compile error, and the policy applies to every file. A bad filter must neither silence a policy nor reject a bundle the clipboard depends on.

Test plan

  • Policy tests: filters decoded and normalised (XLSX, .pdf); the size and type rules (including a renamed file); malformed filters tolerated and reported.
  • Decider tests: an out-of-range size isn't scanned; a match by extension; a renamed file matched by content; a different type gives no event, also when the file is unscannable; an xlsx entry in a zip matches; an entry of another type doesn't.
  • golangci-lint: 0 issues (linux, darwin, windows). The Linux DLP tests, make verify-cross and the changelog check pass.

Refs #326

🤖 Generated with Claude Code

The backend's merged contract (Compliance-OS#562) lets a policy carry
file_filters {types, min_bytes, max_bytes}, and the agent ignored them, so a
policy meant for some file types applied to every file.

- Types are lowercase extensions or detected types: a policy matches a file
  by its extension, its detected type (ooxml.xlsx) or the detected type's
  last part (xlsx), so a renamed file is still caught by its content.
  Archive entries are filtered on their own name and type.
- Sizes filter before the scan: a file outside every policy's size range is
  not read at all.
- file_filters are decoded tolerantly: unreadable ones are reported as a
  compile error and the policy applies to every file (a bad filter must not
  silence a policy, nor reject the clipboard's bundle).

Refs #326

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9879b0f6-f8cb-446f-b110-84aafe03ffb1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sonarqubecloud

sonarqubecloud Bot commented Nov 2, 2026

Copy link
Copy Markdown

@neamul602
neamul602 merged commit 7ade6d2 into dev Nov 2, 2026
23 checks passed
@neamul602
neamul602 deleted the feat/326-file-filters branch November 2, 2026 10:19
@neamul602 neamul602 mentioned this pull request Nov 2, 2026
Merged
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.

1 participant