From f9c9c9d525247b7bd2a64b91138840bb5879a057 Mon Sep 17 00:00:00 2001 From: Aaron3S Date: Mon, 31 Jul 2023 19:33:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=A6=81=E6=AD=A2=E4=B8=80=E4=BA=9B=20a?= =?UTF-8?q?nsible=20=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/models/playbook.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/ops/models/playbook.py b/apps/ops/models/playbook.py index 82491480b..2d3c1f409 100644 --- a/apps/ops/models/playbook.py +++ b/apps/ops/models/playbook.py @@ -11,10 +11,15 @@ from ops.exception import PlaybookNoValidEntry from orgs.mixins.models import JMSOrgBaseModel dangerous_keywords = ( + 'hosts:localhost', + 'hosts:127.0.0.1', + 'hosts:::1', 'delegate_to:localhost', 'delegate_to:127.0.0.1', + 'delegate_to:::1', 'local_action', 'connection:local', + 'ansible_connection' ) @@ -48,7 +53,14 @@ class Playbook(JMSOrgBaseModel): with open(file, 'r') as f: for line_num, line in enumerate(f): for keyword in dangerous_keywords: - if keyword in line.replace(' ', ''): + clear_line = line.replace(' ', '')\ + .replace('\n', '')\ + .replace('\r', '')\ + .replace('\t', '') \ + .replace('\'', '') \ + .replace('\"', '')\ + .replace('\v', '') + if keyword in clear_line: result.append((line_num, keyword)) return result