复制代码

为懒人提供无限可能,生命不息,code不止

人类感性的情绪,让我们知难行难
我思故我在
日拱一卒,功不唐捐
  • 首页
  • 前端
  • 后台
  • 数据库
  • 运维
  • 资源下载
  • 实用工具
  • 接口文档工具
  • 企业管理平台Demo
  • 登录
  • 注册

其它

【原创】数据库审计工具-archery的安装复盘

作者: whooyun发表于: 2026-01-24 16:33

版本清单:
0、Ubuntu24
1、Python 3.12.3
2、Archery (v1.13.0)
3、go-iception 1.3 https://github.com/hanchuanchuan/goInception/releases


避坑清单:
1、必须创建env,用来单独安装archery,并且对应系统账户需要具备执行,操作权限
2、安装完成后,archery并不会生成local_settings.py,所以需要自己创建一个,可一次从网上找一个
3、archery安装完成后,如果出现登录页样式或者js显示不完整,则需要使用nginx进行静态资源配置
4、SQL上线,提示需要配置工作流和检测SQL报错,则需要在系统管理-配置项管理-(右侧操作界面-系统设置-工单审核流配置)
5、要想检测SQL,提交SQL,必须安装,配置go-inception,否则无法使用SQL上线

参考配置:
local_settings.py
import os

# 修正:Python 中必须是 False
DEBUG = False

ALLOWED_HOSTS = ['*']
SECRET_KEY = 'archery_default_secret_key_123456'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'archery',
        'USER': 'root',
        'PASSWORD': 'ttt',
        'HOST': 'localhost',
        'PORT': '3306',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
            'charset': 'utf8mb4',
        }
    }
}

CACHEOPS_REDIS = "redis://127.0.0.1:6379/1"
Q_CLUSTER = {
    'name': 'archery',
    'workers': 4,
    'recycle': 500,
    'timeout': 60,
    'compress': True,
    'save_limit': 250,
    'queue_limit': 500,
    'label': 'Django Q',
    'redis': 'redis://127.0.0.1:6379/2'
}

# 自动适配静态资源路径
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

# ===============================
# Archery v1.13.0 关闭工作流审批
# ===============================

# 关闭工作流功能
ENABLE_WORKFLOW = False

# 关闭审批功能
ENABLE_APPROVAL = False

# 关闭 SQL 上线强制工作流
SQL_WORKFLOW_ENABLE = False

# 强制 SQL 上线不走审批(防止默认值)
REQUIRE_SQL_APPROVAL = False

# 允许域名
ALLOWED_HOSTS = ['ac.tt.com']

# 信任反向代理传递的 https 头(核心)
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Django 新版本必须加(否则 CSRF / static 会异常)
CSRF_TRUSTED_ORIGINS = ['https://ac.tt.com']

# 重要:不要强制 Django 自己做 https 跳转(由 Nginx 做)
SECURE_SSL_REDIRECT = False

# 可选(推荐)
USE_X_FORWARDED_HOST = True

nginx配置
server {
    listen 443 ssl;
    server_name ac.tt.com;

    # SSL 证书
    ssl_certificate     /etc/letsencrypt/live/ac.tt.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/ac.tt.com/privkey.pem;

    # 安全优化(你提供的 + 常用增强项)
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;

    # 建议开启 HSTS(如果确定长期只用 HTTPS)
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

    # 日志
    access_log  /var/log/nginx/archery.access.log;
    error_log   /var/log/nginx/archery.error.log;

    # 工单 / SQL 体积可能较大
    client_max_body_size 50m;
    
    # 1. 处理静态资源 (关键)
    location /static/ {
        # 这里的路径必须指向你在 local_settings.py 中定义的 STATIC_ROOT
        alias /opt/archery/static/;
        expires 7d;
        add_header Access-Control-Allow-Origin *;
    }

    location / {
        # Archery 后端端口(按你实际部署修改,常见 9123 或 8000)
        proxy_pass http://127.0.0.1:8000;

        # 代理头(Django 必须)
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;

        # 超时配置,避免审核SQL中断
        proxy_connect_timeout 60s;
        proxy_send_timeout    300s;
        proxy_read_timeout    300s;

proxy_redirect off;

        # 关闭缓存
        proxy_buffering off;
    }
}

server {
    listen 80;
    server_name ac.tt.com;

    # 强制跳转到 HTTPS
    return 301 https://$host$request_uri;
}

go-inception配置

# GoIncepiton 基础配置
host = "0.0.0.0"
port = 4000
path = "/tmp/tidb"
ignore_sighup = true

[log]
level = "info"
format = "text"

[inc]
# 这里的配置用于 GoInception 存储备份数据
backup_host = "127.0.0.1"
backup_port = 3306
backup_user = "root"
backup_password = "tt"

# 基础审核规则设置
enable_alter_database = false
enable_zero_date = true
enable_nullable = true
enable_drop_table = false
enable_set_engine = true
check_table_comment = true
check_column_comment = true
skip_grant_table = true
support_charset = "utf8,utf8mb4"
support_engine = "innodb"
lang = "zh-CN"