<commit_before><?php

declare(strict_types=1);

namespace App\Monitor;

use Laminas\Diagnostics\Check\CheckInterface;
use Laminas\Diagnostics\Result\Failure;
use Laminas\Diagnostics\Result\ResultInterface;
use Laminas\Diagnostics\Result\Success;
use Laminas\Diagnostics\Result\Warning;

class NoDefaultSecret implements CheckInterface
{
    /**
     * Perform the actual check and return a ResultInterface
     *
     * @return ResultInterface
     */
    public function check()
    {
        $secret = getenv('ILIOS_SECRET', true);
        if (!$secret) {
            return new Warning("'ILIOS_SECRET' is not set");
        }

        $badSecrets = array_map('strtolower', [
            'NotSecretChangeMe',
            'ThisTokenIsNotSoSecretChangeIt',
            'ST<PASSWORD>',
            'PR0DUCT10nS3CRET12345',
        ]);

        if (in_array(trim(strtolower($secret)), $badSecrets)) {
            return new Failure(
                "\nILIOS_SECRET: Set to a ${secret}. This isn't safe and should be changed"
            );
        }

        return new Success('ILIOS_SECRET uses a non-default value');
    }

    /**
     * Return a label describing this test instance.
     *
     * @return string
     */
    public function getLabel()
    {
        return 'No Default Secret';
    }
}<commit_msg>Fix NoDefaultSecret health check<commit_after><?php

declare(strict_types=1);

namespace App\Monitor;

use Laminas\Diagnostics\Check\CheckInterface;
use Laminas\Diagnostics\Result\Failure;
use Laminas\Diagnostics\Result\ResultInterface;
use Laminas\Diagnostics\Result\Success;
use Laminas\Diagnostics\Result\Warning;

class NoDefaultSecret implements CheckInterface
{
    private const NAME = 'ILIOS_SECRET';

    /**
     * Ensure ILIOS_SECRET isn't set to a default value
     *
     * @return ResultInterface
     */
    public function check()
    {
        $secret = getenv(self::NAME);
        if (!$secret && isset($_ENV[self::NAME])) {
            $secret = $_ENV[self::NAME];
        }

        if (!$secret) {
            return new Warning("'ILIOS_SECRET' is not set");
        }

        $badSecrets = array_map('strtolower', [
            'NotSecretChangeMe',
            'ThisTokenIsNotSoSecretChangeIt',
            'ST@G1nGS3CRET12345',
            'PR0DUCT10nS3CRET12345',
        ]);

        if (in_array(trim(strtolower($secret)), $badSecrets)) {
            return new Failure(
                "\nILIOS_SECRET: Set to a ${secret}. This isn't safe and should be changed"
            );
        }

        return new Success('ILIOS_SECRET uses a non-default value');
    }

    /**
     * Describe this test
     *
     * @return string
     */
    public function getLabel()
    {
        return 'No Default Secret';
    }
}
{'fraction_non_alphanumeric': 0.10982239942007974, 'fraction_numerical': 0.009786154403769481, 'mean_word_length': 2.349514563106796, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6936812', 'n_tokens_mistral': 845, 'n_tokens_neox': 828, 'n_words': 185}