Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(proxy-wasm) catch get/set all scoped properties outside of requests #659

Merged
merged 2 commits into from
Jan 16, 2025

Conversation

thibaultcha
Copy link
Member

Scoped properties (e.g. request.*, response.*, upstream.*, ...) can only be read/written from within the context of a request. Only non-scoped properties (e.g. worker_id) can be accessed from root contexts.

Prior to this commit, only ngx.* and wasmx.* (host) properties were caught. Other scoped properties that did not map to either of those would cause a segfault.

We now catch all scoped properties (i.e. containing a . character) when getting/setting properties outside of a request.

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.81210%. Comparing base (1b5f11f) to head (3b009cd).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                 @@
##                main        #659         +/-   ##
===================================================
+ Coverage   90.29307%   90.81210%   +0.51903%     
===================================================
  Files             53          53                 
  Lines          11260       11341         +81     
  Branches        1597        1690         +93     
===================================================
+ Hits           10167       10299        +132     
+ Misses          1087        1036         -51     
  Partials           6           6                 
Files with missing lines Coverage Δ
src/common/proxy_wasm/ngx_proxy_wasm_properties.c 89.13525% <100.00000%> (+1.71952%) ⬆️

... and 14 files with indirect coverage changes

Flag Coverage Δ
unit 90.55126% <100.00000%> (+0.86794%) ⬆️
valgrind 82.47805% <80.64516%> (-0.06149%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@thibaultcha thibaultcha force-pushed the fix/scoped-properties branch 6 times, most recently from 6f8ae21 to 205f3a8 Compare January 16, 2025 01:41
Scoped properties (e.g. `request.*`, `response.*`, `upstream.*`, ...)
can only be read/written from within the context of a request. Only
non-scoped properties (e.g. `worker_id`) can be accessed from root
contexts.

Prior to this commit, only `ngx.*` and `wasmx.*` (host) properties were
caught. Other scoped properties that did not map to either of those
would cause a segfault.

We now catch all scoped properties (i.e. containing a `.` character)
when getting/setting properties outside of a request.
Some tests resolving to external services were unreliable as they were
using a real resolver instead of the local dnsmasq mock resolver that we
use on CI.
@thibaultcha thibaultcha force-pushed the fix/scoped-properties branch from 205f3a8 to 3b009cd Compare January 16, 2025 02:51
@thibaultcha thibaultcha reopened this Jan 16, 2025
@thibaultcha thibaultcha merged commit 3b009cd into main Jan 16, 2025
60 checks passed
@thibaultcha thibaultcha deleted the fix/scoped-properties branch January 16, 2025 05:02
@dev-null-undefined
Copy link
Contributor

I believe this patch is incorrect as for example the variable plugin_name will still cause segmentation fault when used in the on_tick "phase"

@thibaultcha
Copy link
Member Author

thibaultcha commented Jan 17, 2025

Nice catch thanks - the patch is fine, it's a different issue for plugin_name than request access. I'll send a PR.

@thibaultcha
Copy link
Member Author

See #667

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