fix: what bandit and the remaining lint rules found
- nosec for SHA512_password in the login payload (B105): it is a flag telling the gateway how Input_Passwd is encoded, not a password; a false positive. - A failed login raises ConnectionException from the underlying error, so the cause stays attached. - tests: pytest.raises instead of try / assert False / except, which python -O would have turned into tests that always pass.
This commit is contained in:
1 parent
f9fc4e3d06
commit
b306b64673
2 files changed
+7
-18
No files matched your search
@@ -155,7 +155,8 @@ class ZyxelVMGDriver(ResidentialGatewayDriver):
|
||||
"Input_Account": self.username,
|
||||
"Input_Passwd": base64.b64encode(self.password.encode("ascii")).decode("ascii"),
|
||||
"RememberPassword": 0,
|
||||
"SHA512_password": False,
|
||||
# A flag telling the gateway how Input_Passwd is encoded, not a password.
|
||||
"SHA512_password": False, # nosec B105
|
||||
}
|
||||
|
||||
enc_payload = crypto.encrypt_json(login_data)
|
||||
@@ -169,7 +170,7 @@ class ZyxelVMGDriver(ResidentialGatewayDriver):
|
||||
resp.raise_for_status()
|
||||
result = crypto.decrypt_response(resp.json())
|
||||
except (requests.RequestException, json.JSONDecodeError, TypeError, KeyError) as e:
|
||||
raise ConnectionException(f"Login failed at {self._base_url}: {e}")
|
||||
raise ConnectionException(f"Login failed at {self._base_url}: {e}") from e
|
||||
|
||||
if result.get("result") != "ZCFG_SUCCESS":
|
||||
raise ConnectionException(
|
||||
|
||||
Reference in new issue
Block a user