Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
2a5129c4
Commit
2a5129c4
authored
Feb 21, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改支持记录cmd filter日志
parent
202aba04
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
101 additions
and
38 deletions
+101
-38
0025_auto_20190221_1902.py
apps/assets/migrations/0025_auto_20190221_1902.py
+21
-0
cmd_filter.py
apps/assets/models/cmd_filter.py
+4
-0
signals_handler.py
apps/audits/signals_handler.py
+14
-6
views.py
apps/audits/views.py
+5
-2
0005_auto_20190221_1902.py
apps/common/migrations/0005_auto_20190221_1902.py
+17
-0
models.py
apps/common/models.py
+1
-0
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+39
-30
No files found.
apps/assets/migrations/0025_auto_20190221_1902.py
0 → 100644
View file @
2a5129c4
# Generated by Django 2.1.7 on 2019-02-21 11:02
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'assets'
,
'0024_auto_20181219_1614'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'commandfilter'
,
options
=
{
'verbose_name'
:
'Command filter'
},
),
migrations
.
AlterModelOptions
(
name
=
'commandfilterrule'
,
options
=
{
'ordering'
:
(
'-priority'
,
'action'
),
'verbose_name'
:
'Command filter rule'
},
),
]
apps/assets/models/cmd_filter.py
View file @
2a5129c4
...
...
@@ -27,6 +27,9 @@ class CommandFilter(OrgModelMixin):
def
__str__
(
self
):
return
self
.
name
class
Meta
:
verbose_name
=
_
(
"Command filter"
)
class
CommandFilterRule
(
OrgModelMixin
):
TYPE_REGEX
=
'regex'
...
...
@@ -58,6 +61,7 @@ class CommandFilterRule(OrgModelMixin):
class
Meta
:
ordering
=
(
'-priority'
,
'action'
)
verbose_name
=
_
(
"Command filter rule"
)
@property
def
_pattern
(
self
):
...
...
apps/audits/signals_handler.py
View file @
2a5129c4
...
...
@@ -6,14 +6,17 @@ from django.dispatch import receiver
from
django.db
import
transaction
from
jumpserver.utils
import
current_request
from
common.utils
import
get_request_ip
from
common.utils
import
get_request_ip
,
get_logger
from
users.models
import
User
from
.models
import
OperateLog
,
PasswordChangeLog
logger
=
get_logger
(
__name__
)
MODELS_NEED_RECORD
=
(
'User'
,
'UserGroup'
,
'Asset'
,
'Node'
,
'AdminUser'
,
'SystemUser'
,
'Domain'
,
'Gateway'
,
'Organization'
,
'AssetPermission'
,
'Domain'
,
'Gateway'
,
'Organization'
,
'AssetPermission'
,
'CommandFilter'
,
'CommandFilterRule'
,
'License'
,
'Setting'
,
'Account'
,
'SyncInstanceTask'
,
)
...
...
@@ -26,11 +29,16 @@ def create_operate_log(action, sender, resource):
return
resource_type
=
sender
.
_meta
.
verbose_name
remote_addr
=
get_request_ip
(
current_request
)
data
=
{
"user"
:
str
(
user
),
'action'
:
action
,
'resource_type'
:
resource_type
,
'resource'
:
str
(
resource
),
'remote_addr'
:
remote_addr
,
}
with
transaction
.
atomic
():
OperateLog
.
objects
.
create
(
user
=
user
,
action
=
action
,
resource_type
=
resource_type
,
resource
=
resource
,
remote_addr
=
remote_addr
)
try
:
OperateLog
.
objects
.
create
(
**
data
)
except
Exception
as
e
:
logger
.
error
(
"Create operate log error: {}"
.
format
(
e
)
)
@receiver
(
post_save
,
dispatch_uid
=
"my_unique_identifier"
)
...
...
apps/audits/views.py
View file @
2a5129c4
...
...
@@ -14,13 +14,16 @@ from .models import FTPLog, OperateLog, PasswordChangeLog, UserLoginLog
def
get_resource_type_list
():
from
users.models
import
User
,
UserGroup
from
assets.models
import
Asset
,
Node
,
AdminUser
,
SystemUser
,
Domain
,
Gateway
from
assets.models
import
(
Asset
,
Node
,
AdminUser
,
SystemUser
,
Domain
,
Gateway
,
CommandFilter
,
CommandFilterRule
,
)
from
orgs.models
import
Organization
from
perms.models
import
AssetPermission
models
=
[
User
,
UserGroup
,
Asset
,
Node
,
AdminUser
,
SystemUser
,
Domain
,
Gateway
,
Organization
,
AssetPermission
Gateway
,
Organization
,
AssetPermission
,
CommandFilter
,
CommandFilterRule
]
return
[
model
.
_meta
.
verbose_name
for
model
in
models
]
...
...
apps/common/migrations/0005_auto_20190221_1902.py
0 → 100644
View file @
2a5129c4
# Generated by Django 2.1.7 on 2019-02-21 11:02
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'common'
,
'0004_setting_encrypted'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'setting'
,
options
=
{
'verbose_name'
:
'Setting'
},
),
]
apps/common/models.py
View file @
2a5129c4
...
...
@@ -123,3 +123,4 @@ class Setting(models.Model):
class
Meta
:
db_table
=
"settings"
verbose_name
=
_
(
"Setting"
)
apps/locale/zh/LC_MESSAGES/django.mo
View file @
2a5129c4
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
2a5129c4
...
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-02-21 1
5:5
3+0800\n"
"POT-Creation-Date: 2019-02-21 1
9:0
3+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n"
...
...
@@ -233,8 +233,8 @@ msgstr "密码和私钥, 必须输入一个"
msgid "* Automatic login mode must fill in the username."
msgstr "自动登录模式,必须填写用户名"
#: assets/forms/user.py:145 assets/models/
user.py:14
1
#: assets/templates/assets/_system_user.html:66
#: assets/forms/user.py:145 assets/models/
cmd_filter.py:3
1
#: assets/
models/user.py:141 assets/
templates/assets/_system_user.html:66
#: assets/templates/assets/system_user_detail.html:165
msgid "Command filter"
msgstr "命令过滤器"
...
...
@@ -382,7 +382,7 @@ msgstr "标签管理"
#: assets/models/asset.py:109 assets/models/base.py:30
#: assets/models/cluster.py:28 assets/models/cmd_filter.py:25
#: assets/models/cmd_filter.py:5
5
assets/models/group.py:21
#: assets/models/cmd_filter.py:5
8
assets/models/group.py:21
#: assets/templates/assets/admin_user_detail.html:68
#: assets/templates/assets/asset_detail.html:125
#: assets/templates/assets/cmd_filter_detail.html:77
...
...
@@ -415,7 +415,7 @@ msgstr "创建日期"
#: assets/models/asset.py:111 assets/models/base.py:27
#: assets/models/cluster.py:29 assets/models/cmd_filter.py:22
#: assets/models/cmd_filter.py:5
2
assets/models/domain.py:21
#: assets/models/cmd_filter.py:5
5
assets/models/domain.py:21
#: assets/models/domain.py:53 assets/models/group.py:23
#: assets/models/label.py:23 assets/templates/assets/admin_user_detail.html:72
#: assets/templates/assets/admin_user_list.html:32
...
...
@@ -533,11 +533,11 @@ msgstr "北京电信"
msgid "BGP full netcom"
msgstr "BGP全网通"
#: assets/models/cmd_filter.py:3
5
#: assets/models/cmd_filter.py:3
8
msgid "Regex"
msgstr "正则表达式"
#: assets/models/cmd_filter.py:3
6
ops/models/command.py:21
#: assets/models/cmd_filter.py:3
9
ops/models/command.py:21
#: ops/templates/ops/command_execution_list.html:60 terminal/models.py:161
#: terminal/templates/terminal/command_list.html:55
#: terminal/templates/terminal/command_list.html:71
...
...
@@ -546,19 +546,19 @@ msgstr "正则表达式"
msgid "Command"
msgstr "命令"
#: assets/models/cmd_filter.py:4
1
#: assets/models/cmd_filter.py:4
4
msgid "Deny"
msgstr "拒绝"
#: assets/models/cmd_filter.py:4
2
#: assets/models/cmd_filter.py:4
5
msgid "Allow"
msgstr "允许"
#: assets/models/cmd_filter.py:4
6
#: assets/models/cmd_filter.py:4
9
msgid "Filter"
msgstr "过滤器"
#: assets/models/cmd_filter.py:
47
#: assets/models/cmd_filter.py:
50
#: assets/templates/assets/cmd_filter_rule_list.html:58
#: audits/templates/audits/login_log_list.html:50
#: common/templates/common/command_storage_create.html:31
...
...
@@ -568,26 +568,26 @@ msgstr "过滤器"
msgid "Type"
msgstr "类型"
#: assets/models/cmd_filter.py:
48
assets/models/user.py:135
#: assets/models/cmd_filter.py:
51
assets/models/user.py:135
#: assets/templates/assets/cmd_filter_rule_list.html:60
msgid "Priority"
msgstr "优先级"
#: assets/models/cmd_filter.py:
48
#: assets/models/cmd_filter.py:
51
msgid "1-100, the higher will be match first"
msgstr "优先级可选范围为1-100,1最低优先级,100最高优先级"
#: assets/models/cmd_filter.py:5
0
#: assets/models/cmd_filter.py:5
3
#: assets/templates/assets/cmd_filter_rule_list.html:59
#: xpack/plugins/license/models.py:27
msgid "Content"
msgstr "内容"
#: assets/models/cmd_filter.py:5
0
#: assets/models/cmd_filter.py:5
3
msgid "One line one command"
msgstr "每行一个命令"
#: assets/models/cmd_filter.py:5
1
#: assets/models/cmd_filter.py:5
4
#: assets/templates/assets/admin_user_assets.html:52
#: assets/templates/assets/admin_user_list.html:33
#: assets/templates/assets/asset_list.html:96
...
...
@@ -615,6 +615,10 @@ msgstr "每行一个命令"
msgid "Action"
msgstr "动作"
#: assets/models/cmd_filter.py:64
msgid "Command filter rule"
msgstr "命令过滤规则"
#: assets/models/domain.py:61 assets/templates/assets/domain_detail.html:21
#: assets/templates/assets/domain_detail.html:64
#: assets/templates/assets/domain_gateway_list.html:21
...
...
@@ -1790,28 +1794,28 @@ msgstr "日期"
msgid "Datetime"
msgstr "日期"
#: audits/views.py:
68 audits/views.py:112 audits/views.py:148
#: audits/views.py:19
2 audits/views.py:223
templates/_nav.html:72
#: audits/views.py:
71 audits/views.py:115 audits/views.py:151
#: audits/views.py:19
5 audits/views.py:226
templates/_nav.html:72
msgid "Audits"
msgstr "日志审计"
#: audits/views.py:
69
templates/_nav.html:76
#: audits/views.py:
72
templates/_nav.html:76
msgid "FTP log"
msgstr "FTP日志"
#: audits/views.py:11
3
templates/_nav.html:77
#: audits/views.py:11
6
templates/_nav.html:77
msgid "Operate log"
msgstr "操作日志"
#: audits/views.py:1
49
templates/_nav.html:78
#: audits/views.py:1
52
templates/_nav.html:78
msgid "Password change log"
msgstr "改密日志"
#: audits/views.py:19
3
templates/_nav.html:75
#: audits/views.py:19
6
templates/_nav.html:75
msgid "Login log"
msgstr "登录日志"
#: audits/views.py:22
4
ops/views/command.py:44
#: audits/views.py:22
7
ops/views/command.py:44
msgid "Command execution list"
msgstr "命令执行列表"
...
...
@@ -2123,6 +2127,11 @@ msgstr ""
msgid "Enabled"
msgstr "启用"
#: common/models.py:126 users/templates/users/reset_password.html:68
#: users/templates/users/user_profile.html:20
msgid "Setting"
msgstr "设置"
#: common/templates/common/basic_setting.html:15
#: common/templates/common/email_setting.html:15
#: common/templates/common/ldap_setting.html:15
...
...
@@ -3659,7 +3668,7 @@ msgstr "安全令牌验证"
#: users/templates/users/_base_otp.html:44 users/templates/users/_user.html:13
#: users/templates/users/user_profile_update.html:51
#: xpack/plugins/cloud/models.py:
60 xpack/plugins/cloud/models.py:
120
#: xpack/plugins/cloud/models.py:120
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_detail.html:59
#: xpack/plugins/cloud/templates/cloud/sync_instance_task_list.html:13
msgid "Account"
...
...
@@ -3881,11 +3890,6 @@ msgstr "密码强度:"
msgid "Password again"
msgstr "再次输入密码"
#: users/templates/users/reset_password.html:68
#: users/templates/users/user_profile.html:20
msgid "Setting"
msgstr "设置"
#: users/templates/users/reset_password.html:105
#: users/templates/users/user_password_update.html:99
#: users/templates/users/user_update.html:46
...
...
@@ -4552,6 +4556,10 @@ msgstr ""
msgid "Access key secret"
msgstr ""
#: xpack/plugins/cloud/models.py:60
msgid "Cloud account"
msgstr "云账号"
#: xpack/plugins/cloud/models.py:121
msgid "Regions"
msgstr "地域"
...
...
@@ -4762,7 +4770,8 @@ msgstr "界面设置"
msgid "Interface"
msgstr "界面"
#: xpack/plugins/license/meta.py:11 xpack/plugins/license/views.py:27
#: xpack/plugins/license/meta.py:11 xpack/plugins/license/models.py:71
#: xpack/plugins/license/views.py:27
msgid "License"
msgstr "许可证"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment