dcg

NATS

messaging.nats

Protects against destructive NATS/JetStream operations like deleting streams, consumers, key-value entries, objects, and accounts.

  • 6blocking rules
  • 10safe patterns
  • 2Critical
  • 4High
~/.config/dcg/config.toml
[packs]
enabled = ["messaging.nats"]

Evaluated when a command contains nats.

Blocking rules

Each rule ID is messaging.nats:<name>. Use it in allowlists and [policy.rules].

  1. nats-account-delete

    Critical

    nats account delete removes an account and its resources.

    Explanation
    Deleting a NATS account removes all streams, consumers, and permissions associated with that account. All applications using this account will lose connectivity. Safer alternatives: - Review account resources before deletion - Migrate resources to another account first - Disable the account instead of deleting
  2. nats-stream-delete

    Critical

    nats stream delete/rm removes a JetStream stream and all its messages.

    Explanation
    Deleting a JetStream stream permanently removes all stored messages, consumers, and configuration. Applications relying on this stream will lose access to historical data. Safer alternatives: - nats stream info: Review stream details first - nats stream purge: Remove messages but keep the stream - Back up stream configuration before deletion
  3. nats-consumer-delete

    High

    nats consumer delete/rm removes a JetStream consumer.

    Explanation
    Deleting a consumer removes its acknowledgment state and delivery tracking. Messages may be redelivered to other consumers or lost if this was the only consumer. Safer alternatives: - nats consumer info: Review consumer state first - Pause the consumer instead of deleting - Ensure other consumers exist for critical streams
  4. nats-kv-delete

    High

    nats kv del/rm deletes key-value entries.

    Explanation
    Deleting KV entries removes data that applications may depend on. If history is disabled, the deletion is permanent and cannot be recovered. Safer alternatives: - nats kv get: Retrieve and back up the value first - nats kv history: Check if history is enabled - Use TTL for automatic expiration instead of manual deletion
  5. nats-object-delete

    High

    nats object delete removes an object from the store.

    Explanation
    Deleting an object from the object store removes the file and its metadata. Applications expecting this object will receive errors. Safer alternatives: - nats object info: Review object details first - Download the object before deletion - Use object versioning if available
  6. nats-stream-purge

    High

    nats stream purge deletes ALL messages from the stream.

    Explanation
    Purging a stream removes all messages while keeping the stream and consumer configurations intact. Consumers will have no messages to process until new ones arrive. Safer alternatives: - nats stream info: Check message count first - Use --seq to purge only messages up to a specific sequence - Use --keep to retain the last N messages

Safe patterns

Checked first. A command that matches one is never blocked by this pack.

  • nats-stream-info
  • nats-stream-ls
  • nats-consumer-info
  • nats-consumer-ls
  • nats-kv-get
  • nats-kv-ls
  • nats-pub
  • nats-sub
  • nats-server-info
  • nats-bench