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

extension_api.json is not sanitized #1536

Open
OffsetMOSFET opened this issue Jul 26, 2024 · 2 comments
Open

extension_api.json is not sanitized #1536

OffsetMOSFET opened this issue Jul 26, 2024 · 2 comments
Labels
enhancement This is an enhancement on the current functionality

Comments

@OffsetMOSFET
Copy link

Godot version

4.2.2

godot-cpp version

4.2.2

System information

Ubuntu 22.04.4 LTS 64-bit

Issue description

When using a custom api file via extension_api.json, the field arguments/name for each method is used directly. I have a custom module, and I happened to use spaces, parenthesis, and brackets to describe the inputs of my functions. i.e.

ClassDB::bind_method(D_METHOD("example_function", "input (1)"), &Foo::example_function);

This does not create issues when compiling Godot. However, when compiling godot_cpp, it creates malformed function definitions:

void example_function(int input (1));

While this a fixable issue for me, there is a (very circumstantial) way to use this for code injection if the module came from a second party.

Steps to reproduce

Compile godot with modules with malformed input descriptions. Create and move the custom.api. Compile the GDExtension Project.

Minimal reproduction project

N/A

@AThousandShips
Copy link
Member

AThousandShips commented Jul 26, 2024

This belongs in the main repo as it's related to generation, please open one here (No need)

This should be simple to fix by adding checks to the unit tests, will write a check for argument names for the unit tests and module makers can then use that for validation

Writing up a test addition

@AThousandShips AThousandShips added the enhancement This is an enhancement on the current functionality label Jul 26, 2024
@AThousandShips
Copy link
Member

Added a unit test for coverage:

See there for more, we could add a validation step to the API dump but it'd be far more involved as we'd need to add other validations, but that would just duplicate the unit tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This is an enhancement on the current functionality
Projects
None yet
Development

No branches or pull requests

2 participants