dcg

Elasticsearch

search.elasticsearch

Protects against destructive Elasticsearch REST API operations like index deletion, delete-by-query, index close, and cluster setting changes.

  • 10blocking rules
  • 6safe patterns
  • 2Critical
  • 6High
  • 2Medium
~/.config/dcg/config.toml
[packs]
enabled = ["search.elasticsearch"]

Evaluated when a command contains elasticsearch, curl, http, 9200, _search, _cluster, _cat, _doc, _all, _delete_by_query.

Blocking rules

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

  1. es-curl-delete-index

    Critical

    curl -X DELETE against an Elasticsearch index (or _all/*) deletes data permanently.

    Explanation
    Deleting an index permanently removes all documents, mappings, and settings. Using _all or * wildcards can delete multiple indices at once. This operation is immediate and irreversible. Data cannot be recovered without snapshots. Safer alternatives: - GET /_cat/indices to review before deletion - Create a snapshot before deleting - Disable action.destructive_requires_name for safety
  2. es-http-delete-index

    Critical

    http DELETE against an Elasticsearch index (or _all/*) deletes data permanently.

    Explanation
    Deleting an index permanently removes all documents, mappings, and settings. Using _all or * wildcards can delete multiple indices at once. This operation is immediate and irreversible. Data cannot be recovered without snapshots. Safer alternatives: - GET /_cat/indices to review before deletion - Create a snapshot before deleting - Disable action.destructive_requires_name for safety
  3. es-curl-close-index

    High

    curl -X POST to _close closes an index, making it unavailable for reads/writes.

    Explanation
    Closing an index blocks all read and write operations. Applications will receive errors when accessing closed indices. Closed indices still consume disk space but release memory. Use _all with extreme caution. Safer alternatives: - GET /_cat/indices to review indices first - Close specific indices rather than patterns - Use index lifecycle management for automated handling
  4. es-curl-cluster-settings

    High

    curl -X PUT to /_cluster/settings changes cluster settings and can be dangerous.

    Explanation
    Cluster settings affect all nodes and can impact stability, performance, and data integrity. Persistent settings survive restarts. Changes to allocation, recovery, or shard settings can trigger data movement. Safer alternatives: - GET /_cluster/settings to review current values - Use transient settings for testing - Test changes on non-production clusters first
  5. es-curl-delete-by-query

    High

    curl -X POST to _delete_by_query deletes documents matching the query.

    Explanation
    Delete-by-query removes all documents matching the query criteria. A malformed query can delete far more documents than intended. The operation runs asynchronously and cannot be easily cancelled once started. Safer alternatives: - Run the query with _search first to preview matches - Use scroll_size to limit batch size - Set wait_for_completion=false and monitor progress
  6. es-http-close-index

    High

    http POST to _close closes an index, making it unavailable for reads/writes.

    Explanation
    Closing an index blocks all read and write operations. Applications will receive errors when accessing closed indices. Closed indices still consume disk space but release memory. Use _all with extreme caution. Safer alternatives: - GET /_cat/indices to review indices first - Close specific indices rather than patterns - Use index lifecycle management for automated handling
  7. es-http-cluster-settings

    High

    http PUT to /_cluster/settings changes cluster settings and can be dangerous.

    Explanation
    Cluster settings affect all nodes and can impact stability, performance, and data integrity. Persistent settings survive restarts. Changes to allocation, recovery, or shard settings can trigger data movement. Safer alternatives: - GET /_cluster/settings to review current values - Use transient settings for testing - Test changes on non-production clusters first
  8. es-http-delete-by-query

    High

    http POST to _delete_by_query deletes documents matching the query.

    Explanation
    Delete-by-query removes all documents matching the query criteria. A malformed query can delete far more documents than intended. The operation runs asynchronously and cannot be easily cancelled once started. Safer alternatives: - Run the query with _search first to preview matches - Use scroll_size to limit batch size - Set wait_for_completion=false and monitor progress
  9. es-curl-delete-doc

    Medium

    curl -X DELETE against /_doc deletes a document from Elasticsearch.

    Explanation
    Deleting a document removes it from the index. The document ID becomes available for reuse. Applications expecting this document will receive 404 errors. Search results will no longer include this document. Safer alternatives: - GET the document first to verify - Use document versioning for conflict detection - Index a tombstone document instead of deleting
  10. es-http-delete-doc

    Medium

    http DELETE against /_doc deletes a document from Elasticsearch.

    Explanation
    Deleting a document removes it from the index. The document ID becomes available for reuse. Applications expecting this document will receive 404 errors. Search results will no longer include this document. Safer alternatives: - GET the document first to verify - Use document versioning for conflict detection - Index a tombstone document instead of deleting

Safe patterns

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

  • es-curl-get-search
  • es-curl-get-cat
  • es-curl-get-cluster-health
  • es-http-get-search
  • es-http-get-cat
  • es-http-get-cluster-health