Skip to content

Conversation

@kriswuollett
Copy link

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
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

1 participant