Skip to content

Requested Command Execution

When handling actions from Neuro, the action is first passed through a “central” handler function. This forms the basis of the Requested Command Execution (RCE) system.

We can break down the action handling stages into 4 parts:

The way that NeuroPilot’s action permission system works has already been covered in other pages, but at the centralized handler, it checks for the minimum permission level. Example:

  • Git Operations is set to ‘Autopilot’
  • Git Remotes is set to ‘Copilot’
  • Edit Remote Data is set to ‘Off’

In this case, if Neuro tries to add files and make a commit, her permission level will be Autopilot. If Neuro wants to then push it online, her permission level will be Copilot. And finally, if she wants to change where to push it to, well she can’t, so she has to ask for help.

If any of the required permissions are set to ‘Off’, processing will stop at this stage and Neuro will be told that she doesn’t have permission.

As Neuro can send JSON not conforming to schema, it is required to check the JSON to ensure the schema has been followed before continuing on (to prevent errors from undefined fields). The jsonschema library is used here due to the ability to just send in a schema file and Neuro’s packet, and get back a result. This result is then used to check whether or not to stop processing and tell Neuro she typed something wrong.

This is an improvement over other ways of doing it, which is normally using the same function set copy-pasted all over. That may be preferred if actions are used on a smaller scale since it requires less external packages, therefore reducing the external attack vectors (among other benefits), but with so many actions used and so many arguments needed, this becomes infeasible for NeuroPilot, so having this to validate Neuro’s packets is much easier while being functionally the same and features become easy to implement.

Even though Neuro may have sent in a valid packet and has permission to run the action, what if the tools she needs aren’t available? What if she tries to access Neuro-unsafe paths? That’s where custom validations come in.

These validators get immediately ran after the packet has been validated against the schema. This allows for custom validation with other tools (standout uses include Neuro-safe path checks and the Git extension’s availability). This can also act as a secondary schema validator, as a substitution for certain schema keys which have been prohibited from use by the Neuro Game API, or to put more restrictions where necessary (such as having parameters be required depending on another parameter).

This is the stage where the RCE framework gets put to the test. Here, we give the framework info about what commands Neuro wants to execute and the arguments she gave. Here, the framework will decide whether or not it will synchronously return results using the action result command (Autopilot) or asynchronously return results using contexts (Copilot).