__( 'ActivityPilot for WP', 'activitypilot' ), 'fields' => array( 'version' => array( 'label' => 'Plugin version', 'value' => APWPM_VERSION ), 'db_version' => array( 'label' => 'DB schema', 'value' => get_option( 'apwpm_db_version', '?' ) ), 'total_events' => array( 'label' => 'Events stored', 'value' => number_format_i18n( $count ) ), 'critical_24h' => array( 'label' => 'Critical (24h)', 'value' => number_format_i18n( $crit ) ), 'hashchain' => array( 'label' => 'Hash chain', 'value' => APWPM_Integrity::enabled() ? 'enabled' : 'disabled' ), 'immutable' => array( 'label' => 'Immutable mode', 'value' => APWPM_Immutable::enabled() ? 'enabled' : 'disabled' ), ), ); return $info; } public static function register_tests( $tests ) { $tests['direct']['apwpm_critical'] = array( 'label' => __( 'Recent critical activity events', 'activitypilot' ), 'test' => array( __CLASS__, 'test_critical_events' ), ); $tests['direct']['apwpm_hashchain'] = array( 'label' => __( 'Activity log integrity', 'activitypilot' ), 'test' => array( __CLASS__, 'test_hashchain' ), ); return $tests; } public static function test_critical_events() { $count = APWPM_DB::count_recent_errors( 24 ); if ( $count > 10 ) { return array( 'label' => __( 'Many critical events in the last 24 hours', 'activitypilot' ), 'status' => 'critical', 'badge' => array( 'label' => __( 'Security', 'activitypilot' ), 'color' => 'red' ), 'description' => sprintf( '
%s
', sprintf( /* translators: %d: count */ __( '%d critical events were recorded in the last 24 hours. Review your activity timeline.', 'activitypilot' ), $count ) ), 'actions' => sprintf( '', esc_url( APWPM_Admin::timeline_url() ), __( 'Open timeline', 'activitypilot' ) ), 'test' => 'apwpm_critical', ); } return array( 'label' => __( 'No spike in critical activity', 'activitypilot' ), 'status' => 'good', 'badge' => array( 'label' => __( 'Security', 'activitypilot' ), 'color' => 'green' ), 'description' => sprintf( '%s
', __( 'Critical events are within normal levels.', 'activitypilot' ) ), 'actions' => '', 'test' => 'apwpm_critical', ); } public static function test_hashchain() { if ( ! APWPM_Integrity::enabled() ) { return array( 'label' => __( 'Activity log tamper detection is disabled', 'activitypilot' ), 'status' => 'recommended', 'badge' => array( 'label' => __( 'Security', 'activitypilot' ), 'color' => 'orange' ), 'description' => sprintf( '%s
', __( 'Enable the hash chain in Activity Timeline settings to detect tampering of audit rows.', 'activitypilot' ) ), 'actions' => '', 'test' => 'apwpm_hashchain', ); } $result = APWPM_Integrity::verify( 5000 ); if ( ! empty( $result['ok'] ) ) { return array( 'label' => __( 'Activity log hash chain is intact', 'activitypilot' ), 'status' => 'good', 'badge' => array( 'label' => __( 'Security', 'activitypilot' ), 'color' => 'green' ), 'description' => sprintf( '%s
', sprintf( /* translators: %d: number of verified log rows */ __( 'Verified %d rows.', 'activitypilot' ), (int) ( $result['checked'] ?? 0 ) ) ), 'actions' => '', 'test' => 'apwpm_hashchain', ); } return array( 'label' => __( 'Activity log hash chain is broken', 'activitypilot' ), 'status' => 'critical', 'badge' => array( 'label' => __( 'Security', 'activitypilot' ), 'color' => 'red' ), 'description' => sprintf( '%s
', sprintf( /* translators: %d: log row ID where the hash chain breaks */ __( 'Tampering detected — chain breaks at row #%d.', 'activitypilot' ), (int) ( $result['broken_at'] ?? 0 ) ) ), 'actions' => '', 'test' => 'apwpm_hashchain', ); } }