Skip to content

fix: harden regex matching on key:generate command#10183

Open
paulbalandan wants to merge 1 commit intocodeigniter4:developfrom
paulbalandan:key-generate-export
Open

fix: harden regex matching on key:generate command#10183
paulbalandan wants to merge 1 commit intocodeigniter4:developfrom
paulbalandan:key-generate-export

Conversation

@paulbalandan
Copy link
Copy Markdown
Member

Description

Hardens the regex used by spark key:generate to locate encryption.key in .env:

  • A comment line that merely mentions encryption.key (e.g. # Note: encryption.key is set automatically by spark key:generate.) used to match the active pattern, so the command silently rewrote the comment instead of setting a real key. Comments are now matched by a separate pattern that uncomments them; comments that only mention the name are left intact and a fresh encryption.key = … line is appended.
  • DotEnv supports export encryption.key = …. The previous regex didn't, so an existing export-prefixed key was missed and a duplicate appended. The new pattern matches the optional export prefix and preserves it on rewrite.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conform to PSR-12 coding style

@paulbalandan paulbalandan added the bug Verified issues on the current code behavior or pull requests that will fix them label May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants