mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Validate APP_KEY (#13171)
* Validate APP_KEY key:rotate command to rotate keys, only rotates validation data for now * fixes, swapped encrypters, not saving new value to db, check that key exists first * add confirmation * Option to generate new key, re-encrypt data and then save it to .env A lot more text to try to prevent disaster. Print out both keys 1-2 times. Fix bug in EnvHelper (when key is commented but not empty) * fix style * oops, good phpstan
This commit is contained in:
@@ -90,8 +90,9 @@ class EnvHelper
|
||||
|
||||
$value = self::escapeValue($value);
|
||||
|
||||
if (strpos($content, "$key=") !== false) {
|
||||
// only replace ones that aren't already set for safety and uncomment
|
||||
if (preg_match("/^(#$key=$|$key=)/m", $content)) {
|
||||
// enter this block if we have commented and empty or uncommented key
|
||||
// only replace ones that aren't already set to a value for safety and uncomment
|
||||
// escape $ in the replacement
|
||||
$content = preg_replace("/#?$key=\n/", addcslashes("$key=$value\n", '$'), $content);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user