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

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

parent 34de75cb
......@@ -245,22 +245,31 @@ class BaseServer(object):
return data
if not self._input:
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:
action, cmd = rule.match(self._input)
if action == rule.ALLOW:
break
elif action == rule.DENY:
data = char.CLEAR_LINE_CHAR + b'\r'
msg = _("Command `{}` is forbidden ........").format(cmd)
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()
self.command_forbidden(msg)
break
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):
if not self._zmodem_state:
self.session.put_replay(data)
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: BaiJiangjie <bugatti_it@163.com>\n"
"Language-Team: Language locale/en/LC\n"
......@@ -84,75 +84,80 @@ msgstr ""
msgid "Terminal does not support login rdp, please use web terminal to access"
msgstr ""
#: coco/interactive.py:212
#: coco/interactive.py:217
msgid "No Assets"
msgstr ""
#: coco/interactive.py:275
#: coco/interactive.py:280
msgid "Tips: Enter the asset ID and log directly into the asset."
msgstr ""
#: coco/interactive.py:276
#: coco/interactive.py:281
msgid "Page up: P/p"
msgstr ""
#: coco/interactive.py:277
#: coco/interactive.py:282
msgid "Page down: Enter|N/n"
msgstr ""
#: coco/interactive.py:278
#: coco/interactive.py:283
msgid "BACK: b/q"
msgstr ""
#: coco/interactive.py:299
#: coco/interactive.py:303
msgid "ID"
msgstr ""
#: coco/interactive.py:299
#: coco/interactive.py:303
msgid "Hostname"
msgstr ""
#: coco/interactive.py:299
#: coco/interactive.py:303
msgid "IP"
msgstr ""
#: coco/interactive.py:299
#: coco/interactive.py:303
msgid "LoginAs"
msgstr ""
#: coco/interactive.py:313
#: coco/interactive.py:317
msgid "Comment"
msgstr ""
#: coco/interactive.py:322
#: coco/interactive.py:326
msgid "Page: {}, Count: {}, Total Page: {}, Total Count: {}"
msgstr ""
#: coco/interactive.py:394
#: coco/interactive.py:398
msgid "No Nodes"
msgstr ""
#: coco/interactive.py:398
#: coco/interactive.py:402
msgid "Node: [ ID.Name(Asset amount) ]"
msgstr ""
#: coco/interactive.py:400
#: coco/interactive.py:404
msgid "Tips: Enter g+NodeID to display the host under the node, such as g1"
msgstr ""
#: coco/interactive.py:408
#: coco/interactive.py:412
msgid "There is no matched node, please re-enter"
msgstr ""
#: coco/interactive.py:438
#: coco/interactive.py:442
msgid "Select a login:: "
msgstr ""
#: coco/interactive.py:461
#: coco/interactive.py:465
msgid "No system user"
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 ........"
msgstr ""
......
......@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\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"
"Last-Translator: BaiJiangjie <bugatti_it@163.com>\n"
"Language-Team: Language locale/zh\n"
......@@ -91,75 +91,80 @@ msgstr "{T}0) 输入 {green}q{end} 退出.{R}"
msgid "Terminal does not support login rdp, please use web terminal to access"
msgstr "终端不支持登录windows, 请使用web terminal访问"
#: coco/interactive.py:212
#: coco/interactive.py:217
msgid "No Assets"
msgstr "没有资产"
#: coco/interactive.py:275
#: coco/interactive.py:280
msgid "Tips: Enter the asset ID and log directly into the asset."
msgstr "提示: 输入资产ID,直接登录资产."
#: coco/interactive.py:276
#: coco/interactive.py:281
msgid "Page up: P/p"
msgstr "上一页: P/p"
#: coco/interactive.py:277
#: coco/interactive.py:282
msgid "Page down: Enter|N/n"
msgstr "下一页: Enter|N/n"
#: coco/interactive.py:278
#: coco/interactive.py:283
msgid "BACK: b/q"
msgstr "返回: B/b"
#: coco/interactive.py:299
#: coco/interactive.py:303
msgid "ID"
msgstr ""
#: coco/interactive.py:299
#: coco/interactive.py:303
msgid "Hostname"
msgstr "主机名"
#: coco/interactive.py:299
#: coco/interactive.py:303
msgid "IP"
msgstr ""
#: coco/interactive.py:299
#: coco/interactive.py:303
msgid "LoginAs"
msgstr "登录用户"
#: coco/interactive.py:313
#: coco/interactive.py:317
msgid "Comment"
msgstr "备注"
#: coco/interactive.py:322
#: coco/interactive.py:326
msgid "Page: {}, Count: {}, Total Page: {}, Total Count: {}"
msgstr "页码: {}, 数量: {}, 总页数: {}, 总数量: {}"
#: coco/interactive.py:394
#: coco/interactive.py:398
msgid "No Nodes"
msgstr "没有节点"
#: coco/interactive.py:398
#: coco/interactive.py:402
msgid "Node: [ ID.Name(Asset amount) ]"
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"
msgstr "提示: 输入 g+节点ID 显示节点下主机. 如: g1"
#: coco/interactive.py:408
#: coco/interactive.py:412
msgid "There is no matched node, please re-enter"
msgstr "没有匹配分组,请重新输入"
#: coco/interactive.py:438
#: coco/interactive.py:442
msgid "Select a login:: "
msgstr "选择一个登录:"
#: coco/interactive.py:461
#: coco/interactive.py:465
msgid "No system user"
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 ........"
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