fix(archimate): unset AMEF ids were handed on as empty strings past a === null guard (gate-50 14 → PASS) - #472
Merged
Conversation
… `=== null` guard
gate-50 security-config-fail-mode 14 -> PASS, measured with hydra-gates 651e5c5
at the CI scope (--scope-to-diff --base origin/beta).
I nearly dismissed these 14 as false positives of the gate's 10-line window,
on the grounds that the consumers validate. Checking every consumer rather
than the two convenient ones showed the opposite.
The legacy fallback in both getAmefConfig() implementations read every
register/schema id with '' as its default and returned them. The consumers
guard with `=== null`:
ViewService:254, :320 if ($registerId === null || $viewSchemaId === null) throw
ViewService:711 $registerId used with NO guard at all
and `'' === null` is false. An empty id therefore passes the guard and is
pinned into an OpenRegister query as the register/schema — and an unpinned
query returns rows, which reads exactly like a correct result.
Nothing reaches a query TODAY only because the fallback writes PLURAL key
names (`views_schema`, `elements_schema`) while every consumer reads SINGULAR
ones (`view_schema`, `element_schema`), so the lookups miss and fall back to
null. Measured producer/consumer key overlap: the empty set. That is an
accident of naming, not a defence — adding the singular keys, the obvious
"cleanup", turns it into a live fail-open.
- resolveConfiguredId() reads each id and returns null, with a warning naming
the key, when it is empty or whitespace. The guard is now AT the read, and
there is one read instead of eight.
- The fallback array_filters the nulls out, so `?? null` downstream yields
null — which is what every consumer already checks for.
- ViewService::getModulesData() gains the missing register guard and fails
closed rather than issuing an unpinned query; its schema loop now uses
empty() rather than `=== null` for the same reason.
Narrower than it first looks, and the tests say so: the fallback is only
reached when `amef_config` is MALFORMED, because its default '{}' is valid
JSON and decodes to []. My first draft of the tests failed for exactly that
reason and taught me the branch condition.
Can-fail: reverting the three services turns 3 of the 4 new tests red and puts
gate-50 back to 14.
phpcs lib/ 0 errors, phpmd/psalm/phpstan clean, unit suite 523 tests green.
Contributor
Quality Report — ConductionNL/softwarecatalog @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ✅ | ||||
| phpmd | ✅ | ||||
| psalm | ✅ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| build | ✅ | ||||
| check-manifest | ✅ | ||||
| check-vue-demi | ✅ | ||||
| test-l10n | ✅ | ||||
| composer | ✅ | ✅ 128/128 | |||
| npm | ✅ | ✅ 718/718 | |||
| PHPUnit | ✅ | ||||
| Newman | ⏭️ | ||||
| Playwright | ✅ | ||||
| Hydra gates | ✅ |
Quality workflow — 2026-08-09 20:55 UTC
Download the full PDF report from the workflow artifacts.
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.
gate-50 security-config-fail-mode: 14 → PASS. hydra-gates
651e5c5bb3ba8764903e5d6fc5bac5a208bd67fc, measured at the CI scope (--scope-to-diff --base origin/beta).I nearly dismissed these as false positives
My first read was that gate-50's 10-line window was too narrow and the consumers validate anyway — so I was going to leave all 14 red with that as the reason. Checking every consumer rather than the two convenient ones showed the opposite.
The legacy fallback in both
getAmefConfig()implementations read every register/schema id with''as its default and returned them. The consumers guard with=== null:'' === nullis false. An empty id passes the guard and is pinned into an OpenRegister query as the register/schema — and an unpinned query returns rows, which reads exactly like a correct result rather than like a failure.Why nothing has broken yet
The fallback writes plural key names (
views_schema,elements_schema) while every consumer reads singular ones (view_schema,element_schema). Measured producer/consumer overlap: the empty set. So the lookups miss and fall back tonull, and the throw fires.That is an accident of naming, not a defence. Adding the singular keys — the obvious cleanup, and something I nearly did myself earlier in this session — converts it into a live fail-open.
The fix
resolveConfiguredId()reads each id and returnsnull, with a warning naming the key, when it is empty or whitespace. The guard is now at the read, and there is one read instead of eight per file.array_filters the nulls out, so?? nulldownstream yieldsnull— exactly what every consumer already checks for.ViewService::getModulesData()gains the missing register guard and fails closed rather than issuing an unpinned query; its schema loop now usesempty()rather than=== nullfor the same reason.Narrower than it first looks — and the tests said so
The fallback is only reached when
amef_configis malformed, because its default'{}'is valid JSON and decodes to[]. My first draft of the tests failed for exactly that reason and taught me the branch condition;serviceWithConfig()now setsamef_configto'not-json'deliberately, and the unconfigured case asserts[]explicitly so it cannot pass vacuously by iterating an empty array.Can-fail proof
Reverting the three services to
origin/development:The fourth test (a configured id comes through unchanged) passes in both directions by design — it is the regression net, not a mirror of the fix.
Other measurements
phpcs lib/— 0 errors / 87 warnings, identical toorigin/development.phpmd(repo baseline),psalm,phpstan— clean.