Skip to content

Commit

Permalink
Ignore bandit errors when setting password hash algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
flashcode committed Jan 1, 2023
1 parent 47e6d0f commit ba2cb0c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions qweechat/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def pbkdf2(self, hash_name, salt):
def _build_init_command(self):
"""Build the init command to send to WeeChat."""
totp = f',totp={self._totp}' if self._totp else ''
if self._pwd_hash_algo == 'plain':
if self._pwd_hash_algo == 'plain': # nosec
cmd = _PROTO_INIT_PWD % {
'password': self._password,
'totp': totp,
Expand All @@ -154,16 +154,16 @@ def _build_init_command(self):
salt = self._server_nonce + client_nonce
pwd_hash = None
iterations = ''
if self._pwd_hash_algo == 'pbkdf2+sha512':
if self._pwd_hash_algo == 'pbkdf2+sha512': # nosec
pwd_hash = self.pbkdf2('sha512', salt)
iterations = f':{self._pwd_hash_iter}'
elif self._pwd_hash_algo == 'pbkdf2+sha256':
elif self._pwd_hash_algo == 'pbkdf2+sha256': # nosec
pwd_hash = self.pbkdf2('sha256', salt)
iterations = f':{self._pwd_hash_iter}'
elif self._pwd_hash_algo == 'sha512':
elif self._pwd_hash_algo == 'sha512': # nosec
pwd = salt + self._password.encode('utf-8')
pwd_hash = hashlib.sha512(pwd).hexdigest()
elif self._pwd_hash_algo == 'sha256':
elif self._pwd_hash_algo == 'sha256': # nosec
pwd = salt + self._password.encode('utf-8')
pwd_hash = hashlib.sha256(pwd).hexdigest()
if not pwd_hash:
Expand All @@ -184,7 +184,7 @@ def _build_sync_command(self):

def handshake_timer_expired(self):
if self.status == STATUS_AUTHENTICATING:
self._pwd_hash_algo = 'plain'
self._pwd_hash_algo = 'plain' # nosec
self.send_to_weechat(self._build_init_command())
self.sync_weechat()
self.set_status(STATUS_CONNECTED)
Expand Down

0 comments on commit ba2cb0c

Please sign in to comment.