wp-cli / restful

Unlocking the potential of the WP REST API at the command line

Home Page:https://wp-cli.org/restful/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Retrieving REST API callback functions

cybernick3000 opened this issue · comments

Currently, restful can retrieve a list of all REST endpoints registered, but would it be possible to use restful to enumerate all REST API callback functions in a particular plugin?

In the following example, the particular callback function registered for the endpoint would be get_post_id

<?php add_action( 'rest_api_init', function() { register_rest_route( 'myplugin/v1', '/books', array( 'methods' => 'GET', 'callback' => 'get_post_id', ) ); });

It seems WP_REST_Server::get_routes() is able to return an array containing the names of the callback functions but I am not sure if it can be used in restful

Thanks for the question, @cybernick3000 !

would it be possible to use restful to enumerate all REST API callback functions in a particular plugin?

Potentially! What are you hoping to do with these callback functions?

I am using taint analysis to detect vulnerabilities in plugin code.

These callback functions usually take in an object of type WP_REST_Request which often contains tainted user input and if I can get a list of these callback functions, I could use this information to set the taint sources properly in the taint analysis engine.

Not sure if this is the best way to approach though.

Not sure if this is the best way to approach though.

Hm, yeah. I don't have a better solution to offer, unfortunately.

Feel free to report back if you find a good solution!