Commit e3e031ec authored by BaiJiangJie's avatar BaiJiangJie Committed by 老广

[Bugfix] 修复加载命令过滤规则为None时的Bug,添加处理逻辑 (#148)

parent 34de75cb
...@@ -245,22 +245,31 @@ class BaseServer(object): ...@@ -245,22 +245,31 @@ class BaseServer(object):
return data return data
if not self._input: if not self._input:
return data return data
if self._cmd_filter_rules is None:
msg = _("Warning: Failed to load filter rule, "
"please press Ctrl + D to exit retry.")
data = self.command_forbidden(msg)
return data
for rule in self._cmd_filter_rules: for rule in self._cmd_filter_rules:
action, cmd = rule.match(self._input) action, cmd = rule.match(self._input)
if action == rule.ALLOW: if action == rule.ALLOW:
break break
elif action == rule.DENY: elif action == rule.DENY:
data = char.CLEAR_LINE_CHAR + b'\r'
msg = _("Command `{}` is forbidden ........").format(cmd) msg = _("Command `{}` is forbidden ........").format(cmd)
msg = wr(warning(msg.encode()), before=1, after=1) self.command_forbidden(msg)
self.output_data.append(msg)
self.session.send_to_clients(msg)
self.session.put_command(self._input, msg.decode())
self.session.put_replay(msg)
self.input_data.clean()
break break
return data return data
def command_forbidden(self, msg):
data = char.CLEAR_LINE_CHAR + b'\r'
msg = wr(warning(msg.encode()), before=1, after=1)
self.output_data.append(msg)
self.session.send_to_clients(msg)
self.session.put_command(self._input, msg.decode())
self.session.put_replay(msg)
self.input_data.clean()
return data
def r_replay_filter(self, data): def r_replay_filter(self, data):
if not self._zmodem_state: if not self._zmodem_state:
self.session.put_replay(data) self.session.put_replay(data)
......
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-12-18 20:03+0800\n" "POT-Creation-Date: 2018-12-21 16:48+0800\n"
"PO-Revision-Date: 2018-08-10 10:42+0800\n" "PO-Revision-Date: 2018-08-10 10:42+0800\n"
"Last-Translator: BaiJiangjie <bugatti_it@163.com>\n" "Last-Translator: BaiJiangjie <bugatti_it@163.com>\n"
"Language-Team: Language locale/en/LC\n" "Language-Team: Language locale/en/LC\n"
...@@ -84,75 +84,80 @@ msgstr "" ...@@ -84,75 +84,80 @@ msgstr ""
msgid "Terminal does not support login rdp, please use web terminal to access" msgid "Terminal does not support login rdp, please use web terminal to access"
msgstr "" msgstr ""
#: coco/interactive.py:212 #: coco/interactive.py:217
msgid "No Assets" msgid "No Assets"
msgstr "" msgstr ""
#: coco/interactive.py:275 #: coco/interactive.py:280
msgid "Tips: Enter the asset ID and log directly into the asset." msgid "Tips: Enter the asset ID and log directly into the asset."
msgstr "" msgstr ""
#: coco/interactive.py:276 #: coco/interactive.py:281
msgid "Page up: P/p" msgid "Page up: P/p"
msgstr "" msgstr ""
#: coco/interactive.py:277 #: coco/interactive.py:282
msgid "Page down: Enter|N/n" msgid "Page down: Enter|N/n"
msgstr "" msgstr ""
#: coco/interactive.py:278 #: coco/interactive.py:283
msgid "BACK: b/q" msgid "BACK: b/q"
msgstr "" msgstr ""
#: coco/interactive.py:299 #: coco/interactive.py:303
msgid "ID" msgid "ID"
msgstr "" msgstr ""
#: coco/interactive.py:299 #: coco/interactive.py:303
msgid "Hostname" msgid "Hostname"
msgstr "" msgstr ""
#: coco/interactive.py:299 #: coco/interactive.py:303
msgid "IP" msgid "IP"
msgstr "" msgstr ""
#: coco/interactive.py:299 #: coco/interactive.py:303
msgid "LoginAs" msgid "LoginAs"
msgstr "" msgstr ""
#: coco/interactive.py:313 #: coco/interactive.py:317
msgid "Comment" msgid "Comment"
msgstr "" msgstr ""
#: coco/interactive.py:322 #: coco/interactive.py:326
msgid "Page: {}, Count: {}, Total Page: {}, Total Count: {}" msgid "Page: {}, Count: {}, Total Page: {}, Total Count: {}"
msgstr "" msgstr ""
#: coco/interactive.py:394 #: coco/interactive.py:398
msgid "No Nodes" msgid "No Nodes"
msgstr "" msgstr ""
#: coco/interactive.py:398 #: coco/interactive.py:402
msgid "Node: [ ID.Name(Asset amount) ]" msgid "Node: [ ID.Name(Asset amount) ]"
msgstr "" msgstr ""
#: coco/interactive.py:400 #: coco/interactive.py:404
msgid "Tips: Enter g+NodeID to display the host under the node, such as g1" msgid "Tips: Enter g+NodeID to display the host under the node, such as g1"
msgstr "" msgstr ""
#: coco/interactive.py:408 #: coco/interactive.py:412
msgid "There is no matched node, please re-enter" msgid "There is no matched node, please re-enter"
msgstr "" msgstr ""
#: coco/interactive.py:438 #: coco/interactive.py:442
msgid "Select a login:: " msgid "Select a login:: "
msgstr "" msgstr ""
#: coco/interactive.py:461 #: coco/interactive.py:465
msgid "No system user" msgid "No system user"
msgstr "" msgstr ""
#: coco/models.py:247 #: coco/models.py:242
msgid ""
"Warning: Failed to load filter rule, please press Ctrl + D to exit retry."
msgstr ""
#: coco/models.py:251
msgid "Command `{}` is forbidden ........" msgid "Command `{}` is forbidden ........"
msgstr "" msgstr ""
......
...@@ -7,7 +7,7 @@ msgid "" ...@@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-12-18 20:04+0800\n" "POT-Creation-Date: 2018-12-21 16:48+0800\n"
"PO-Revision-Date: 2018-08-10 10:42+0800\n" "PO-Revision-Date: 2018-08-10 10:42+0800\n"
"Last-Translator: BaiJiangjie <bugatti_it@163.com>\n" "Last-Translator: BaiJiangjie <bugatti_it@163.com>\n"
"Language-Team: Language locale/zh\n" "Language-Team: Language locale/zh\n"
...@@ -91,75 +91,80 @@ msgstr "{T}0) 输入 {green}q{end} 退出.{R}" ...@@ -91,75 +91,80 @@ msgstr "{T}0) 输入 {green}q{end} 退出.{R}"
msgid "Terminal does not support login rdp, please use web terminal to access" msgid "Terminal does not support login rdp, please use web terminal to access"
msgstr "终端不支持登录windows, 请使用web terminal访问" msgstr "终端不支持登录windows, 请使用web terminal访问"
#: coco/interactive.py:212 #: coco/interactive.py:217
msgid "No Assets" msgid "No Assets"
msgstr "没有资产" msgstr "没有资产"
#: coco/interactive.py:275 #: coco/interactive.py:280
msgid "Tips: Enter the asset ID and log directly into the asset." msgid "Tips: Enter the asset ID and log directly into the asset."
msgstr "提示: 输入资产ID,直接登录资产." msgstr "提示: 输入资产ID,直接登录资产."
#: coco/interactive.py:276 #: coco/interactive.py:281
msgid "Page up: P/p" msgid "Page up: P/p"
msgstr "上一页: P/p" msgstr "上一页: P/p"
#: coco/interactive.py:277 #: coco/interactive.py:282
msgid "Page down: Enter|N/n" msgid "Page down: Enter|N/n"
msgstr "下一页: Enter|N/n" msgstr "下一页: Enter|N/n"
#: coco/interactive.py:278 #: coco/interactive.py:283
msgid "BACK: b/q" msgid "BACK: b/q"
msgstr "返回: B/b" msgstr "返回: B/b"
#: coco/interactive.py:299 #: coco/interactive.py:303
msgid "ID" msgid "ID"
msgstr "" msgstr ""
#: coco/interactive.py:299 #: coco/interactive.py:303
msgid "Hostname" msgid "Hostname"
msgstr "主机名" msgstr "主机名"
#: coco/interactive.py:299 #: coco/interactive.py:303
msgid "IP" msgid "IP"
msgstr "" msgstr ""
#: coco/interactive.py:299 #: coco/interactive.py:303
msgid "LoginAs" msgid "LoginAs"
msgstr "登录用户" msgstr "登录用户"
#: coco/interactive.py:313 #: coco/interactive.py:317
msgid "Comment" msgid "Comment"
msgstr "备注" msgstr "备注"
#: coco/interactive.py:322 #: coco/interactive.py:326
msgid "Page: {}, Count: {}, Total Page: {}, Total Count: {}" msgid "Page: {}, Count: {}, Total Page: {}, Total Count: {}"
msgstr "页码: {}, 数量: {}, 总页数: {}, 总数量: {}" msgstr "页码: {}, 数量: {}, 总页数: {}, 总数量: {}"
#: coco/interactive.py:394 #: coco/interactive.py:398
msgid "No Nodes" msgid "No Nodes"
msgstr "没有节点" msgstr "没有节点"
#: coco/interactive.py:398 #: coco/interactive.py:402
msgid "Node: [ ID.Name(Asset amount) ]" msgid "Node: [ ID.Name(Asset amount) ]"
msgstr "节点: [ ID.名称(资产数量) ]" msgstr "节点: [ ID.名称(资产数量) ]"
#: coco/interactive.py:400 #: coco/interactive.py:404
msgid "Tips: Enter g+NodeID to display the host under the node, such as g1" msgid "Tips: Enter g+NodeID to display the host under the node, such as g1"
msgstr "提示: 输入 g+节点ID 显示节点下主机. 如: g1" msgstr "提示: 输入 g+节点ID 显示节点下主机. 如: g1"
#: coco/interactive.py:408 #: coco/interactive.py:412
msgid "There is no matched node, please re-enter" msgid "There is no matched node, please re-enter"
msgstr "没有匹配分组,请重新输入" msgstr "没有匹配分组,请重新输入"
#: coco/interactive.py:438 #: coco/interactive.py:442
msgid "Select a login:: " msgid "Select a login:: "
msgstr "选择一个登录:" msgstr "选择一个登录:"
#: coco/interactive.py:461 #: coco/interactive.py:465
msgid "No system user" msgid "No system user"
msgstr "没有系统用户" msgstr "没有系统用户"
#: coco/models.py:247 #: coco/models.py:242
msgid ""
"Warning: Failed to load filter rule, please press Ctrl + D to exit retry."
msgstr "警告: 加载过滤规则失败,请按 Ctrl + D 退出重试."
#: coco/models.py:251
msgid "Command `{}` is forbidden ........" msgid "Command `{}` is forbidden ........"
msgstr "命令 `{}` 是被禁止的 ..." msgstr "命令 `{}` 是被禁止的 ..."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment