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
ce530e41
Commit
ce530e41
authored
Oct 09, 2019
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改cmd filter rules pattern
parent
e5217881
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
+19
-13
cmd_filter.py
apps/assets/models/cmd_filter.py
+17
-11
command_execution_create.html
apps/ops/templates/ops/command_execution_create.html
+2
-2
No files found.
apps/assets/models/cmd_filter.py
View file @
ce530e41
...
...
@@ -7,6 +7,7 @@ from django.db import models
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
django.utils.translation
import
ugettext_lazy
as
_
from
common.utils
import
lazyproperty
from
orgs.mixins.models
import
OrgModelMixin
...
...
@@ -57,25 +58,30 @@ class CommandFilterRule(OrgModelMixin):
date_updated
=
models
.
DateTimeField
(
auto_now
=
True
)
created_by
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
default
=
''
,
verbose_name
=
_
(
'Created by'
))
__pattern
=
None
class
Meta
:
ordering
=
(
'-priority'
,
'action'
)
verbose_name
=
_
(
"Command filter rule"
)
@property
@
lazy
property
def
_pattern
(
self
):
if
self
.
__pattern
:
return
self
.
__pattern
if
self
.
type
==
'command'
:
regex
=
[]
for
cmd
in
self
.
content
.
split
(
'
\r\n
'
):
cmd
=
cmd
.
replace
(
' '
,
'
\
s+'
)
regex
.
append
(
r'\b{0}\b'
.
format
(
cmd
))
self
.
__pattern
=
re
.
compile
(
r'{}'
.
format
(
'|'
.
join
(
regex
)))
content
=
self
.
content
.
replace
(
'
\r\n
'
,
'
\n
'
)
for
cmd
in
content
.
split
(
'
\n
'
):
cmd
=
re
.
escape
(
cmd
)
cmd
=
cmd
.
replace
(
'
\\
'
,
'
\
s+'
)
if
cmd
[
-
1
]
.
isalpha
():
regex
.
append
(
r'\b{0}\b'
.
format
(
cmd
))
else
:
regex
.
append
(
r'\b{0}'
.
format
(
cmd
))
s
=
r'{}'
.
format
(
'|'
.
join
(
regex
))
else
:
self
.
__pattern
=
re
.
compile
(
r'{0}'
.
format
(
self
.
content
))
return
self
.
__pattern
s
=
r'{0}'
.
format
(
self
.
content
)
try
:
_pattern
=
re
.
compile
(
s
)
except
:
_pattern
=
''
return
_pattern
def
match
(
self
,
data
):
found
=
self
.
_pattern
.
search
(
data
)
...
...
apps/ops/templates/ops/command_execution_create.html
View file @
ce530e41
...
...
@@ -140,6 +140,7 @@
}
function
initTree
()
{
$
(
'#assetTree'
).
html
(
"{% trans 'Loading' %}"
+
'..'
);
if
(
systemUserId
)
{
url
=
treeUrl
+
'&system_user='
+
systemUserId
}
else
{
...
...
@@ -365,4 +366,4 @@
execute
()
})
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
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