Michael Pasternak has uploaded a new change for review.

Change subject: cli: do not log /connect command in history
......................................................................

cli: do not log /connect command in history

Change-Id: Ieb983ecec4ae30fbae2411f0bf2eaef194e96f21
Signed-off-by: Michael Pasternak <mpast...@redhat.com>
---
M src/ovirtcli/command/connect.py
M src/ovirtcli/historymanager.py
2 files changed, 13 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/54/8054/1

diff --git a/src/ovirtcli/command/connect.py b/src/ovirtcli/command/connect.py
index 49784b2..3cfcfce 100644
--- a/src/ovirtcli/command/connect.py
+++ b/src/ovirtcli/command/connect.py
@@ -110,6 +110,10 @@
             self.context.settings.get('ovirt-shell:version'))
             self.context.history.enable()
 
+            #do not log connect command details as it may be
+            #a subject for password stealing or DOS attack
+            self.__remove_history_entry()
+
         except RequestError, e:
             self.__cleanContext()
             self.error("[" + str(e.status) + '] - ' + str(e.reason) + ', ' + 
str(e.detail))
@@ -127,6 +131,11 @@
     def testConnectivity(self):
         self.context.connection.test(throw_exception=True)
 
+    def __remove_history_entry(self):
+        last_entry = self.context.history.get(self.context.history.length() - 
1)
+        if last_entry and last_entry.startswith(ConnectCommand.name):
+            self.context.history.remove(self.context.history.length() - 1)
+
     def __cleanContext(self):
         if self.context.connection is not None:
             self.context._clean_settings()
diff --git a/src/ovirtcli/historymanager.py b/src/ovirtcli/historymanager.py
index a696590..9ab618d 100644
--- a/src/ovirtcli/historymanager.py
+++ b/src/ovirtcli/historymanager.py
@@ -73,6 +73,10 @@
             self.__register_file(self.tmp_histfile)
             self.clear()
 
+    def remove(self, entry):
+        if self.length() > 0:
+            readline.remove_history_item(entry)
+
     def __unregister_dump_callback(self):
         for item in atexit._exithandlers:
             if hasattr(item[0], 'func_name') and \


--
To view, visit http://gerrit.ovirt.org/8054
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieb983ecec4ae30fbae2411f0bf2eaef194e96f21
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-cli
Gerrit-Branch: master
Gerrit-Owner: Michael Pasternak <mpast...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to