Repository navigation
fix(core): ssl_ca TLS insertion breaks database.php via commented PostgreSQL block - #475
Merged
ostefano merged 2 commits intoOct 23, 2026
Conversation
update_database_tls_config inserts the TLS key (ssl_ca/ssl_cert/ssl_key) after every line matching `public $default = [`. database.default.php ships TWO such lines: the active MySQL one and a COMMENTED-OUT PostgreSQL example (`// public $default = [`). The unanchored sed address matches both, so the key is also inserted inside the commented block but OUTSIDE the `//`, producing invalid PHP: Error: syntax error, unexpected single-quoted string "ssl_ca", expecting "function" Anchor the address to the start of line (`^[[:space:]]*public`) so only the active, non-commented $default block is matched. Verified with `php -l`: before = 2 insertions + parse error; after = 1 insertion + no syntax errors. Reproduces with MYSQL_TLS=true + MYSQL_TLS_CA set against an external DB (e.g. Azure MySQL Flexible) on misp-core 2.5.x.
Collaborator
|
Please rebase |
Contributor
Author
|
branch updated |
ostefano
approved these changes
Oct 23, 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.
Problem
When starting
misp-corewithMYSQL_TLS=trueandMYSQL_TLS_CAset (external DB over TLS, e.g. Azure MySQL Flexible / AWS RDS), the container crashes in a loop:Root cause
core/files/init_misp.sh→update_database_tls_config(). When the TLS key does not yet exist indatabase.php, it is inserted with:The address
/public\s+\$default\s*=\s*\[/is not anchored, andapp/Config/database.default.phpships two matching lines:So the
a\(append) runs on both, inserting'ssl_ca' => '...'inside the commented PostgreSQL block but outside the//, producing invalid PHP and the crash above.Fix
Anchor the
sedaddress to the start of the line (^[[:space:]]*public) so only the active, non-commented$defaultblock matches:One-character-class change, no behaviour change for the normal (single, non-commented) case.
Verification
Tested against the real
database.default.phpfrommisp-core:v2.5.50withphp -l:ssl_cainsertionsphp -lErrors parsingNo syntax errors detectedReproduces on misp-core 2.5.x with
MYSQL_TLS=true+MYSQL_TLS_CApointing at an externally managed MySQL. Same applies tossl_cert/ssl_key.