Skip to content

Traceback on error displays password with adb tool #411

Closed

Description

@drewaogle

ran adb utils execute summary and when it failed in connect I got:

│ /home/drew_ogle/penv/etl/lib/python3.11/site-packages/aperturedb/Connector.py:163 in             │
│ authenticate                                                                                     │
│                                                                                                  │
│   160 │   │   │   if shared_data.session is None:                                                │
│   161 │   │   │   │   self.shared_data.lock = Lock()                                             │
│   162 │   │   │   │   try:                                                                       │
│ ❱ 163 │   │   │   │   │   self._authenticate(user, password, token)                              │
│   164 │   │   │   │   except Exception as e:                                                     │
│   165 │   │   │   │   │   raise UnauthenticatedException(                                        │
│   166 │   │   │   │   │   │   "Authentication failed:", str(e))                                  │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │    password = 'PASSWORD HERE'                                                                        │ │
│ │        self = <aperturedb.Connector.Connector object at 0x7fab5ff93750>                      │ │
│ │ shared_data = namespace(session=None, lock=<unlocked _thread.lock object at 0x7fab5f23ae00>) │ │
│ │       token = ''                                                                             │ │
│ │        user = 'admin'                                                                        │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/drew_ogle/penv/etl/lib/python3.11/site-packages/aperturedb/Connector.py:216 in             │
│ _authenticate                                                                                    │
│                                                                                                  │
│   213 │   │   │   raise Exception(                                                               │
│   214 │   │   │   │   "Either password or token must be specified for authentication")           │
│   215 │   │                                                                                      │
│ ❱ 216 │   │   response, _ = self._query(query)                                                   │
│   217 │   │                                                                                      │
│   218 │   │   if not isinstance(response, (list, tuple)) or not "Authenticate" in response[0]:   │
│   219 │   │   │   raise Exception(                                                               │
│                                                                                                  │
│ ╭───────────────────────────────── locals ──────────────────────────────────╮                    │
│ │ password = 'admin'                                                                │           │
│ │    query = [{'Authenticate': {'username': 'admin', 'password': 'PASSWORD HERE'}}] │           │
│ │     self = <aperturedb.Connector.Connector object at 0x7fab5ff93750>           │                    │
│ │    token = ''                                                             │                    │
│ │     user = 'admin'                                                        │                    │
│ ╰───────────────────────────────────────────────────────────────────────────╯                    │
│                                                                                                  │
│ /home/drew_ogle/penv/etl/lib/python3.11/site-packages/aperturedb/Connector.py:400 in _query      │
│                                                                                                  │
│   397 │   │   │   │   self.conn.close()                                                          │
│   398 │   │   │   │   self.connected = False                                                     │
│   399 │   │   │                                                                                  │
│ ❱ 400 │   │   │   self.connect(                                                                  │
│   401 │   │   │   │   details=f"Will retry in {self.config.retry_interval_seconds} seconds")     │
│   402 │   │   │   time.sleep(self.config.retry_interval_seconds)                                 │
│   403                                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │          blob_array = []                                                                     │ │
│ │                data = b'\n>[{"Authenticate": {"username": "admin", "password": "PASSWORD!!"}}]'   │ │
│ │               query = [{'Authenticate': {'username': 'admin', 'password': 'PASSWORD!!'}}]         │ │
│ │           query_msg = json: "[{\"Authenticate\": {\"username\": \"admin\", \"password\":     │ │
│ │                       \"PASSWORD HERE\"}}]"                                                          │ │
│ │           query_str = '[{"Authenticate": {"username": "admin", "password": "PASSWORD HERE"}}]'       │ │
│ │ response_blob_array = []                                                                     │ │
│ │                self = <aperturedb.Connector.Connector object at 0x7fab5ff93750>              │ │
│ │               tries = 1                                                                      │ │
│ │          try_resume = True                                                                   │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/drew_ogle/penv/etl/lib/python3.11/site-packages/aperturedb/Connector.py:330 in connect     │
│                                                                                                  │
│   327 │   │   │   # nothing else will work until this is done.                                   │
│   328 │   │   │   # This can help to get going amidst server restarts.                           │
│   329 │   │   │   try:                                                                           │
│ ❱ 330 │   │   │   │   self._connect()                                                            │
│   331 │   │   │   except socket.error as e:                                                      │
│   332 │   │   │   │   logger.error(                                                              │
│   333 │   │   │   │   │   f"Error connecting to server: {self.config} \r\n{details}.", exc_inf   │
│                                                                                                  │
│ ╭────────────────────────────── locals ───────────────────────────────╮                          │
│ │ details = 'Will retry in 1 seconds'                                 │                          │
│ │    self = <aperturedb.Connector.Connector object at 0x7fab5ff93750> │                          │
│ ╰─────────────────────────────────────────────────────────────────────╯                          │
│                                                                                                  │
│ /home/drew_ogle/penv/etl/lib/python3.11/site-packages/aperturedb/Connector.py:293 in _connect    │
│                                                                                                  │
│   290 │   │   │   # Receive response from server                                                 │
│   291 │   │   │   response = self._recv_msg()                                                    │
│   292 │   │   │                                                                                  │
│ ❱ 293 │   │   │   version, server_protocol = struct.unpack('@II', response)                      │
│   294 │   │   │                                                                                  │
│   295 │   │   │   if version != PROTOCOL_VERSION:                                                │
│   296 │   │   │   │   logger.warning("Protocol version differ from server")                      │
│                                                                                                  │
│ ╭─────────────────────────────── locals ────────────────────────────────╮                        │
│ │ hello_msg = b'\x01\x00\x00\x00\x02\x00\x00\x00'                       │                        │
│ │  protocol = 2                                                         │                        │
│ │  response = None                                                      │                        │
│ │      self = <aperturedb.Connector.Connector object at 0x7fab5ff93750> │                        │
│ ╰───────────────────────────────────────────────────────────────────────╯                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: a bytes-like object is required, not 'NoneType'

During handling of the above exception, another exception occurred:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/drew_ogle/penv/etl/lib/python3.11/site-packages/aperturedb/cli/utilities.py:44 in execute  │
│                                                                                                  │
│   41 │   │   │   CommandTypes.REMOVE_INDEXES, force) and utils.remove_all_indexes(),             │
│   42 │   }                                                                                       │
│   43 │                                                                                           │
│ ❱ 44 │   available_commands[command]()                                                           │
│   45                                                                                             │
│   46                                                                                             │
│   47 class LogLevel(str, Enum):                                                                  │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ available_commands = {                                                                       │ │
│ │                      │   <CommandTypes.STATUS: 'status'>: <function                          │ │
│ │                      execute.<locals>.<lambda> at 0x7fab5f4fd120>,                           │ │
│ │                      │   <CommandTypes.SUMMARY: 'summary'>: <repr-error '(\'Authentication   │ │
│ │                      failed:\', "a bytes-like object is required, not \'NoneType\'")'>,      │ │
│ │                      │   <CommandTypes.REMOVE_ALL: 'remove_all'>: <function                  │ │
│ │                      execute.<locals>.<lambda> at 0x7fab5f4fd3a0>,                           │ │
│ │                      │   <CommandTypes.REMOVE_INDEXES: 'remove_indexes'>: <function          │ │
│ │                      execute.<locals>.<lambda> at 0x7fab5f4fd1c0>                            │ │
│ │                      }                                                                       │ │
│ │            command = <CommandTypes.SUMMARY: 'summary'>                                       │ │
│ │              force = False                                                                   │ │
│ │              utils = <repr-error '(\'Authentication failed:\', "a bytes-like object is       │ │
│ │                      required, not \'NoneType\'")'>                                          │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/drew_ogle/penv/etl/lib/python3.11/site-packages/aperturedb/Utils.py:298 in summary         │
│                                                                                                  │
│    295 │   │                                                                                     │
│    296 │   │   This is essentially a call to :ref:`GetSchema <GetSchema>`_, with the results fo  │
│    297 │   │   """                                                                               │
│ ❱  298 │   │   r = self.get_schema()                                                             │
│    299 │   │   s = json.loads(self.status())[0]["GetStatus"]                                     │
│    300 │   │   version = s["version"]                                                            │
│    301 │   │   status = s["status"]                                                              │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │ self = <repr-error '(\'Authentication failed:\', "a bytes-like object is required, not       │ │
│ │        \'NoneType\'")'>                                                                      │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/drew_ogle/penv/etl/lib/python3.11/site-packages/aperturedb/Utils.py:174 in get_schema      │
│                                                                                                  │
│    171 │   │   │   }                                                                             │
│    172 │   │   }]                                                                                │
│    173 │   │                                                                                     │
│ ❱  174 │   │   res, _ = self.connector.query(query)                                              │
│    175 │   │                                                                                     │
│    176 │   │   schema = {}                                                                       │
│    177                                                                                           │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │   query = [{'GetSchema': {}}]                                                                │ │
│ │ refresh = False                                                                              │ │
│ │    self = <repr-error '(\'Authentication failed:\', "a bytes-like object is required, not    │ │
│ │           \'NoneType\'")'>                                                                   │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /home/drew_ogle/penv/etl/lib/python3.11/site-packages/aperturedb/Connector.py:432 in query       │
│                                                                                                  │
│   429 │   │   │   _type_: _description_                                                          │
│   430 │   │   """                                                                                │
│   431 │   │   if self.should_authenticate:                                                       │
│ ❱ 432 │   │   │   self.authenticate(                                                             │
│   433 │   │   │   │   shared_data=self.shared_data,                                              │
│   434 │   │   │   │   user=self.config.username,                                                 │
│   435 │   │   │   │   password=self.config.password,                                             │
│                                                                                                  │
│ ╭───────────────────────────── locals ──────────────────────────────╮                            │
│ │ blobs = []                                                        │                            │
│ │     q = [{'GetSchema': {}}]                                       │                            │
│ │  self = <aperturedb.Connector.Connector object at 0x7fab5ff93750> │                            │
│ ╰───────────────────────────────────────────────────────────────────╯                            │
│                                                                                                  │
│ /home/drew_ogle/penv/etl/lib/python3.11/site-packages/aperturedb/Connector.py:165 in             │
│ authenticate                                                                                     │
│                                                                                                  │
│   162 │   │   │   │   try:                                                                       │
│   163 │   │   │   │   │   self._authenticate(user, password, token)                              │
│   164 │   │   │   │   except Exception as e:                                                     │
│ ❱ 165 │   │   │   │   │   raise UnauthenticatedException(                                        │
│   166 │   │   │   │   │   │   "Authentication failed:", str(e))                                  │
│   167 │   │   │   else:                                                                          │
│   168 │   │   │   │   self.shared_data = shared_data                                             │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │    password = 'PASSWORD HERE'                                                                        │ │
│ │        self = <aperturedb.Connector.Connector object at 0x7fab5ff93750>                      │ │
│ │ shared_data = namespace(session=None, lock=<unlocked _thread.lock object at 0x7fab5f23ae00>) │ │
│ │       token = ''                                                                             │ │
│ │        user = 'admin'                                                                        │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

Activity

  1. drewaogle commented on Apr 19, 2024

    @drewaogle
    ContributorAuthor

    Obviously we don't want password printed out as it might leak into a log ( like it would have here ) which might not match the expected permissions people have.

  2. gsaluja9 commented on Aug 27, 2024

    @gsaluja9
    Contributor

    This is fixed, so check and close @drewaogle

  3. drewaogle commented on Sep 4, 2024

    @drewaogle
    ContributorAuthor

    Verified we no longer output local variables, which includes sensitive passwords as of #470

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions