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

v1.15.0 #1820

Merged
merged 181 commits into from
Sep 15, 2023
Merged

v1.15.0 #1820

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
1142584
fix: remove print
st1020 Aug 17, 2023
c5e72c3
pref: improve app vul list pref
st1020 Aug 18, 2023
e119303
pref: use group celery tasks in sca bulk handler
st1020 Aug 18, 2023
a6660be
Merge pull request #1739 from st1020/fix/remove-print
Bidaya0 Aug 18, 2023
b5c7e74
Merge pull request #1749 from st1020/pref/sca-bulk-celery-tasks
Bidaya0 Aug 18, 2023
aeaa94b
feat: add session engine
st1020 Aug 21, 2023
317dd8b
Merge pull request #1753 from st1020/feat/add-session-engine
Bidaya0 Aug 21, 2023
c0791da
feat: remove outdate code
st1020 Aug 21, 2023
150889f
Merge pull request #1742 from st1020/pref/improve-app-vul-list-pref
st1020 Aug 21, 2023
ea35c2b
feat: remove outdate code
st1020 Aug 21, 2023
4d2513a
feat: set session expiry
st1020 Aug 22, 2023
00d6699
Merge pull request #1755 from st1020/feat/set-session-expiry
Bidaya0 Aug 22, 2023
f95055f
Merge pull request #1754 from st1020/feat/remove-outdate-code
Bidaya0 Aug 22, 2023
a359d73
fix: app vul list error
st1020 Aug 22, 2023
d3b2397
Merge pull request #1756 from st1020/fix/app-vul-list-error
st1020 Aug 22, 2023
70236c9
feat: add failed login count
st1020 Aug 22, 2023
ae00a02
Merge pull request #1757 from st1020/feat/failed-login-count
Bidaya0 Aug 22, 2023
01e3e99
feat: new patch implementation
st1020 Aug 24, 2023
6915411
feat: update ci
tscuite Aug 24, 2023
6d2ea37
Merge pull request #1760 from tscuite/develop
tscuite Aug 24, 2023
38ade47
fix: login error
st1020 Aug 24, 2023
7d1bf4f
fix: login error
st1020 Aug 24, 2023
5b7aaf4
feat: new patch implementation
st1020 Aug 24, 2023
2fecb78
Merge pull request #1761 from st1020/fix/login-error
Bidaya0 Aug 24, 2023
b7b4086
feat: add login lock status
st1020 Aug 24, 2023
bee92de
Merge pull request #1759 from st1020/feat/new-patch-impl
Bidaya0 Aug 24, 2023
87b17d5
Merge pull request #1762 from st1020/feat/add-login-lock-status
Bidaya0 Aug 24, 2023
7f339f3
feat: modify project summary api day_num field
st1020 Aug 24, 2023
c9e924f
build(deps): bump uwsgi from 2.0.21 to 2.0.22
dependabot[bot] Aug 24, 2023
69d4af4
Merge pull request #1764 from HXSecurity/dependabot/pip/uwsgi-2.0.22
Bidaya0 Aug 25, 2023
a0c1187
feat: method pool save
st1020 Aug 25, 2023
7af4ebe
feat: method pool save
st1020 Aug 25, 2023
129113a
feat: method pool save
st1020 Aug 25, 2023
0045fab
feat: method pool save
st1020 Aug 28, 2023
a8614c6
feat: modify project summary api day_num field
st1020 Aug 28, 2023
11b72b6
feat: method pool save
st1020 Aug 28, 2023
40efec3
fix: ruff error
st1020 Aug 28, 2023
29bd97b
feat: method pool save
st1020 Aug 28, 2023
0cd9688
feat: modify project summary api day_num field
st1020 Aug 28, 2023
5d210e8
feat: method pool save
st1020 Aug 28, 2023
2650e9a
Merge branch 'develop' into feat/method-pool-save
st1020 Aug 28, 2023
e27b9bd
feat: method pool save
st1020 Aug 28, 2023
3198094
Merge pull request #1763 from st1020/feat/modify-project-summary-day-num
st1020 Aug 28, 2023
c43e05a
Merge pull request #1766 from st1020/feat/method-pool-save
st1020 Aug 28, 2023
c54157e
feat: reduce memory usage in vul scan.
Bidaya0 Aug 28, 2023
7a7b758
feat: change to networkx
Bidaya0 Aug 28, 2023
014b79d
Merge branch 'develop' into feat/reduce-memory-usage
Bidaya0 Aug 28, 2023
5f89edd
deps: add networkx
Bidaya0 Aug 28, 2023
3732799
deps: add networkx
Bidaya0 Aug 28, 2023
3f7639a
deps: add networkx
Bidaya0 Aug 29, 2023
0191871
deps: add networkx
Bidaya0 Aug 29, 2023
dbe304a
feat: modify vul save logic
st1020 Aug 29, 2023
8750f3d
deps: add networkx
Bidaya0 Aug 29, 2023
68d2791
deps: add networkx
Bidaya0 Aug 29, 2023
d1e6f76
Merge pull request #1767 from Bidaya0/feat/reduce-memory-usage
Bidaya0 Aug 29, 2023
716902e
feat: modify vul save logic
st1020 Aug 29, 2023
8f6a3c7
feat: modify vul save logic
st1020 Aug 29, 2023
8ef1f45
feat: modify vul save logic
st1020 Aug 29, 2023
5f87136
Merge pull request #1768 from st1020/feat/change-vul-save
Bidaya0 Aug 29, 2023
c7b65ec
fix: vul method pool error
st1020 Aug 29, 2023
70a54e0
Merge pull request #1769 from st1020/fix/vul-method-pool-error
st1020 Aug 29, 2023
cf652d4
feat: add has vul method pool field
st1020 Aug 29, 2023
68f4599
fix: iast_vulnerability table migration
st1020 Aug 30, 2023
c56a957
feat: package focus
st1020 Aug 30, 2023
590373f
feat: package focus
st1020 Aug 30, 2023
c5d3970
Merge pull request #1771 from st1020/feat/add-has-vul-method-pool-field
Bidaya0 Aug 30, 2023
4cf5b82
Merge pull request #1772 from st1020/fix/vul-migration
Bidaya0 Aug 30, 2023
1bcb93e
Merge pull request #1773 from st1020/feat/package-focus
st1020 Aug 30, 2023
d4a0c97
feat: focus package priority
st1020 Aug 30, 2023
8028343
feat: focus package priority
st1020 Aug 30, 2023
43f10b1
Merge pull request #1775 from st1020/feat/focus-package-priority
Bidaya0 Aug 31, 2023
904d620
feat: add custom tag
Bidaya0 Sep 1, 2023
ceb5b14
Merge pull request #1777 from Bidaya0/feat/add-custom-tag
Bidaya0 Sep 1, 2023
248f1b3
feat: change hook strategy length limit.
Bidaya0 Sep 1, 2023
5c32901
Merge pull request #1778 from Bidaya0/feat/change-hook-strategy-lengt…
Bidaya0 Sep 1, 2023
214028d
add project topo api.
Bidaya0 Sep 1, 2023
db9f808
feat: add new topo graph model.
Bidaya0 Sep 1, 2023
6336aeb
feat: add new topo graph model.
Bidaya0 Sep 1, 2023
8ed0bad
feat: add new topo graph model.
Bidaya0 Sep 1, 2023
6ec843b
feat: add new topo graph model.
Bidaya0 Sep 1, 2023
a51103b
feat: add new topo graph model.
Bidaya0 Sep 1, 2023
4cf3ef4
Merge pull request #1779 from Bidaya0/feat/add-new-topo-table
Bidaya0 Sep 1, 2023
3b168c4
fix: memory reduce.
Bidaya0 Sep 1, 2023
e1f4023
deps: add pandas dependance
st1020 Sep 4, 2023
1a5498c
Merge pull request #1781 from st1020/deps/add-pandas-deps
st1020 Sep 4, 2023
870cb68
feat: custom max page size
st1020 Sep 4, 2023
4fd3c51
Merge pull request #1782 from st1020/feat/custom-max-page-size
st1020 Sep 4, 2023
79172d7
feat: modify notify
st1020 Sep 4, 2023
073cc48
feat: modify notify
st1020 Sep 4, 2023
73854b4
Merge pull request #1783 from st1020/feat/modify-notify
st1020 Sep 4, 2023
401dfb1
refactor: vul details api parse_graph
st1020 Sep 6, 2023
180188d
Merge pull request #1784 from st1020/refactor/vul-details
st1020 Sep 6, 2023
53fe75d
feat: update ci
tscuite Sep 6, 2023
309e8cb
Merge pull request #1785 from tscuite/develop
tscuite Sep 6, 2023
5222186
feat: add replay header
st1020 Sep 6, 2023
90fec8e
feat: add replay header
st1020 Sep 6, 2023
4ef89e0
Merge pull request #1786 from st1020/feat/add-replay-header
st1020 Sep 6, 2023
b84f784
feat: update ci
tscuite Sep 7, 2023
d6669f5
Merge pull request #1787 from tscuite/develop
tscuite Sep 7, 2023
f9fce7d
feat: update ci
tscuite Sep 8, 2023
0274fcd
Merge pull request #1788 from tscuite/develop
tscuite Sep 8, 2023
9a2da71
feat: modify hook strategy update logic
st1020 Sep 8, 2023
26d21a5
feat: update ci
tscuite Sep 8, 2023
7059245
Merge pull request #1790 from tscuite/develop
tscuite Sep 8, 2023
87cc6a1
feat: modify hook strategy update logic
st1020 Sep 8, 2023
9a59410
feat: update ci
tscuite Sep 8, 2023
f7fe5ee
Merge pull request #1791 from tscuite/develop
tscuite Sep 8, 2023
c95a302
feat: modify hook strategy update logic
st1020 Sep 8, 2023
28a64ad
feat: modify hook strategy update logic
st1020 Sep 8, 2023
50f9448
Merge pull request #1789 from st1020/feat/modify-hook_strategy
st1020 Sep 8, 2023
cd6b12a
feat: update ci
tscuite Sep 8, 2023
3f84716
Merge pull request #1792 from tscuite/develop
tscuite Sep 8, 2023
c9ce36c
feat: update ci
tscuite Sep 8, 2023
ce560bb
Merge pull request #1793 from tscuite/develop
tscuite Sep 8, 2023
773dbc4
feat: update ci
tscuite Sep 8, 2023
343fae4
Merge pull request #1794 from tscuite/develop
tscuite Sep 8, 2023
a2d170b
feat: heartbeat use celery task
st1020 Sep 11, 2023
9aaa4f9
fix: save vul did not save uri
st1020 Sep 11, 2023
293ad3a
feat: add project token
Bidaya0 Sep 11, 2023
5a62e32
feat: add project token
Bidaya0 Sep 11, 2023
5765508
feat: add project token
Bidaya0 Sep 11, 2023
36ef77a
Merge pull request #1797 from Bidaya0/feat/add-project-token
Bidaya0 Sep 11, 2023
8958afb
Merge pull request #1795 from st1020/feat/heartbeat-use-task
st1020 Sep 11, 2023
6f9e8d7
Merge pull request #1796 from st1020/fix/save-vul
st1020 Sep 11, 2023
e211537
feat: add project token
Bidaya0 Sep 11, 2023
5f81a21
feat: add project token
Bidaya0 Sep 11, 2023
cb9b8d3
Merge pull request #1798 from Bidaya0/feat/add-project-token-p2
Bidaya0 Sep 11, 2023
c29d92b
feat: add new migration
Bidaya0 Sep 12, 2023
e1a7c8e
feat: add new migration
Bidaya0 Sep 12, 2023
e9ce16e
Merge pull request #1799 from Bidaya0/feat/add-new-migration
Bidaya0 Sep 12, 2023
1a44f8b
fix: memory usage.
Bidaya0 Sep 12, 2023
63d6fc1
Merge pull request #1780 from Bidaya0/fix/memory-reduce
Bidaya0 Sep 12, 2023
2e32e82
dep: add new migration
Bidaya0 Sep 12, 2023
383c40e
Merge pull request #1800 from Bidaya0/dep/add-new-migration
Bidaya0 Sep 12, 2023
7a68866
fix: modify rule value
st1020 Sep 13, 2023
015e511
Merge pull request #1801 from st1020/fix/modify-rule-value
st1020 Sep 13, 2023
5e9a531
fix: set language
st1020 Sep 13, 2023
ccc7c14
Merge pull request #1802 from st1020/fix/set-lang
st1020 Sep 13, 2023
4ae170e
fix: modify rule value
st1020 Sep 13, 2023
f56fb84
Merge pull request #1803 from st1020/fix/modify-rule-value
st1020 Sep 13, 2023
33b1264
deps: add more itertools
Bidaya0 Sep 13, 2023
8f71f71
Merge pull request #1804 from Bidaya0/deps/add-deps
Bidaya0 Sep 13, 2023
f24ab8e
feat/project token p2
Bidaya0 Sep 13, 2023
63027b4
Merge pull request #1805 from Bidaya0/feat/project-token-p2
Bidaya0 Sep 13, 2023
a0369cf
feat/remove no risk level
Bidaya0 Sep 13, 2023
0189f30
Merge pull request #1806 from Bidaya0/feat/remove-norisk-level-in-pro…
Bidaya0 Sep 13, 2023
cf96f1a
feat/project token p2
Bidaya0 Sep 13, 2023
83c13bf
Merge pull request #1807 from Bidaya0/feat/project-token-p3
Bidaya0 Sep 13, 2023
287102d
fix: heartbeat task error
st1020 Sep 13, 2023
92316dc
feat/api route is cover.
Bidaya0 Sep 13, 2023
ccc8baa
feat/api route is cover.
Bidaya0 Sep 13, 2023
bed072b
Merge pull request #1809 from Bidaya0/feat/fix-api-route-cover-update
Bidaya0 Sep 13, 2023
443724c
Merge pull request #1808 from st1020/fix/heartbeat-task-error
Bidaya0 Sep 13, 2023
b111129
fix: heartbeat task error
st1020 Sep 13, 2023
abfba68
feat: sensitive info rule add system type
st1020 Sep 13, 2023
4fe3c08
Merge pull request #1811 from st1020/feat/sensitive-info-rule-add-sys…
Bidaya0 Sep 14, 2023
05fe77c
fix: heartbeat task error
st1020 Sep 14, 2023
b004b74
Merge pull request #1810 from st1020/fix/heartbeat-task-error
Bidaya0 Sep 14, 2023
d88f16b
fix: change to directed graph.
Bidaya0 Sep 14, 2023
b903c7d
fix: vul status const error
st1020 Sep 14, 2023
10cffe6
Merge pull request #1813 from st1020/fix/vul-status-const-error
Bidaya0 Sep 14, 2023
f94865a
Merge pull request #1812 from Bidaya0/fix/vul_engine_change_directed_…
Bidaya0 Sep 14, 2023
a3120c0
feat: add constratin in vec.
Bidaya0 Sep 14, 2023
f035716
feat: add constratin in vec.
Bidaya0 Sep 14, 2023
64285c9
Merge pull request #1814 from Bidaya0/feat/add_constrain_in_vec
Bidaya0 Sep 14, 2023
7a985ec
feat: add some doc.
Bidaya0 Sep 14, 2023
a41a7bb
feat: add some doc.
Bidaya0 Sep 14, 2023
bf67576
feat: add some doc.
Bidaya0 Sep 14, 2023
4976e47
feat: add some doc.
Bidaya0 Sep 15, 2023
10b7967
Merge pull request #1815 from Bidaya0/feat/add_doc
Bidaya0 Sep 15, 2023
a40199a
feat: update new strategy.
Bidaya0 Sep 15, 2023
cd5f1f8
Merge pull request #1816 from Bidaya0/feat/update-new-strategy
Bidaya0 Sep 15, 2023
1904c2d
fix:project_agent_download_token
Bidaya0 Sep 15, 2023
2a5866c
Merge pull request #1817 from Bidaya0/fix/project_agent_download_token
Bidaya0 Sep 15, 2023
8d97700
feat: update new strategy.
Bidaya0 Sep 15, 2023
57b3de4
feat: update new strategy.
Bidaya0 Sep 15, 2023
1e30101
feat: update new strategy.
Bidaya0 Sep 15, 2023
50996f7
feat: update new strategy.
Bidaya0 Sep 15, 2023
b0a5bac
Merge pull request #1818 from Bidaya0/feat/update-new-strategy-
Bidaya0 Sep 15, 2023
5af7bfc
feat: update new strategy.
Bidaya0 Sep 15, 2023
5a22f27
Merge pull request #1819 from Bidaya0/fix/project_agent_download_p2
Bidaya0 Sep 15, 2023
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ celerybeat.pid
*.o
*.c
*.prof
*.dat
7 changes: 6 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pillow = "==9.3.0"
pyrsistent = "==0.19.1"
pytz = "==2022.6"
types-pyyaml = ">=6.0.12.2"
uwsgi = "==2.0.21"
uwsgi = "==2.0.22"
marisa-trie = "==0.8.0"
gunicorn = "==20.1.0"
celery-singleton = "*"
Expand All @@ -89,6 +89,11 @@ networkit = "*"
flower = "~=2.0.0"
django-health-check = "==3.17.0"
django-prometheus = "==2.3.1"
django-add-default-value = "==0.10.0"
networkx = {extras = ["all"], version = "*"}
pandas = "~=2.1.0"
pydot = "*"
more-itertools = "*"

[dev-packages]

Expand Down
428 changes: 215 additions & 213 deletions Pipfile.lock

Large diffs are not rendered by default.

62 changes: 61 additions & 1 deletion deploy/commands/management/commands/load_hook_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
from collections import OrderedDict

from django.core.management.base import BaseCommand
from django.db.models import Q

from dongtai_common.models.hook_strategy import HookStrategy
from dongtai_common.models.hook_type import HookType
from dongtai_common.models.sensitive_info import IastSensitiveInfoRule
from dongtai_common.models.strategy import IastStrategyModel
from dongtai_common.utils.validate import save_hook_stratefile_sha1sum
from dongtai_conf.settings import BASE_DIR
Expand All @@ -23,6 +25,9 @@ def handle(self, *args, **options):
POLICY_DIR = os.path.join(BASE_DIR, "static/data/")
with open(os.path.join(POLICY_DIR, "vul_strategy.json")) as fp:
full_strategies = json.load(fp, object_pairs_hook=OrderedDict)
if os.path.exists(os.path.join(POLICY_DIR, "sensitive_info_strategy.json")):
with open(os.path.exists(os.path.join(POLICY_DIR, "sensitive_info_strategy.json"))) as fp:
full_strategies.extend(json.load(fp, object_pairs_hook=OrderedDict))
strategy_dict = {}
for strategy in full_strategies:
if IastStrategyModel.objects.filter(
Expand Down Expand Up @@ -110,7 +115,6 @@ def handle(self, *args, **options):
hooktype_obj.save()
hooktype_dict[f"{hook_type['value']}-{hook_type['type']}"] = hooktype_obj

HookStrategy.objects.filter(language_id=v, system_type=1).delete()
with open(os.path.join(POLICY_DIR, f"{k.lower()}_full_policy.json")) as fp:
full_policy = json.load(fp, object_pairs_hook=OrderedDict)
for policy in full_policy:
Expand All @@ -119,6 +123,21 @@ def handle(self, *args, **options):
continue
policy_strategy = strategy_dict[policy["value"]]
for hook_strategy in policy["details"]:
if HookStrategy.objects.filter(
value=hook_strategy["value"], type=hook_strategy["type"], language_id=v, system_type=1
).exists():
# 如果已经存在规则,跳过创建
continue
if HookStrategy.objects.filter(
value=hook_strategy["value"], type=hook_strategy["type"], language_id=v, system_type=0
):
# 如果已经存在用户自定义规则,设置为系统规则,跳过创建
hook_strategy_obj = HookStrategy.objects.filter(
value=hook_strategy["value"], type=hook_strategy["type"], language_id=v, system_type=0
).get()
hook_strategy_obj.system_type = 1
hook_strategy_obj.save()
continue
del hook_strategy["language"]
hook_strategy["language_id"] = v
HookStrategy.objects.create(strategy=policy_strategy, **hook_strategy)
Expand All @@ -127,8 +146,49 @@ def handle(self, *args, **options):
continue
policy_hook_type = hooktype_dict[f"{policy['value']}-{policy['type']}"]
for hook_strategy in policy["details"]:
if HookStrategy.objects.filter(
value=hook_strategy["value"], type=hook_strategy["type"], language_id=v, system_type=1
).exists():
# 如果已经存在规则,跳过创建
continue
if HookStrategy.objects.filter(
value=hook_strategy["value"], type=hook_strategy["type"], language_id=v, system_type=0
):
# 如果已经存在用户自定义规则,设置为系统规则,跳过创建
hook_strategy_obj = HookStrategy.objects.filter(
value=hook_strategy["value"], type=hook_strategy["type"], language_id=v, system_type=0
).get()
hook_strategy_obj.system_type = 1
hook_strategy_obj.save()
continue
del hook_strategy["language"]
hook_strategy["language_id"] = v
HookStrategy.objects.create(hooktype=policy_hook_type, **hook_strategy)
save_hook_stratefile_sha1sum()

sensitive_info_rule = []
if os.path.exists(os.path.join(POLICY_DIR, "sensitive_info_rule.json")):
with open(os.path.join(POLICY_DIR, "sensitive_info_rule.json")) as fp:
sensitive_info_rule = json.load(fp, object_pairs_hook=OrderedDict)
sensitive_info_rule_ids = []
for rule in sensitive_info_rule:
if rule["strategy"] not in strategy_dict:
continue
strategy = strategy_dict[rule["strategy"]]
exist_rule = IastSensitiveInfoRule.objects.filter(
strategy=strategy, pattern_type_id=rule["pattern_type"], pattern=rule["pattern"], system_type=1
).first()
if exist_rule:
sensitive_info_rule_ids.append(exist_rule.pk)
else:
obj = IastSensitiveInfoRule.objects.create(
user_id=1,
strategy=strategy,
pattern_type_id=rule["pattern_type"],
pattern=rule["pattern"],
status=1,
system_type=1,
)
sensitive_info_rule_ids.append(obj.pk)
IastSensitiveInfoRule.objects.filter(~Q(id__in=sensitive_info_rule_ids), system_type=1).delete()
self.stdout.write(self.style.SUCCESS("Successfully load strategy ."))
16 changes: 16 additions & 0 deletions deploy/commands/management/commands/unlock_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.core.management.base import BaseCommand

from dongtai_common.models.user import User


class Command(BaseCommand):
help = "scripts to unlock user"
functions = []

def add_arguments(self, parser):
parser.add_argument("id", nargs="*", default=[], type=int)

def handle(self, *args, **options):
users = User.objects.filter(pk__in=options["id"]).all() if options["id"] else User.objects.all()
users.update(failed_login_count=0)
self.stdout.write(self.style.SUCCESS("Successfully Unlock Users"))
15 changes: 13 additions & 2 deletions deploy/kubernetes/helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ initContainers:

{{- define "deploy.initContainers" -}}
initContainers:
- image: {{ .Values.images }}/dongtai-logrotate:{{ .Values.tag }}
- image: {{ .Values.images }}/dongtai-server:{{ .Values.tag }}
command:
- sh
- -c
Expand Down Expand Up @@ -247,7 +247,7 @@ Create the name of the service account to use

[security]
csrf_trust_origins ={{.Values.csrfTrustOrigins}}
secret_key ={{.Values.secretKey}}
secret_key ={{ randAlphaNum 50 }}

[smtp]
server ={{.Values.smtp.server}}
Expand Down Expand Up @@ -345,6 +345,17 @@ Create the name of the service account to use
location /log/ {
proxy_pass http://dongtai-logstash-svc:8082/;
}
{{- if .Values.max }}
location /dongtai_doc/ {
proxy_pass http://dongtai-doc-svc/;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header X-Host $http_x_forwarded_host;
}
{{- end }}
location = /50x.html {
root /usr/share/nginx/html;
}
Expand Down
43 changes: 43 additions & 0 deletions deploy/kubernetes/helm/templates/deployments/dongtai-doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{{- if .Values.max }}
---
# dongtai-doc服务
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "dongtai.fullname" . }}-doc
namespace: {{.Release.Namespace}}
annotations:
kubesphere.io/description: {{ template "dongtai.fullname" . }}-doc
labels:
app: {{ template "dongtai.fullname" . }}-doc
{{- include "dongtai.labels" . | nindent 4 }}
spec:
replicas: {{.Values.replicaCount}}
selector:
matchLabels:
app: {{ template "dongtai.fullname" . }}-doc
{{- include "dongtai.labels" . | nindent 6 }}
template:
metadata:
annotations:
doc_number: {{.Values.build.server_number}}
labels:
app: {{ template "dongtai.fullname" . }}-doc
{{- include "dongtai.labels" . | nindent 8 }}
spec:
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
containers:
- name: {{ template "dongtai.fullname" . }}-doc-container
image: {{ .Values.images }}/dongtai-doc:{{ .Values.tag }}
imagePullPolicy: Always
resources:
limits:
cpu: 500m
memory: 500Mi
requests:
cpu: 500m
memory: 500Mi
{{- end }}
38 changes: 38 additions & 0 deletions deploy/kubernetes/helm/templates/job/dongtai_update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- if .Values.migrate }}
---
# dongtai-update服务
apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "dongtai.fullname" . }}-update-{{ randNumeric 10 }}
namespace: {{.Release.Namespace}}
annotations:
{{- if not .Values.develop.dev }}
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
{{- end }}
"helm.sh/hook": pre-upgrade
"helm.sh/hook-weight": "-5"
kubesphere.io/description: {{ template "dongtai.fullname" . }}-update
labels:
app: {{ template "dongtai.fullname" . }}-update
{{- include "dongtai.labels" . | nindent 4 }}
spec:
template:
metadata:
labels:
app: {{ template "dongtai.fullname" . }}-update
{{- include "dongtai.labels" . | nindent 8 }}
spec:
restartPolicy: Never
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
containers:
- name: {{ template "dongtai.fullname" . }}-update-container
image: {{ .Values.images }}/dongtai-server:{{ .Values.tag }}
command: [ "/bin/sh","/opt/dongtai/deploy/docker/entrypoint.sh" ]
args: [ "migrate" ]
{{- include "deploy.config" . | nindent 10 }}
{{- include "deploy.config.vo" . | nindent 6 }}
{{- end }}
17 changes: 17 additions & 0 deletions deploy/kubernetes/helm/templates/service/dongtai-doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{{- if .Values.max }}
---
apiVersion: v1
kind: Service
metadata:
name: dongtai-doc-svc
namespace: {{.Release.Namespace}}
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
app: {{ template "dongtai.fullname" . }}-doc
type: ClusterIP
{{- end }}
2 changes: 1 addition & 1 deletion deploy/kubernetes/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ logging_level: INFO # DEBUG, INFO
somaxconn: null #If system max net.core.somaxconn (128) . Example: somaxconn: 4096
healthcheck: true
logstash: "true"
migrate: true

nodeSelector:
kubernetes.io/os: linux
Expand Down Expand Up @@ -54,7 +55,6 @@ storage:
persistentVolumeClaim: iast-agent-pvc # or null(The agent needs to close the reporting log function 'dongtai.log.disable-collector: false')

csrfTrustOrigins: .example.com
secretKey: vbjlvbxfvazjfprywuxgyclmvhtmselddsefxxlcixovmqfpgy

smtp:
server: smtp_server
Expand Down
35 changes: 35 additions & 0 deletions dongtai_common/common/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,38 @@ def authenticate(self, request):
return None
token = auth.lower().replace(self.keyword.lower().encode(), b"", 1).decode()
return self.auth_decodedenticate_credentials(token)


@cached_decorator(random_range=(300, 600), use_celery_update=False)
def get_user_from_project_key(key):
from dongtai_common.models.project import IastProject
from dongtai_common.models.user import User

project = IastProject.objects.get(token=key)
principal = User.objects.filter(pk=project.user_id).first()
user = principal if principal else User.objects.filter(pk=1).first()
user.using_project = project
return user


class ProjectTokenAuthentication(TokenAuthentication):
keyword = "Token PROJECT"
model = None

def auth_decodedenticate_credentials(self, key):
from rest_framework import exceptions

from dongtai_common.models.project import IastProject

try:
user = get_user_from_project_key(key)
except IastProject.DoesNotExist as e:
raise exceptions.AuthenticationFailed(_("Invalid token.")) from e
return (user, key)

def authenticate(self, request):
auth = get_authorization_header(request)
if not auth or not auth.lower().startswith(self.keyword.lower().encode()):
return None
token = auth[13:].decode()
return self.auth_decodedenticate_credentials(token)
Loading
Loading