Skip to content
This repository was archived by the owner on Apr 20, 2022. It is now read-only.

Commit 6311e60

Browse files
authored
Merge pull request #43 from HXSecurity/feature/issue-80
Feature/issue 80
2 parents 930af9d + ab0750b commit 6311e60

File tree

9 files changed

+109
-40
lines changed

9 files changed

+109
-40
lines changed

.github/workflows/release_engine.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Release DongTai Engine
4+
5+
on:
6+
push:
7+
branches: [ "release-*" ]
8+
9+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
10+
jobs:
11+
# This workflow contains a single job called "build"
12+
build:
13+
# The type of runner that the job will run on
14+
runs-on: ubuntu-latest
15+
strategy:
16+
max-parallel: 4
17+
matrix:
18+
python-version: [3.7]
19+
20+
# Steps represent a sequence of tasks that will be executed as part of the job
21+
steps:
22+
- name: start-build
23+
uses: joelwmale/webhook-action@master
24+
with:
25+
url: ${{ secrets.WEBHOOK_URL }}
26+
body: '{"msg_type": "interactive","card": {"config": {"wide_screen_mode": true,"enable_forward": true},"elements": [{"tag": "div","text": {"content": "状态:项目${{github.repository}}构建开始\n分支:${{github.ref}}\n流程:${{github.workflow}}\n构建编号:${{github.run_number}}\n触发事件:${{github.event_name}}\n提交人:${{github.actor}}\nSHA-1:${{github.sha}}\n","tag": "lark_md"}}]}}'
27+
28+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
29+
- name: Set up Python 3.7
30+
uses: actions/checkout@v1
31+
with:
32+
python-version: 3.7
33+
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install -r requirements-prod.txt
38+
39+
- name: Lint with flake8
40+
run: |
41+
pip install flake8
42+
# stop the build if there are Python syntax errors or undefined names
43+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
44+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
45+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
46+
47+
- name: Checkout
48+
uses: actions/checkout@v2
49+
50+
- name: Set up QEMU
51+
uses: docker/setup-qemu-action@v1
52+
53+
- name: Set up Docker Buildx
54+
uses: docker/setup-buildx-action@v1
55+
56+
- name: Login to DockerHub
57+
uses: docker/login-action@v1
58+
with:
59+
registry: ${{ secrets.ALIYUN_REGISTRY }}
60+
username: ${{ secrets.ALIYUN_DOCKERHUB_USER }}
61+
password: ${{ secrets.ALIYUN_DOCKERHUB_PASSWORD }}
62+
63+
- name: Build and push
64+
uses: docker/build-push-action@v2
65+
with:
66+
context: .
67+
push: true
68+
tags: "registry.cn-beijing.aliyuncs.com/huoxian_pub/dongtai-engine:1.0.0,"
69+
70+
- name: finish build
71+
uses: joelwmale/webhook-action@master
72+
with:
73+
url: ${{ secrets.WEBHOOK_URL }}
74+
body: '{"msg_type": "interactive","card": {"config": {"wide_screen_mode": true,"enable_forward": true},"elements": [{"tag": "div","text": {"content": "状态:项目${{github.repository}}构建成功\n分支:${{github.ref}}\n流程:${{github.workflow}}\n构建编号:${{github.run_number}}\n触发事件:${{github.event_name}}\n提交人:${{github.actor}}\nSHA-1:${{github.sha}}\n","tag": "lark_md"}}]}}'

conf/uwsgi.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
#uwsgi监听的socket,可以为socket文件或ip地址+端口号,用nginx的时候就配socket , 直接运行的时候配 http, http-socket = 127.0.0.1:8080
44
http = :8000
55

6-
listen = 1024
7-
86
#指定项目的目录,在app加载前切换到当前目录
97
chdir = /opt/dongtai/engine
108

core/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ def update_sca():
399399

400400

401401
def is_alive(agent_id, timestamp):
402-
return IastHeartbeat.objects.values('id').filter(agent__id=agent_id, dt__gt=(timestamp - 600)).exists()
402+
return IastHeartbeat.objects.values('id').filter(agent__id=agent_id, dt__gt=(timestamp - 60 * 20)).exists()
403403

404404

405405
@shared_task(queue='dongtai-periodic-task')

deploy/deploy-eks-iast-saas-engine-prod.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: iast-engine
4+
name: dongtai-engine
55
namespace: iast-prod
66
annotations:
7-
kubesphere.io/description: iast-engine
7+
kubesphere.io/description: dongtai-engine
88
labels:
9-
app: iast-engine
9+
app: dongtai-engine
1010
spec:
1111
replicas: 5
1212
selector:
1313
matchLabels:
14-
app: iast-engine
14+
app: dongtai-engine
1515
template:
1616
metadata:
1717
labels:
18-
app: iast-engine
18+
app: dongtai-engine
1919
spec:
2020
containers:
21-
- name: iast-engine-container
21+
- name: dongtai-engine-container
2222
image: registry.cn-beijing.aliyuncs.com/secnium/iast-saas-engine:VERSION
2323
imagePullPolicy: Always
2424
volumeMounts:
@@ -38,6 +38,6 @@ spec:
3838
volumes:
3939
- name: configfile
4040
configMap:
41-
name: iast-test-config.ini
41+
name: dongtai-iast-config-prod.ini
4242
imagePullSecrets:
4343
- name: aliyun-registry-secret

deploy/deploy-eks-iast-saas-engine-task-prod.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
apiVersion: apps/v1
22
kind: Deployment
33
metadata:
4-
name: iast-engine-task
4+
name: dongtai-engine-task
55
namespace: iast-prod
66
annotations:
7-
kubesphere.io/description: iast-engine-task
7+
kubesphere.io/description: dongtai-engine-task
88
labels:
9-
app: iast-engine-task
9+
app: dongtai-engine-task
1010
spec:
1111
replicas: 1
1212
selector:
1313
matchLabels:
14-
app: iast-engine-task
14+
app: dongtai-engine-task
1515
template:
1616
metadata:
1717
labels:
18-
app: iast-engine-task
18+
app: dongtai-engine-task
1919
spec:
2020
containers:
21-
- name: iast-engine-task-container
21+
- name: dongtai-engine-task-container
2222
image: registry.cn-beijing.aliyuncs.com/secnium/iast-saas-engine:VERSION
2323
command: ["/bin/bash","/opt/dongtai/engine/docker/entrypoint.sh"]
2424
args: ["task"]
@@ -40,6 +40,6 @@ spec:
4040
volumes:
4141
- name: configfile
4242
configMap:
43-
name: iast-test-config.ini
43+
name: dongtai-iast-config-prod.ini
4444
imagePullSecrets:
4545
- name: aliyun-registry-secret

lingzhi_engine/celery.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,23 @@
2525
# should have a `CELERY_` prefix.
2626

2727
configs["CELERY_QUEUES"] = [
28-
Queue("dongtai-method-pool-scan", Exchange("method_pool"), routing_key="method_pool"),
29-
Queue("dongtai-replay-vul-scan", Exchange("method_pool"), routing_key="method_pool"),
30-
Queue("dongtai-strategy-scan", Exchange("strategy"), routing_key="strategy"),
31-
Queue("dongtai-search-scan", Exchange("search"), routing_key="search"),
32-
Queue("dongtai-periodic-task", Exchange("periodic_task"), routing_key="periodic_task"),
33-
Queue("dongtai-replay-task", Exchange("replay_task"), routing_key="replay_task"),
28+
Queue("dongtai-method-pool-scan", Exchange("dongtai-method-pool-scan"), routing_key="dongtai-method-pool-scan"),
29+
Queue("dongtai-replay-vul-scan", Exchange("dongtai-replay-vul-scan"), routing_key="dongtai-replay-vul-scan"),
30+
Queue("dongtai-strategy-scan", Exchange("dongtai-strategy-scan"), routing_key="dongtai-strategy-scan"),
31+
Queue("dongtai-search-scan", Exchange("dongtai-search-scan"), routing_key="dongtai-search-scan"),
32+
Queue("dongtai-periodic-task", Exchange("dongtai-periodic-task"), routing_key="dongtai-periodic-task"),
33+
Queue("dongtai-replay-task", Exchange("dongtai-replay-task"), routing_key="dongtai-replay-task"),
3434
]
3535
configs["CELERY_ROUTES"] = {
36-
"core.tasks.search_vul_from_method_pool": {'exchange': 'method_pool', 'routing_key': 'method_pool'},
37-
"core.tasks.search_vul_from_strategy": {'exchange': 'strategy', 'routing_key': 'strategy'},
38-
"core.tasks.search_sink_from_method_pool": {'exchange': 'search', 'routing_key': 'search'},
39-
"core.tasks.update_sca": {'exchange': 'periodic_task', 'routing_key': 'periodic_task'},
40-
"core.tasks.update_agent_status": {'exchange': 'periodic_task', 'routing_key': 'periodic_task'},
41-
"core.tasks.heartbeat": {'exchange': 'periodic_task', 'routing_key': 'periodic_task'},
42-
"core.tasks.clear_error_log": {'exchange': 'periodic_task', 'routing_key': 'periodic_task'},
43-
"core.tasks.vul_recheck": {'exchange': 'replay_task', 'routing_key': 'replay_task'},
36+
"core.tasks.search_vul_from_method_pool": {'exchange': 'dongtai-method-pool-scan', 'routing_key': 'dongtai-method-pool-scan'},
37+
"core.tasks.search_vul_from_strategy": {'exchange': 'dongtai-strategy-scan', 'routing_key': 'dongtai-strategy-scan'},
38+
"core.tasks.search_vul_from_replay_method_pool": {'exchange': 'dongtai-replay-vul-scan', 'routing_key': 'dongtai-replay-vul-scan'},
39+
"core.tasks.search_sink_from_method_pool": {'exchange': 'dongtai-search-scan', 'routing_key': 'dongtai-search-scan'},
40+
"core.tasks.update_sca": {'exchange': 'dongtai-periodic-task', 'routing_key': 'dongtai-periodic-task'},
41+
"core.tasks.update_agent_status": {'exchange': 'dongtai-periodic-task', 'routing_key': 'dongtai-periodic-task'},
42+
"core.tasks.heartbeat": {'exchange': 'dongtai-periodic-task', 'routing_key': 'dongtai-periodic-task'},
43+
"core.tasks.clear_error_log": {'exchange': 'dongtai-periodic-task', 'routing_key': 'dongtai-periodic-task'},
44+
"core.tasks.vul_recheck": {'exchange': 'dongtai-replay-task', 'routing_key': 'dongtai-replay-task'},
4445
}
4546
configs["CELERY_ENABLE_UTC"] = False
4647
configs["CELERY_TIMEZONE"] = settings.TIME_ZONE

signals/handlers/vul_handler.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,10 @@ def save_vul(vul_meta, vul_level, vul_name, vul_stack, top_stack, bottom_stack,
230230

231231
vul = IastVulnerabilityModel.objects.filter(
232232
type=vul_name, # 指定漏洞类型
233-
url=vul_meta.url,
233+
uri=vul_meta.uri,
234234
http_method=vul_meta.http_method,
235-
taint_position=taint_position,
236-
param_name=param_name,
237-
agent=vul_meta.agent
235+
agent=vul_meta.agent,
236+
method_pool_id=vul_meta.id
238237
).first()
239238
if vul:
240239
vul.req_header = vul_meta.req_header

test/core/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_search_vul_from_replay_method_pool(self):
1717
search_vul_from_replay_method_pool(method_id)
1818

1919
def test_search_vul_from_method_pool(self):
20-
method_pool_id = 585
20+
method_pool_id = 2311521
2121
from core.tasks import search_vul_from_method_pool
2222
search_vul_from_method_pool(method_pool_id)
2323

test/task.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest
22

3-
from core.tasks import maven_spider, heartbeat
3+
from core.tasks import heartbeat, search_vul_from_method_pool
44
from test import DongTaiTestCase
55

66

@@ -56,9 +56,6 @@ def test_agent_status_update(self):
5656
from core.tasks import update_agent_status
5757
update_agent_status()
5858

59-
def test_maven_spider(self):
60-
maven_spider()
61-
6259
def test_heart_beat(self):
6360
import os
6461
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lingzhi_engine.settings")

0 commit comments

Comments
 (0)