Ensure numeric validation for configuration variables and set default for server keypair expiration

This commit is contained in:
netkas 2025-03-19 13:33:38 -04:00
parent 00f1db8180
commit 50f998c2ab
Signed by: netkas
GPG key ID: 4D8629441B76E4CC
2 changed files with 2 additions and 2 deletions

View file

@ -348,7 +348,7 @@
case 'SB_CRYPTO_KEYPAIR_EXPIRES': case 'SB_CRYPTO_KEYPAIR_EXPIRES':
case 'SB_CRYPTO_ENCRYPTION_KEYS_COUNT': case 'SB_CRYPTO_ENCRYPTION_KEYS_COUNT':
case 'SB_CACHE_PORT': case 'SB_CACHE_PORT':
if($variable !== false) if($variable !== false && is_numeric($variable))
{ {
Configuration::getConfigurationLib()->set($config, (int) $variable); Configuration::getConfigurationLib()->set($config, (int) $variable);
Program::getLogger()->info(sprintf('Set %s to %s', $config, $variable)); Program::getLogger()->info(sprintf('Set %s to %s', $config, $variable));

View file

@ -19,7 +19,7 @@
public function __construct(array $data) public function __construct(array $data)
{ {
$this->serverName = $data['server_name']; $this->serverName = $data['server_name'];
$this->serverKeypairExpires = $data['server_keypair_expires']; $this->serverKeypairExpires = (int)$data['server_keypair_expires'] ?? 0;
$this->transportEncryptionAlgorithm = $data['transport_encryption_algorithm']; $this->transportEncryptionAlgorithm = $data['transport_encryption_algorithm'];
} }