MMOframework
Pourquoi l'IA Playground Bibliothèques Développeurs Agence
FR EN
Créer un projet en direct
Index

HardeningProbe

MMO\admin\monitoring\probes · 1 symbole · générée le 30 Nov 2026

class

HardeningProbe

HardeningProbe.php:32

Whether a site's configuration is still what its reference says (ISO 27001 A.8.9, A.8.20 to A.8.22): the deviations of a target from the probe's options, which are the reference -- versioned with the project, in its hub.json ("probes": {"hardening": {...}}), read the same by the hub and by php scripts/admin.php harden-check.

class MMO\admin\monitoring\probes\HardeningProbe extends MMO\admin\monitoring\aProbe
Espace de noms
MMO\admin\monitoring\probes
Étend
aProbe
It only reads, in two parts: - from here, over http(s) ([`httpChecks`](https://mmoframework.fr/documentation/mmo.admin/php/monitoring/probes/HardeningProbe.md#hardeningprobe-httpchecks)): http goes to https, HSTS and the security headers on a page and on a static file ([`$asset`](https://mmoframework.fr/documentation/mmo.admin/php/monitoring/probes/HardeningProbe.md#hardeningprobe-asset)), no `X-Powered-By: PHP`, a TLS older than 1.2 refused ([`legacyTls`](https://mmoframework.fr/documentation/mmo.admin/php/monitoring/probes/HardeningProbe.md#hardeningprobe-legacytls)); - on the target's server, one sh script over its shell ([`script`](https://mmoframework.fr/documentation/mmo.admin/php/monitoring/probes/HardeningProbe.md#hardeningprobe-script), [`serverChecks`](https://mmoframework.fr/documentation/mmo.admin/php/monitoring/probes/HardeningProbe.md#hardeningprobe-serverchecks)): the `display_errors` and `expose_php` of php-fpm's and apache's php.ini, the mode of the key files ([`$keyFiles`](https://mmoframework.fr/documentation/mmo.admin/php/monitoring/probes/HardeningProbe.md#hardeningprobe-keyfiles)), the versions of php and of the database, the clock synchronized (NTP), the database listening on the loopback only. Each check is `ok`, `deviation` or `unknown` (what a webspace does not let it read: never a deviation). A deviation makes the reading a warning, or critical for those of [`$critical`](https://mmoframework.fr/documentation/mmo.admin/php/monitoring/probes/HardeningProbe.md#hardeningprobe-critical). It is off by default (`"enabled": true` in `hub.json`): it asks every site three more requests and its server one more script. Metrics: `hardening.deviations`, `hardening.unknown`. Details: `checks`, a list of {id, status, expected, actual, measure}. Facts: `php`, `database`.
$reading = (new HardeningProbe(['asset' => 'assets/favicon.ico']))->collect($target); $reading->metrics['hardening.deviations']; // 0 array_column($reading->details['checks'], 'status', 'id'); // ['https.redirect' => 'ok', 'hsts' => 'ok', ...]

Constantes7

DESCRIPTION

const DESCRIPTION = 'the configuration against its reference: https, headers, tls, php, keys, database, ntp'

DEVIATION

const DEVIATION = 'deviation'

KIND

const KIND = 'target'

MEASURES

check => the measures of ISO 27001's annex A it is about (their numbers only)

const MEASURES = […13 items]

NAME

const NAME = 'hardening'

OK

const OK = 'ok'

UNKNOWN

const UNKNOWN = 'unknown'

Propriétés14

allowedListen

array $allowedListen = []
Type
array

critical

array $critical = ['keys', 'database.exposed', 'https.redirect']
Type
array

databasePorts

array $databasePorts = [27017, 3306, 5432, 6379, 11211]
Type
array

databases

array $databases = ['mongodb' => '7.0', 'mysql' => '8.0', 'mariadb' => '10.11']
Type
array

enabled

bool $enabled = false
Type
bool

engine

string $engine = 'mongodb'
Type
string

headers

array $headers = […3 items]
Type
array

hstsMaxAge

int $hstsMaxAge = 15552000
Type
int

http

bool $http = true
Type
bool

keyFiles

array $keyFiles = ['configs/private.key']
Type
array

php

string $php = '8.3'
Type
string

server

bool $server = true
Type
bool

tls

bool $tls = true
Type
bool

Méthodes12

check($id, $status, $expected, $actual)

HardeningProbe.php:313
protected function check(string $id, string $status, string $expected, string $actual): array
$idstring
$statusstring
$expectedstring
$actualstring
retournearraystring, status: string, expected: string, actual: string, measure: string}

headers($id, $headers, $withHsts)

HardeningProbe.php:174
protected function headers(string $id, array $headers, bool $withHsts = false): array
$idstring
$headersarray
$withHsts = falseboolalso HSTS (a static file is served by the web server alone: it must send it too)
retournearraythe check of $headers

httpChecks($target, $transport)

HardeningProbe.php:122
function httpChecks( MMO\admin\entities\Target $target, MMO\admin\monitoring\iHttpTransport $transport ): array
$targetTarget
$transportiHttpTransportwhat asks
retournearrayeach check: id, status, expected, actual, measure

legacyTls($host, $port)

HardeningProbe.php:191

Whether the site accepts a TLS older than 1.2: a handshake asking 1.0 to 1.1 at most.

protected function legacyTls(string $host, int $port): ?bool
$hoststring
$portint
retournenull | booltrue accepted, false refused, null when it cannot tell (no curl, nothing answers)

needsShell()

HardeningProbe.php:102

what it asks over http does not need the server: what it reads on it says unknown by itself

function needsShell(): bool
retournebool

probe($subject, $reading, $previous)

HardeningProbe.php:104
protected function probe( MMO\admin\entities\Server|MMO\admin\entities\Target $subject, MMO\admin\monitoring\Reading $reading, ?MMO\admin\monitoring\Reading $previous ): void
$subjectServer | Target
$readingReading
$previousnull | Reading
retournevoid

script($target)

HardeningProbe.php:210
function script(MMO\admin\entities\Target $target): string
$targetTarget
retournestringthe script run on the target's server: read only, every section reading what it can

serverChecks($output, $target, $reading)

HardeningProbe.php:233
function serverChecks( ?string $output, MMO\admin\entities\Target $target, ?MMO\admin\monitoring\Reading $reading = null ): array
$outputnull | stringwhat script printed (null: the server could not be reached)
$targetTarget
$reading = nullnull | Readingits facts filled (php, database)
retournearraythe server's checks
Membres hérités (13)
ConstantesDéclaré parDescription
SERVERaProbea probe of servers
TARGETaProbea probe of targets: the sites of the project, one per client
PropriétésDéclaré parDescription
hubaProbe
timeoutaProbe
MéthodesDéclaré parDescription
collect($subject, $previous, $time)aProbeLook at a subject, never throwing: whatever goes wrong is in the reading.
debugName()aProbe
failure($e)aProbe
Number($value)aProbe
Percent($part, $whole)aProbe
run($subject, $script)aProbeRun a script on the subject, stopped after $timeout seconds where timeout exists (a webspace may lack it).
Sections($output)aProbe
shell($subject)aProbe
__construct($options, $hub)aProbe