In valid array in Security.php on scan null given in in_array()

Created on 7 May 2025, 3 days ago

Problem/Motivation

[error]  TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 371 of /var/www/html/docroot/modules/contrib/security_review/src/Security.php) #0 /var/www/html/docroot/modules/contrib/security_review/src/Security.php(371): in_array(20, NULL)
#1 /var/www/html/docroot/modules/contrib/security_review/src/Checks/FilePermissions.php(52): Drupal\security_review\Security->findWritableFiles(Array, true)
#2 /var/www/html/docroot/modules/contrib/security_review/src/Checks/FilePermissions.php(96): Drupal\security_review\Checks\FilePermissions->run(true)
#3 /var/www/html/docroot/modules/contrib/security_review/src/Checklist.php(165): Drupal\security_review\Checks\FilePermissions->runCli()

Steps to reproduce

1. Install the module security_review
2. Run the Security scan
3. The batch process will throw the error message above
4. The same can be replicated on the Drush scan drush security:review.

Proposed resolution

Check the is array before running the in_array.

change,

into,

$filegroup = filegroup($file);
$filegroup = is_array($filegroup) ? $filegroup : [];
if ($gw === 1 && in_array($filegroup, $gids)) {

Remaining tasks

Nil

User interface changes

Nil

API changes

Nil

Data model changes

Nil

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇳India arunkumark Coimbatore

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024