首页
/ TheHive项目应用配置文件详解与技术指南

TheHive项目应用配置文件详解与技术指南

2025-07-09 04:48:06作者:卓炯娓

概述

TheHive是一款开源的网络安全事件响应平台,其核心配置文件application.conf是系统运行的关键所在。本文将深入解析该配置文件的各项参数,帮助管理员正确配置TheHive平台以满足不同场景下的需求。

安全密钥配置

安全密钥是TheHive应用的基础安全配置,建议采用外部文件引用的方式管理:

include "/etc/thehive/secret.conf"

这种分离式管理方式符合安全最佳实践,避免将敏感信息直接存储在应用配置文件中。密钥文件应设置严格的访问权限,仅允许TheHive进程读取。

数据库配置详解

TheHive支持多种数据库后端,配置位于db.janusgraph部分:

生产环境推荐配置(Cassandra)

storage {
  backend: cql
  hostname: ["ip1", "ip2"]
  username: "thehive"
  password: "password"
  cql {
    cluster-name: thp
    keyspace: thehive
  }
}

关键参数说明:

  • backend: 指定使用Cassandra作为存储后端
  • hostname: Cassandra集群节点地址数组
  • cql.cluster-name: 自定义集群名称
  • keyspace: 数据库keyspace名称

索引配置

index.search {
  backend: lucene
  directory: /opt/thp/thehive/index
}

对于单机部署,Lucene是轻量级的选择。集群环境必须使用Elasticsearch:

index.search {
  backend: elasticsearch
  hostname: ["ip1", "ip2"]
  index-name: thehive
}

测试环境配置(BerkeleyJE)

storage.backend: berkeleyje
storage.directory: /opt/thp/thehive/database

BerkeleyJE适合测试和开发环境,但不建议用于生产环境。可设置磁盘使用阈值:

berkeleyje.freeDisk: 200 # 单位MB

附件存储配置

TheHive支持多种附件存储方案:

本地文件系统

provider: localfs
localfs.location: /path/to/files

HDFS分布式存储

provider: hdfs
hdfs {
  root: "hdfs://localhost:10000"
  location: "/thehive"
  username: thehive
}

认证配置

认证模块支持多种认证方式:

auth {
  providers: [
    {name: session}               # 必须包含
    {name: basic, realm: thehive} # HTTP基本认证
    {name: local}                 # 本地用户认证
    {name: key}                  # API密钥认证
  ]
  defaultUserDomain: "thehive.local"
}

认证提供者可以组合使用,session提供者是必须的。defaultUserDomain用于自动补全用户邮箱域名。

集成服务配置

Cortex集成

play.modules.enabled += org.thp.thehive.connector.cortex.CortexModule
cortex {
  servers: [
    {
      name: "local"
      url: "http://localhost:9001"
      auth {
        type: "bearer"
        key: "***"
      }
      wsConfig {}
    }
  ]
}

MISP集成

play.modules.enabled += org.thp.thehive.connector.misp.MispModule
misp {
  interval: 1 hour
  servers: [
    {
      name = "local"
      url = "http://localhost/"
      auth {
        type = key
        key = "***"
      }
      wsConfig {}
    }
  ]
}

高级配置

附件大小限制

play.http.parser.maxDiskBuffer: 1GB

默认限制为10MB,可根据实际需求调整此值。注意增大此值可能影响系统性能。

最佳实践建议

  1. 生产环境务必使用Cassandra或Elasticsearch作为后端
  2. 安全密钥应通过外部文件管理
  3. 认证配置应根据组织安全策略定制
  4. 集成服务配置前确保网络连通性和API密钥正确
  5. 定期备份关键配置和数据库

通过合理配置这些参数,TheHive可以适应从开发测试到大规模生产环境的各种需求场景。