Whitelist specific functions for the data controller - #1304
Open
PGijsbers wants to merge 1 commit into
Open
Conversation
PGijsbers
force-pushed
the
whitelist-data-access
branch
from
August 4, 2026 14:30
34c350e to
462a821
Compare
PGijsbers
requested review from
janvanrijn and
omosola
and removed request for
omosola
August 4, 2026 14:31
janvanrijn
reviewed
Aug 4, 2026
| $function_whitelist = array('download', 'view', 'get_csv'); | ||
|
|
||
| if (!in_array($function, $function_whitelist)) { | ||
| http_response_code(404); |
Member
There was a problem hiding this comment.
shouldn't we define an XML error for this?
|
The current associated model ( And LGTM 🚢 (pending @janvanrijn) |
janvanrijn
approved these changes
Aug 4, 2026
janvanrijn
left a comment
Member
There was a problem hiding this comment.
The current associated model (Data_server) used only returns http-related error codes as well
That's true, good point.
Let's go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The controller would allow attempts at calling arbitrary functions. This is harmless as long as no new functions get defined on the class - the exposed functions are exactly those we want to allow. However, we noticed from logs that there are attempts at calling other functions, so we are taking preventative measures to close things down so that:
This patch introduces a whitelist of functions which are allowed to be called this way, and provides clearer error messages if an unknown function is called, or a known function is called incorrectly.
--
I considered using the standard
returnErrordefined onMY_Api_Modelbut you would need to load in those modules and hack around it not actually being called from the new controller:Anywhere in the path (e.g., in the constructor, or specifically only when an error is actually raised):
and then at the call site:
because at some point the error template path is determined by interpolation of the controller and page.
I figured it's better to keep things simple.