Skip to content

Add file server filter#43243

Merged
ravenblackx merged 26 commits into
envoyproxy:mainfrom
ravenblackx:file_server
Feb 26, 2026
Merged

Add file server filter#43243
ravenblackx merged 26 commits into
envoyproxy:mainfrom
ravenblackx:file_server

Conversation

@ravenblackx
Copy link
Copy Markdown
Contributor

@ravenblackx ravenblackx commented Jan 30, 2026

Commit Message: Add file server filter
Additional Description: Filter facilitates asynchronous serving from files. Simplistic configuration for the common use-case. Further features (e.g. exclusions) can be added later as needed. Secured against path-escapes by using std::filesystem::path to verify that the path requested isn't altered by normalization, and that it's within a path explicitly configured to be shared.
Risk Level: Negligible, as no change to existing operations, it's a new filter. It's marked work in progress and not assured secure, so should not be adopted at this time without due caution.
Testing: I think there's 100% coverage, but CI isn't running right now.
Docs Changes: New docs for it.
Release Notes: Will add at the end, to minimize annoying merge conflicts.
Platform Specific Features: Windows not supported, as AsyncFile operations don't currently support Windows.

Signed-off-by: Raven Black <ravenblack@dropbox.com>
@repokitteh-read-only
Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #43243 was opened by ravenblackx.

see: more, trace.

@ravenblackx
Copy link
Copy Markdown
Contributor Author

/coverage

@repokitteh-read-only
Copy link
Copy Markdown

Coverage for this Pull Request will be rendered here:

https://storage.googleapis.com/envoy-cncf-pr/43243/coverage/index.html

For comparison, current coverage on main branch is here:

https://storage.googleapis.com/envoy-cncf-postsubmit/main/coverage/index.html

The coverage results are (re-)rendered each time the CI Envoy/Checks (coverage) job completes.

🐱

Caused by: a #43243 (comment) was created by @ravenblackx.

see: more, trace.

Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
@ravenblackx ravenblackx marked this pull request as ready for review February 2, 2026 19:24
@repokitteh-read-only repokitteh-read-only Bot added api deps Approval required for changes to Envoy's external dependencies labels Feb 2, 2026
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @wbpcode
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).
CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @jwendell

🐱

Caused by: #43243 was ready_for_review by ravenblackx.

see: more, trace.

Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

Thanks for this great contribution. Some initial comments to API.

Comment thread api/envoy/extensions/filters/http/file_server/v3/file_server.proto Outdated
Comment thread api/envoy/extensions/filters/http/file_server/v3/file_server.proto
@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Feb 3, 2026

/wait

Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
jwendell
jwendell previously approved these changes Feb 4, 2026
Copy link
Copy Markdown
Member

@jwendell jwendell left a comment

Choose a reason for hiding this comment

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

deps LGTM

@repokitteh-read-only repokitteh-read-only Bot removed the deps Approval required for changes to Envoy's external dependencies label Feb 4, 2026
Comment thread api/envoy/extensions/filters/http/file_server/v3/file_server.proto
Signed-off-by: Raven Black <ravenblack@dropbox.com>
@ravenblackx
Copy link
Copy Markdown
Contributor Author

/retest

@ravenblackx ravenblackx requested a review from wbpcode February 10, 2026 21:20
Signed-off-by: Raven Black <ravenblack@dropbox.com>
@repokitteh-read-only repokitteh-read-only Bot added the deps Approval required for changes to Envoy's external dependencies label Feb 10, 2026
@jwendell
Copy link
Copy Markdown
Member

/lgtm deps

@repokitteh-read-only repokitteh-read-only Bot removed the deps Approval required for changes to Envoy's external dependencies label Feb 12, 2026
@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Feb 22, 2026

happy to be listed as a codeowner - but as you say @wbpcode c++ is not my area - so would be great if you are up for also sponsoring

Yeah. I can also sponsor this new extension and @ravenblackx could add me to the codeowner list.

Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

LGTM overall except some comments. The file_streamer is a little hard to follow but I also didn't get a better way.

/wait

Comment on lines +42 to +44
// [#not-implemented-hide:] Directory operations currently have no async implementation.
message List {
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: as a fresh new extension, I think any field that not implemented could be removed first because:

  1. We may find no one want it in the future.
  2. We may have a better API design in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We want it - the catch is just that it requires implementing async directory operations first which is going to be additional PRs that I didn't want to roll up into this already large PR.

And I wanted the API review before going for that implementation. :)

Comment thread api/envoy/extensions/filters/http/file_server/v3/file_server.proto Outdated
Comment thread source/extensions/filters/http/file_server/config.cc Outdated
Comment thread source/extensions/filters/http/file_server/config.cc Outdated
Comment thread source/extensions/filters/http/file_server/config.cc Outdated
Comment on lines +28 to +30
createRouteSpecificFilterConfigTyped(const ProtoFileServerConfig& config,
Server::Configuration::ServerFactoryContext& context,
ProtobufMessage::ValidationVisitor& validator) override;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: it would be great if we can also add the createFilterFactoryFromProtoWithServerContext support here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't understand what that function is for. How does it differ from createFilterFactoryFromProtoTyped? It has the same arguments except for dropping DualInfo, and it loses the StatusOr error path of the return value, so I assume it has to use exceptions instead.

This comment

  // This method is for dual filter to create filter from server context when it is configured
  // in downstream. It won't be called if a dual filter is in upstream.

is not enlightening to me at all, as that seems to describe half of what createFilterFactoryFromProtoTyped is already doing. I don't understand why the default behavior is to throw an exception rather than just calling the other function that has to be overridden (or why it exists at all, given the name implies it exists to be the same as the other function but with ServerContext, but the other function already takes the same arguments).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

createFilterFactoryFromProtoWithServerContext makes us could configure a filter in the route rather then downstream or upstream filter chain. At the route, we only have the server context and even have no DualInfo.

All these are historical technical debt. If even you, a maintainer, are confused about this, I think we do need a completely refactor to these methods.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agree. I also have seen many configs using the DualInfo version, but haven't seen any actually consuming the DualInfo. So I would think a good option would be to have a default for each of the functions, that just calls createFilterFactoryFromProtoWithServerContext (the lowest common denominator of available arguments), and then only override that one for the common case.

Except that createFilterFactoryFromProtoWithServerContext doesn't return a status. :(

Comment thread source/extensions/filters/http/file_server/filter.h Outdated
Comment thread source/extensions/filters/http/file_server/filter.cc Outdated
Comment thread source/extensions/filters/http/file_server/filter.cc Outdated
Comment thread source/extensions/filters/http/file_server/file_streamer.h Outdated
Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
@ravenblackx ravenblackx requested a review from wbpcode February 23, 2026 17:25
@ravenblackx
Copy link
Copy Markdown
Contributor Author

/retest

Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: Raven Black <ravenblack@dropbox.com>
@ravenblackx
Copy link
Copy Markdown
Contributor Author

Found what the fuzz test problem is, it's nothing to do with my filter, it's that the fuzz tester picks a "random" filter if there's no config, and adding one more filter changes the outcome of that randomness to a filter that crashes.

@ravenblackx
Copy link
Copy Markdown
Contributor Author

#43627 to address the caused-but-unrelated test breakage.

Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

Signed-off-by: Raven Black <ravenblack@dropbox.com>
@ravenblackx ravenblackx merged commit 506746a into envoyproxy:main Feb 26, 2026
30 checks passed
bmjask pushed a commit to bmjask/envoy that referenced this pull request Mar 14, 2026
Commit Message: Add file server filter
Additional Description: Filter facilitates asynchronous serving from
files. Simplistic configuration for the common use-case. Further
features (e.g. exclusions) can be added later as needed. Secured against
path-escapes by using `std::filesystem::path` to verify that the path
requested isn't altered by normalization, and that it's within a path
explicitly configured to be shared.
Risk Level: Negligible, as no change to existing operations, it's a new
filter. It's marked work in progress and not assured secure, so should
not be adopted at this time without due caution.
Testing: I think there's 100% coverage, but CI isn't running right now.
Docs Changes: New docs for it.
Release Notes: Will add at the end, to minimize annoying merge
conflicts.
Platform Specific Features: Windows not supported, as AsyncFile
operations don't currently support Windows.

---------

Signed-off-by: Raven Black <ravenblack@dropbox.com>
Signed-off-by: bjmask <11672696+bjmask@users.noreply.github.com>
bvandewalle pushed a commit to bvandewalle/envoy that referenced this pull request Mar 17, 2026
Commit Message: Add file server filter
Additional Description: Filter facilitates asynchronous serving from
files. Simplistic configuration for the common use-case. Further
features (e.g. exclusions) can be added later as needed. Secured against
path-escapes by using `std::filesystem::path` to verify that the path
requested isn't altered by normalization, and that it's within a path
explicitly configured to be shared.
Risk Level: Negligible, as no change to existing operations, it's a new
filter. It's marked work in progress and not assured secure, so should
not be adopted at this time without due caution.
Testing: I think there's 100% coverage, but CI isn't running right now.
Docs Changes: New docs for it.
Release Notes: Will add at the end, to minimize annoying merge
conflicts.
Platform Specific Features: Windows not supported, as AsyncFile
operations don't currently support Windows.

---------

Signed-off-by: Raven Black <ravenblack@dropbox.com>
fishcakez pushed a commit to fishcakez/envoy that referenced this pull request Mar 25, 2026
Commit Message: Add file server filter
Additional Description: Filter facilitates asynchronous serving from
files. Simplistic configuration for the common use-case. Further
features (e.g. exclusions) can be added later as needed. Secured against
path-escapes by using `std::filesystem::path` to verify that the path
requested isn't altered by normalization, and that it's within a path
explicitly configured to be shared.
Risk Level: Negligible, as no change to existing operations, it's a new
filter. It's marked work in progress and not assured secure, so should
not be adopted at this time without due caution.
Testing: I think there's 100% coverage, but CI isn't running right now.
Docs Changes: New docs for it.
Release Notes: Will add at the end, to minimize annoying merge
conflicts.
Platform Specific Features: Windows not supported, as AsyncFile
operations don't currently support Windows.

---------

Signed-off-by: Raven Black <ravenblack@dropbox.com>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
Commit Message: Add file server filter
Additional Description: Filter facilitates asynchronous serving from
files. Simplistic configuration for the common use-case. Further
features (e.g. exclusions) can be added later as needed. Secured against
path-escapes by using `std::filesystem::path` to verify that the path
requested isn't altered by normalization, and that it's within a path
explicitly configured to be shared.
Risk Level: Negligible, as no change to existing operations, it's a new
filter. It's marked work in progress and not assured secure, so should
not be adopted at this time without due caution.
Testing: I think there's 100% coverage, but CI isn't running right now.
Docs Changes: New docs for it.
Release Notes: Will add at the end, to minimize annoying merge
conflicts.
Platform Specific Features: Windows not supported, as AsyncFile
operations don't currently support Windows.

---------

Signed-off-by: Raven Black <ravenblack@dropbox.com>
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.

5 participants