diff --git a/CHANGELOG.md b/CHANGELOG.md index 51ce4e8..7865440 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * FEATURES * Add `pymongo` hook rules for NoSQL injection detection #84 * Add `python-ldap` and `ldap3` hook rules for LDAP injection detection #86, #88 + * Use the environment variable `DEBUG=1` to enable debug mode #92 * BUGFIXES * Fix request and response header formats #87 diff --git a/CHANGELOG_CN.md b/CHANGELOG_CN.md index 89765f6..bba15c6 100644 --- a/CHANGELOG_CN.md +++ b/CHANGELOG_CN.md @@ -5,6 +5,7 @@ * 功能 * 增加 `pymongo` 策略规则以检测 NoSQL 注入漏洞 #84 * 增加 `python-ldap` and `ldap3` 策略规则以检测 LDAP 注入漏洞 #86, #88 + * 使用环境变量 `DEBUG=1` 开启 DEBUG 模式 #92 * 修复 * 修复请求头和响应头格式 #87 diff --git a/README.ZH_CN.md b/README.ZH_CN.md index 10a6822..7e850d9 100644 --- a/README.ZH_CN.md +++ b/README.ZH_CN.md @@ -30,17 +30,18 @@ DongTai-agent-python * Python: >=3.6 * CPython -* gcc (Linux/macOS) -* make (Linux/macOS) -* cmake -* Visual Studio (Windows) +* 编译依赖 + * gcc (Linux/macOS) + * make (Linux/macOS) + * cmake + * Visual Studio (Windows) * Web 框架 - * Django: 3.0-3.2, 4.0 - * Flask: 1.0-1.2, 2.0 + * Django: 3.0-3.2, 4.0 + * Flask: 1.0-1.2, 2.0 * Python 依赖包 - * psutil: >= 5.8.0 - * requests: >= 2.25.1 - * pip: >= 19.2.3 + * psutil: >= 5.8.0 + * requests: >= 2.25.1 + * pip: >= 19.2.3 ## 快速上手 @@ -76,6 +77,7 @@ DongTai-agent-python #### 环境变量 +* 开启调试: `DEBUG=1` * 自动创建项目: `AUTO_CREATE_PROJECT=1` * 项目名称: `PROJECT_NAME=Demo` * 项目版本: `PROJECT_VERSION=v1.0` @@ -84,6 +86,7 @@ DongTai-agent-python 也可以配置 `dongtai_agent_python/config.json` 中相关的配置项,同样生效 +* `debug` * `project.name` * `project.version` * `engine.name` diff --git a/README.md b/README.md index 6cfabc3..12e1fac 100644 --- a/README.md +++ b/README.md @@ -32,17 +32,18 @@ DongTai-agent-python * Python: >=3.6 * CPython -* gcc (Linux/macOS) -* make (Linux/macOS) -* cmake -* Visual Studio (Windows) +* Compiling Dependencies + * gcc (Linux/macOS) + * make (Linux/macOS) + * cmake + * Visual Studio (Windows) * Web Framework - * Django: 3.0-3.2, 4.0 - * Flask: 1.0-1.2, 2.0 + * Django: 3.0-3.2, 4.0 + * Flask: 1.0-1.2, 2.0 * Python packages - * psutil: >= 5.8.0 - * requests: >= 2.25.1 - * pip: >= 19.2.3 + * psutil: >= 5.8.0 + * requests: >= 2.25.1 + * pip: >= 19.2.3 ## Quick Start @@ -81,6 +82,7 @@ Please refer to the [Quick Start](https://doc.dongtai.io/en/02_start/index.html) #### Environment Variables +* DEBUG mode: `DEBUG=1` * Auto Create Project: `AUTO_CREATE_PROJECT=1` * Project Name: `PROJECT_NAME=Demo` * Project Version: `PROJECT_VERSION=v1.0` @@ -89,6 +91,7 @@ Please refer to the [Quick Start](https://doc.dongtai.io/en/02_start/index.html) You can also configure the value in `dongtai_agent_python/config.json` +* `debug` * `project.name` * `project.version` * `engine.name` diff --git a/dongtai_agent_python/common/logger.py b/dongtai_agent_python/common/logger.py index 392cb84..4eab905 100644 --- a/dongtai_agent_python/common/logger.py +++ b/dongtai_agent_python/common/logger.py @@ -64,7 +64,7 @@ def logger_config(logging_name): logger = logging.getLogger(logging_name) logger.handlers.clear() - if setting.config.get("debug"): + if setting.debug: level = logging.DEBUG else: level = logging.INFO diff --git a/dongtai_agent_python/setting/setting.py b/dongtai_agent_python/setting/setting.py index e3d9218..5650aa7 100644 --- a/dongtai_agent_python/setting/setting.py +++ b/dongtai_agent_python/setting/setting.py @@ -26,6 +26,7 @@ def init(self): self.container = {} self.config = Config() + self.debug = self.config.get("debug", False) self.project_name = self.config.get('project', {}).get('name', 'Demo Project') self.project_version = self.config.get('project', {}).get('version', '') # engine.name will auto generated when download @@ -44,6 +45,9 @@ def init_os_environ(self): if not isinstance(os_env, dict): return + if os_env.get('DEBUG', '') == '1': + self.debug = True + # windows always upper case env key project_name = os_env.get('PROJECT_NAME', '') or os_env.get('PROJECTNAME', '') or os_env.get('projectName', '') if project_name: