Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add environment DEBUG #92

Merged
merged 1 commit into from
Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 功能
* 增加 `pymongo` 策略规则以检测 NoSQL 注入漏洞 #84
* 增加 `python-ldap` and `ldap3` 策略规则以检测 LDAP 注入漏洞 #86, #88
* 使用环境变量 `DEBUG=1` 开启 DEBUG 模式 #92
* 修复
* 修复请求头和响应头格式 #87

Expand Down
21 changes: 12 additions & 9 deletions README.ZH_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

## 快速上手

Expand Down Expand Up @@ -76,6 +77,7 @@ DongTai-agent-python

#### 环境变量

* 开启调试: `DEBUG=1`
* 自动创建项目: `AUTO_CREATE_PROJECT=1`
* 项目名称: `PROJECT_NAME=Demo`
* 项目版本: `PROJECT_VERSION=v1.0`
Expand All @@ -84,6 +86,7 @@ DongTai-agent-python

也可以配置 `dongtai_agent_python/config.json` 中相关的配置项,同样生效

* `debug`
* `project.name`
* `project.version`
* `engine.name`
Expand Down
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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`
Expand All @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion dongtai_agent_python/common/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions dongtai_agent_python/setting/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down