@@ -990,6 +990,64 @@ private function getItemsHealthCheck(): array
990990 ];
991991 }
992992
993+ // ---------------------------------------------------------------------
994+ // File permissions checks
995+ // ---------------------------------------------------------------------
996+ $ projectDir = (string ) $ this ->getParameter ('kernel.project_dir ' );
997+
998+ // Help links (optional but avoids null URLs)
999+ $ securityGuideUrl = '/documentation/security.html ' ;
1000+ $ optimizationGuideUrl = '/documentation/optimization.html ' ;
1001+
1002+ // .env should NOT be writable by the web server user
1003+ $ envPath = $ projectDir .'/.env ' ;
1004+ $ envIsWritable = is_file ($ envPath ) && is_writable ($ envPath );
1005+
1006+ $ items [] = [
1007+ 'className ' => 'item-health-check-env-perms ' .($ envIsWritable ? 'text-error ' : 'text-success ' ),
1008+ 'url ' => $ securityGuideUrl ,
1009+ 'label ' => sprintf (
1010+ $ this ->translator ->trans ($ envIsWritable ? '%s is writeable ' : '%s is not writeable ' ),
1011+ '.env '
1012+ ),
1013+ ];
1014+
1015+ // config/ should NOT be writable by the web server user
1016+ $ configPath = $ projectDir .'/config ' ;
1017+ $ configIsWritable = is_dir ($ configPath ) && is_writable ($ configPath );
1018+
1019+ $ items [] = [
1020+ 'className ' => 'item-health-check-config-perms ' .($ configIsWritable ? 'text-error ' : 'text-success ' ),
1021+ 'url ' => $ securityGuideUrl ,
1022+ 'label ' => sprintf (
1023+ $ this ->translator ->trans ($ configIsWritable ? '%s is writeable ' : '%s is not writeable ' ),
1024+ 'config/ '
1025+ ),
1026+ ];
1027+
1028+ // var/cache MUST be writable (Symfony cache)
1029+ $ cachePath = $ projectDir .'/var/cache ' ;
1030+ $ cacheIsWritable = is_dir ($ cachePath ) && is_writable ($ cachePath );
1031+
1032+ $ items [] = [
1033+ 'className ' => 'item-health-check-cache-perms ' .($ cacheIsWritable ? 'text-success ' : 'text-error ' ),
1034+ 'url ' => $ optimizationGuideUrl ,
1035+ 'label ' => sprintf (
1036+ $ this ->translator ->trans ($ cacheIsWritable ? '%s is writeable ' : '%s is not writeable ' ),
1037+ 'var/cache '
1038+ ),
1039+ ];
1040+
1041+ // public/main/install existence -> orange if present
1042+ $ installPath = $ projectDir .'/public/main/install ' ;
1043+ $ installExists = is_dir ($ installPath );
1044+
1045+ $ items [] = [
1046+ 'className ' => 'item-health-check-install-folder ' .($ installExists ? 'text-warning ' : 'text-success ' ),
1047+ 'url ' => $ securityGuideUrl ,
1048+ 'label ' => $ this ->translator ->trans ($ installExists ? 'Install folder is still present ' : 'Install folder is not present ' ),
1049+ ];
1050+
9931051 return $ items ;
9941052 }
9951053}
0 commit comments