Validate attribute manipulation PHP syntax on metadata push#1916
Merged
kayjoosten merged 2 commits intomainfrom Mar 2, 2026
Merged
Validate attribute manipulation PHP syntax on metadata push#1916kayjoosten merged 2 commits intomainfrom
kayjoosten merged 2 commits intomainfrom
Conversation
johanib
reviewed
Feb 25, 2026
src/OpenConext/EngineBlock/Metadata/Entity/Assembler/PushMetadataAssembler.php
Show resolved
Hide resolved
src/OpenConext/EngineBlock/Metadata/Entity/Assembler/PushMetadataAssembler.php
Outdated
Show resolved
Hide resolved
johanib
reviewed
Feb 25, 2026
...s/integration/OpenConext/EngineBlock/Metadata/Entity/Assembler/PushMetadataAssemblerTest.php
Show resolved
Hide resolved
Contributor
Author
Validation approach: findings & performanceApproaches considered
Why
Performance impactBenchmark run locally (PHP 8.2, 1000 iterations, warmed up):
Simulated metadata push of 500 services (all with manipulation code):
In practice, not all services have manipulation code, so the real-world overhead will be even lower. The added validation cost during a metadata push is negligible. |
When entities are pushed to /api/connections, any manipulation_code is now syntax-checked using token_get_all() with TOKEN_PARSE before being stored. This catches PHP parse errors at push time instead of at login time. If a syntax error is found, a RuntimeException is thrown with the entity ID, which the controller returns as a 400 Bad Request. The entire push is rejected if any entity has invalid manipulation code. Resolves: #1778
b8b62ba to
1a8c115
Compare
johanib
approved these changes
Feb 26, 2026
Contributor
johanib
left a comment
There was a problem hiding this comment.
Thanks for the explanation.
Maybe add an entry to the changelog? "Metadata push will now reject all metadata if any service contains invalid attribute manipulations."
Two small comments, but no blockers 👍
src/OpenConext/EngineBlock/Metadata/Entity/Assembler/PushMetadataAssembler.php
Show resolved
Hide resolved
johanib
approved these changes
Mar 2, 2026
baszoetekouw
approved these changes
Mar 2, 2026
baszoetekouw
approved these changes
Mar 2, 2026
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.
When entities are pushed to /api/connections, any manipulation_code is now syntax-checked using token_get_all() with TOKEN_PARSE before being stored. This catches PHP parse errors at push time instead of at login time.
If a syntax error is found, a RuntimeException is thrown with the entity ID, which the controller returns as a 400 Bad Request. The entire push is rejected if any entity has invalid manipulation code.
Resolves: #1778