]*\\\\\.php)/i', $content ); } } $results = array(); if ( ! $has_index ) { $results[] = $this->make_result( array( 'id' => 'uploads_no_index', 'title' => __( 'Uploads directory has no index file', 'aipatch-security-scanner' ), 'severity' => AIPSC_Audit_Check_Result::SEVERITY_LOW, 'description' => __( 'The uploads directory lacks an index.html or index.php, potentially allowing directory listing.', 'aipatch-security-scanner' ), 'why_it_matters' => __( 'Directory listing reveals all uploaded files, which may include sensitive documents.', 'aipatch-security-scanner' ), 'recommendation' => __( 'Add an empty index.html file in the uploads directory.', 'aipatch-security-scanner' ), 'evidence' => $base, 'fixable' => true, ) ); } if ( ! $blocks_php ) { $results[] = $this->make_result( array( 'id' => 'uploads_php_execution', 'title' => __( 'PHP execution not blocked in uploads', 'aipatch-security-scanner' ), 'severity' => AIPSC_Audit_Check_Result::SEVERITY_HIGH, 'confidence' => $has_htaccess ? AIPSC_Audit_Check_Result::CONFIDENCE_HIGH : AIPSC_Audit_Check_Result::CONFIDENCE_MEDIUM, 'description' => __( 'The uploads directory does not block PHP execution, allowing uploaded shells to run.', 'aipatch-security-scanner' ), 'why_it_matters' => __( 'If an attacker uploads a PHP file, it can be executed and give full server access.', 'aipatch-security-scanner' ), 'recommendation' => __( 'Add .htaccess rules to block PHP execution in the uploads directory.', 'aipatch-security-scanner' ), 'evidence' => $has_htaccess ? '.htaccess exists but no PHP blocking rules' : 'No .htaccess in uploads directory', 'fixable' => true, ) ); } if ( empty( $results ) ) { $results[] = $this->make_result( array( 'id' => 'uploads_index', 'title' => $this->get_title(), 'severity' => AIPSC_Audit_Check_Result::SEVERITY_INFO, 'status' => AIPSC_Audit_Check_Result::STATUS_PASS, 'description' => __( 'Uploads directory is properly protected.', 'aipatch-security-scanner' ), ) ); } return $results; } }