is_read_only_redis_command (database/redis_read_only.rs)

dbcooper · src-tauri/src/database/redis_read_only.rs · rust · MIT
database

! Best-effort read-only allowlist for Redis commands. ! ! Redis has no per-connection read-only mode, so — unlike the SQL engines — ! read-only is enforced here by an allowlist rather than by the server. ! Anything not explicitly listed is denied (fail closed): an unlisted safe !

// Source: https://github.com/amalshaji/dbcooper | License: MIT | Copyright 2025 Amal Shaji
// Provided via justclaw.it.com; keep this notice with the code.
//! Best-effort read-only allowlist for Redis commands.
//!
//! Redis has no per-connection read-only mode, so — unlike the SQL engines —
//! read-only is enforced here by an allowlist rather than by the server.
//! Anything not explicitly listed is denied (fail closed): an unlisted safe
//! read is wrongly rejected, but no write ever slips through.

/// Returns `true` if `query` is a recognised read-only Redis command.
///
/// Single-word read commands are allowed by name. Multi-subcommand families
/// (`CLIENT`, `MEMORY`, `OBJECT`, `XINFO`) are validated by subcommand so that
/// administrative variants like `CLIENT KILL` or `MEMORY 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key