Skip to content

Add regex file filtering policy#169

Merged
rtimush merged 6 commits intocoralogix:masterfrom
kriswuollett:regex-policies
Nov 10, 2025
Merged

Add regex file filtering policy#169
rtimush merged 6 commits intocoralogix:masterfrom
kriswuollett:regex-policies

Conversation

@kriswuollett
Copy link
Contributor

Refactors the file policy code and adds an implementation for a regex filter. Motivating use case is filtering out test protos that may be in third party repos. Used URI-like prefix to allow for later easier addition of other filter policy implementations.

Closes #168

An example usage of the regex policy that was tested manually:

[protobuf]
url = "github.com/protocolbuffers/protobuf"
protocol = "https"
revision = "938d3bdf860dfc3c9a55bc5961ce1ecdb1a87e0f"
allow_policies = ["google/protobuf/*"]
deny_policies = ["re://compiler|bridge|sample|test"]
content_roots = ["src"]

Yields:

% tree protos/google/protobuf 
protos/google/protobuf
├── any.proto
├── api.proto
├── cpp_features.proto
├── descriptor.proto
├── duration.proto
├── empty.proto
├── field_mask.proto
├── internal_options.proto
├── late_loaded_option.proto
├── late_loaded_option_user.proto
├── source_context.proto
├── struct.proto
├── timestamp.proto
├── type.proto
├── util
│   ├── json_format.proto
│   └── json_format_proto3.proto
└── wrappers.proto

2 directories, 17 files

An example usage of the regex policy:

```toml
[protobuf]
url = "github.com/protocolbuffers/protobuf"
protocol = "https"
revision = "938d3bdf860dfc3c9a55bc5961ce1ecdb1a87e0f"
allow_policies = ["google/protobuf/*"]
deny_policies = ["re://compiler|bridge|sample|test"]
content_roots = ["src"]
```

Closes coralogix#168
@rtimush rtimush requested a review from a team October 31, 2025 09:11
Copy link
Collaborator

@rtimush rtimush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great to me, thank you for the contribution!

@rtimush rtimush merged commit 055d603 into coralogix:master Nov 10, 2025
16 checks passed
@rtimush rtimush mentioned this pull request Nov 10, 2025
rtimush added a commit that referenced this pull request Nov 11, 2025
## 🤖 New release

* `protofetch`: 0.1.13 -> 0.1.14 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.1.14](v0.1.13...v0.1.14)
- 2025-11-10

### Other

- Add regex file filtering policy
([#169](#169))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
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.

File policies based on file names not necessarily paths

2 participants