fix(config): validate system_config on the runtime read path#67
Merged
Conversation
getSystemConfig() now parses stored rows against SystemConfigSchema on load rather than casting them, and fails loudly on invalid config so malformed values never reach auth logic. Correct the cache TTL comment (the value is 5 minutes, not 30 seconds). Update the unit tests to use full valid config fixtures and cover the validation-failure path. Closes #13
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Closes #13
Summary
getSystemConfig()trusted database rows with a cast and never validated them; only the admin read handler parsed against the schema. Invalid or malformedsystem_configcould therefore flow straight into auth logic (token TTLs, roles, origins, login methods).This validates on the runtime read path:
SystemConfigSchemabefore caching.300_000 msis 5 minutes, not 30 seconds).Behavior change
If stored
system_configdoes not satisfySystemConfigSchema,getSystemConfig()now throws instead of returning bad data. In normal operation this cannot happen: bootstrap seeds all required keys and the admin write path already validates. The change protects against out-of-band or corrupted rows.Testing
buildSystemConfig) and to cover the new validation-failure path.