MySQL
TMA-MYSQL-4.8
Ensure 'sql_mode' Contains 'STRICT_ALL_TABLES'
Description
When data changing statements are made (i.e., INSERT, UPDATE), MySQL can handle invalid or missing values differently depending on whether strict SQL mode is enabled. When strict SQL mode is enabled, data may not be truncated or otherwise "adjusted" to make the data changing statement work. Runs mysql -NBe with the client defaults: put an administrative account in ~/.my.cnf (mode 0600) or a mysql_config_editor login path, not MYSQL_PWD (see 1.4/1.6).
Méthode de vérification
Méthode d'audit: Requête SQL
out=$(mysql -NBe "SELECT IF(FIND_IN_SET('STRICT_ALL_TABLES', @@global.sql_mode) > 0, 'compliant', 'noncompliant')" 2>/dev/null) || exit 1; printf '%s\n' "$out"- Sortie attendue
compliant
Méthode de correction
Méthode de correction: Recommandation ou correctif d'infrastructure
Add STRICT_ALL_TABLES to sql_mode under [mysqld] (e.g. sql_mode=STRICT_ALL_TABLES,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION) after testing applications, then restart or SET GLOBAL sql_mode.
Propriétés
- Systèmes d'exploitation
- Tous
- Étiquettes
- mysqldatabaseconfiguration
- Référence
- CIS Oracle MySQL Community Server 8.4 Benchmark v1.1.0 - 4.8 Ensure 'sql_mode' Contains 'STRICT_ALL_TABLES'
Vérifier cet hôte
Exécutez cette commande sur une machine que vous êtes autorisé à auditer. L'analyse est en lecture seule.
tmaegis scan --target mysql --level 2