dcg

Apache Kafka

messaging.kafka

Protects against destructive Kafka CLI operations like deleting topics, removing consumer groups, resetting offsets, and deleting records.

  • 7blocking rules
  • 9safe patterns
  • 3Critical
  • 4High
~/.config/dcg/config.toml
[packs]
enabled = ["messaging.kafka"]

Evaluated when a command contains kafka-topics, kafka-topics.sh, kafka-consumer-groups, kafka-consumer-groups.sh, kafka-configs, kafka-configs.sh, kafka-acls, kafka-acls.sh, kafka-delete-records, kafka-delete-records.sh.

Blocking rules

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

  1. kafka-delete-records

    Critical

    kafka-delete-records deletes records up to specified offsets.

    Explanation
    This command permanently deletes messages from topic partitions up to the specified offsets. Deleted data cannot be recovered. Consumers attempting to read deleted offsets will encounter errors. Safer alternatives: - Use retention policies for automatic data expiration - Verify the offset JSON file carefully before execution - Consider topic compaction for key-based retention
  2. kafka-topics-delete

    Critical

    kafka-topics --delete removes Kafka topics and data.

    Explanation
    Deleting a Kafka topic permanently removes all messages and partitions. Consumers will receive errors, and any unprocessed data is lost. Producer applications may fail until they handle the missing topic. Safer alternatives: - kafka-topics --describe: Review topic details first - Set retention.ms to expire data naturally - Back up critical data before deletion
  3. rpk-topic-delete

    Critical

    rpk topic delete removes topics (Kafka-compatible).

    Explanation
    Deleting a topic via rpk (Redpanda) permanently removes all data and partitions, similar to kafka-topics --delete. This affects both Redpanda and Kafka-compatible systems. Safer alternatives: - rpk topic describe: Review topic details first - rpk topic list: Verify the topic name - Use retention settings for data lifecycle management
  4. kafka-acls-remove

    High

    kafka-acls --remove deletes ACLs and can break access controls.

    Explanation
    Removing ACLs can immediately break access for producers and consumers. Applications may fail with authorization errors, causing message loss or processing delays. Safer alternatives: - kafka-acls --list: Review existing ACLs first - Test ACL changes in a non-production environment - Add new ACLs before removing old ones during transitions
  5. kafka-configs-delete-config

    High

    kafka-configs --alter --delete-config removes broker/topic configs.

    Explanation
    Deleting configuration overrides reverts topics or brokers to default settings. This can unexpectedly change retention, replication, or compression behavior. Safer alternatives: - kafka-configs --describe: Review current configuration first - Set explicit values instead of deleting to revert to defaults - Test configuration changes in a non-production environment
  6. kafka-consumer-groups-delete

    High

    kafka-consumer-groups --delete removes consumer groups and offsets.

    Explanation
    Deleting a consumer group removes all committed offsets. When consumers reconnect, they will start from the earliest or latest offset based on their configuration, potentially reprocessing or skipping messages. Safer alternatives: - kafka-consumer-groups --describe: Check group status first - Reset offsets instead of deleting the group - Ensure all consumers are stopped before deletion
  7. kafka-consumer-groups-reset-offsets

    High

    kafka-consumer-groups --reset-offsets rewinds offsets and can cause reprocessing.

    Explanation
    Resetting consumer offsets can cause messages to be reprocessed or skipped. This affects data consistency if your consumers are not idempotent. Resetting to the earliest offset on a high-volume topic may trigger massive reprocessing. Safer alternatives: - Use --dry-run to preview the reset first - Reset to a specific timestamp or offset for precision - Ensure consumers are stopped before resetting

Safe patterns

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

  • kafka-topics-list
  • kafka-topics-describe
  • kafka-consumer-groups-list
  • kafka-consumer-groups-describe
  • kafka-acls-list
  • kafka-configs-describe
  • kafka-console-consumer
  • kafka-console-producer
  • kafka-broker-api-versions