Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
70fa43ad
J
jumpserver
项目概览
gjl2004yn
/
jumpserver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jumpserver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
70fa43ad
编写于
10月 10, 2018
作者:
baltery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Update] 修改一些逻辑
上级
44bf01d4
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
47 addition
and
15 deletion
+47
-15
apps/assets/forms/cmd_filter.py
apps/assets/forms/cmd_filter.py
+7
-0
apps/assets/models/cmd_filter.py
apps/assets/models/cmd_filter.py
+6
-4
apps/assets/models/node.py
apps/assets/models/node.py
+4
-6
apps/assets/models/user.py
apps/assets/models/user.py
+1
-1
apps/assets/templates/assets/cmd_filter_list.html
apps/assets/templates/assets/cmd_filter_list.html
+1
-1
apps/assets/templates/assets/cmd_filter_rule_create_update.html
...ssets/templates/assets/cmd_filter_rule_create_update.html
+17
-0
apps/assets/templates/assets/system_user_asset.html
apps/assets/templates/assets/system_user_asset.html
+2
-1
apps/assets/views/system_user.py
apps/assets/views/system_user.py
+2
-1
apps/common/templatetags/common_tags.py
apps/common/templatetags/common_tags.py
+6
-0
apps/locale/zh/LC_MESSAGES/django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
apps/locale/zh/LC_MESSAGES/django.po
apps/locale/zh/LC_MESSAGES/django.po
+1
-1
未找到文件。
apps/assets/forms/cmd_filter.py
浏览文件 @
70fa43ad
# -*- coding: utf-8 -*-
#
from
django
import
forms
from
orgs.mixins
import
OrgModelForm
from
..models
import
CommandFilter
,
CommandFilterRule
...
...
@@ -18,3 +20,8 @@ class CommandFilterRuleForm(OrgModelForm):
fields
=
[
'filter'
,
'type'
,
'content'
,
'priority'
,
'action'
,
'comment'
]
widgets
=
{
'content'
:
forms
.
Textarea
(
attrs
=
{
'placeholder'
:
'eg:
\r\n
reboot
\r\n
rm -rf'
}),
}
apps/assets/models/cmd_filter.py
浏览文件 @
70fa43ad
...
...
@@ -35,11 +35,10 @@ class CommandFilterRule(OrgModelMixin):
(
TYPE_COMMAND
,
_
(
'Command'
)),
)
ACTION_DENY
=
'deny'
ACTION_ACCEPT
=
'accept'
ACTION_DENY
,
ACTION_ALLOW
=
range
(
2
)
ACTION_CHOICES
=
(
(
ACTION_DENY
,
_
(
'Deny'
)),
(
ACTION_A
CCEPT
,
_
(
'Accept'
))
(
ACTION_A
LLOW
,
_
(
'Allow'
)),
)
id
=
models
.
UUIDField
(
default
=
uuid
.
uuid4
,
primary_key
=
True
)
...
...
@@ -47,11 +46,14 @@ class CommandFilterRule(OrgModelMixin):
type
=
models
.
CharField
(
max_length
=
16
,
default
=
TYPE_COMMAND
,
choices
=
TYPE_CHOICES
,
verbose_name
=
_
(
"Type"
))
priority
=
models
.
IntegerField
(
default
=
50
,
verbose_name
=
_
(
"Priority"
),
validators
=
[
MinValueValidator
(
1
),
MaxValueValidator
(
100
)])
content
=
models
.
TextField
(
max_length
=
1024
,
verbose_name
=
_
(
"Content"
),
help_text
=
_
(
"One line one command"
))
action
=
models
.
CharField
(
max_length
=
16
,
default
=
ACTION_DENY
,
choices
=
ACTION_CHOICES
,
verbose_name
=
_
(
"Action"
))
action
=
models
.
IntegerField
(
default
=
ACTION_DENY
,
choices
=
ACTION_CHOICES
,
verbose_name
=
_
(
"Action"
))
comment
=
models
.
CharField
(
max_length
=
64
,
blank
=
True
,
default
=
''
,
verbose_name
=
_
(
"Comment"
))
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
date_updated
=
models
.
DateTimeField
(
auto_now
=
True
)
created_by
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
default
=
''
,
verbose_name
=
_
(
'Created by'
))
class
Meta
:
ordering
=
(
'priority'
,
'action'
)
def
__str__
(
self
):
return
'{} % {}'
.
format
(
self
.
type
,
self
.
content
)
apps/assets/models/node.py
浏览文件 @
70fa43ad
...
...
@@ -38,12 +38,10 @@ class Node(OrgModelMixin):
return
True
self_key
=
[
int
(
k
)
for
k
in
self
.
key
.
split
(
':'
)]
other_key
=
[
int
(
k
)
for
k
in
other
.
key
.
split
(
':'
)]
if
len
(
self_key
)
<
len
(
other_key
):
return
True
elif
len
(
self_key
)
>
len
(
other_key
):
return
False
else
:
return
self_key
[
-
1
]
<
other_key
[
-
1
]
return
self_key
.
__lt__
(
other_key
)
def
__lt__
(
self
,
other
):
return
not
self
.
__gt__
(
other
)
@
property
def
name
(
self
):
...
...
apps/assets/models/user.py
浏览文件 @
70fa43ad
...
...
@@ -117,7 +117,7 @@ class SystemUser(AssetUser):
sudo
=
models
.
TextField
(
default
=
'/bin/whoami'
,
verbose_name
=
_
(
'Sudo'
))
shell
=
models
.
CharField
(
max_length
=
64
,
default
=
'/bin/bash'
,
verbose_name
=
_
(
'Shell'
))
login_mode
=
models
.
CharField
(
choices
=
LOGIN_MODE_CHOICES
,
default
=
AUTO_LOGIN
,
max_length
=
10
,
verbose_name
=
_
(
'Login mode'
))
cmd_filters
=
models
.
ManyToManyField
(
'CommandFilter'
,
related_name
=
'system_users'
,
verbose_name
=
_
(
"Command filter"
))
cmd_filters
=
models
.
ManyToManyField
(
'CommandFilter'
,
related_name
=
'system_users'
,
verbose_name
=
_
(
"Command filter"
)
,
blank
=
True
)
cache_key
=
"__SYSTEM_USER_CACHED_{}"
...
...
apps/assets/templates/assets/cmd_filter_list.html
浏览文件 @
70fa43ad
...
...
@@ -66,7 +66,7 @@ $(document).ready(function(){
var
$data_table
=
$
(
'
#cmd_filter_list_table
'
).
DataTable
();
var
name
=
$
(
this
).
closest
(
"
tr
"
).
find
(
"
:nth-child(2)
"
).
children
(
'
a
'
).
html
();
var
uid
=
$this
.
data
(
'
uid
'
);
var
the_url
=
'
{% url "api-assets:
label
-detail" pk=DEFAULT_PK %}
'
.
replace
(
'
{{ DEFAULT_PK }}
'
,
uid
);
var
the_url
=
'
{% url "api-assets:
cmd-filter
-detail" pk=DEFAULT_PK %}
'
.
replace
(
'
{{ DEFAULT_PK }}
'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
setTimeout
(
function
()
{
$data_table
.
ajax
.
reload
();
...
...
apps/assets/templates/assets/cmd_filter_rule_create_update.html
浏览文件 @
70fa43ad
...
...
@@ -51,7 +51,24 @@
{% block custom_foot_js %}
<script>
var
content_origin_placeholder
=
''
;
var
content_origin_help_text
=
''
;
var
content_ref
=
''
;
var
content_help_ref
=
''
;
$
(
document
).
ready
(
function
(){
content_ref
=
$
(
'
#id_content
'
);
content_help_ref
=
content_ref
.
next
();
content_origin_placeholder
=
content_ref
.
attr
(
'
placeholder
'
);
content_origin_help_text
=
content_help_ref
.
html
();
}).
on
(
'
change
'
,
'
#id_type
'
,
function
()
{
if
(
$
(
'
#id_type :selected
'
).
val
()
===
'
regex
'
)
{
content_ref
.
attr
(
'
placeholder
'
,
'
rm.*|reboot|shutdown
'
);
content_help_ref
.
html
(
""
);
}
else
{
content_ref
.
attr
(
'
placeholder
'
,
content_origin_placeholder
);
content_help_ref
.
html
(
content_origin_help_text
);
}
})
</script>
{% endblock %}
\ No newline at end of file
apps/assets/templates/assets/system_user_asset.html
浏览文件 @
70fa43ad
{% extends 'base.html' %}
{% load common_tags %}
{% load static %}
{% load i18n %}
...
...
@@ -113,7 +114,7 @@
</tr>
</form>
{% for node in system_user.nodes.all %}
{% for node in system_user.nodes.all
|sort
%}
<tr>
<td
><b
class=
"bdg_node"
data-gid=
{{
node.id
}}
>
{{ node }}
</b></td>
<td>
...
...
apps/assets/views/system_user.py
浏览文件 @
70fa43ad
...
...
@@ -91,10 +91,11 @@ class SystemUserAssetView(AdminUserRequiredMixin, DetailView):
context_object_name
=
'system_user'
def
get_context_data
(
self
,
**
kwargs
):
nodes_remain
=
sorted
(
Node
.
objects
.
exclude
(
systemuser
=
self
.
object
),
reverse
=
True
)
context
=
{
'app'
:
_
(
'assets'
),
'action'
:
_
(
'System user asset'
),
'nodes_remain'
:
Node
.
objects
.
exclude
(
systemuser
=
self
.
object
)
'nodes_remain'
:
nodes_remain
}
kwargs
.
update
(
context
)
return
super
().
get_context_data
(
**
kwargs
)
apps/common/templatetags/common_tags.py
浏览文件 @
70fa43ad
...
...
@@ -100,3 +100,9 @@ def is_bool_field(field):
@
register
.
filter
def
to_dict
(
data
):
return
dict
(
data
)
@
register
.
filter
def
sort
(
data
):
print
(
data
)
return
sorted
(
data
)
apps/locale/zh/LC_MESSAGES/django.mo
浏览文件 @
70fa43ad
无法预览此类型文件
apps/locale/zh/LC_MESSAGES/django.po
浏览文件 @
70fa43ad
...
...
@@ -1295,7 +1295,7 @@ msgstr "创建规则"
#: assets/templates/assets/cmd_filter_rule_list.html:61
msgid "Strategy"
msgstr "
分类
"
msgstr "
策略
"
#: assets/templates/assets/delete_confirm.html:6
#: perms/templates/perms/delete_confirm.html:6 templates/delete_confirm.html:6
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录