Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rules): account for
paramiko.*
imports
`AutoAddPolicy`, `WarningPolicy` and `SSHClient` are not only exposed in `paramiko.client`, but also in `paramiko` (https://github.com/paramiko/paramiko/blob/66117732de6de03914308f9a21b05b50a781d13c/paramiko/__init__.py#L121-L164). So we also have to account for that when resolving the import paths.
- Loading branch information
1 parent
4b9ec46
commit c44e0b5
Showing
3 changed files
with
58 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 50 additions & 40 deletions
90
...rules/flake8_bandit/snapshots/ruff_linter__rules__flake8_bandit__tests__S507_S507.py.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,82 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs | ||
--- | ||
S507.py:13:40: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
S507.py:15:40: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
| | ||
12 | # Errors | ||
13 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) | ||
14 | # Errors | ||
15 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) | ||
| ^^^^^^^^^^^^^^^^^^^^ S507 | ||
14 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) | ||
15 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) | ||
16 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) | ||
17 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) | ||
| | ||
|
||
S507.py:14:40: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
S507.py:16:40: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
| | ||
12 | # Errors | ||
13 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) | ||
14 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) | ||
14 | # Errors | ||
15 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) | ||
16 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) | ||
| ^^^^^^^^^^^^^^^^^^^^ S507 | ||
15 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) | ||
16 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) | ||
17 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) | ||
18 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) | ||
| | ||
|
||
S507.py:15:40: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
S507.py:17:40: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
| | ||
13 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) | ||
14 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) | ||
15 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) | ||
15 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy) | ||
16 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) | ||
17 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) | ||
| ^^^^^^^^^^^^^^^^^^^^ S507 | ||
16 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) | ||
17 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) | ||
18 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) | ||
19 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) | ||
| | ||
|
||
S507.py:16:40: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
S507.py:18:40: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
| | ||
14 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) | ||
15 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) | ||
16 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) | ||
16 | ssh_client.set_missing_host_key_policy(client.WarningPolicy) | ||
17 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) | ||
18 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) | ||
| ^^^^^^^^^^^^^ S507 | ||
17 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) | ||
18 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) | ||
19 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) | ||
20 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) | ||
| | ||
|
||
S507.py:17:47: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
S507.py:19:47: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
| | ||
15 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) | ||
16 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) | ||
17 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) | ||
17 | ssh_client.set_missing_host_key_policy(client.AutoAddPolicy()) | ||
18 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) | ||
19 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) | ||
| ^^^^^^^^^^^^^^^^^^^^ S507 | ||
18 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) | ||
19 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) | ||
20 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) | ||
21 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) | ||
| | ||
|
||
S507.py:18:47: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
S507.py:20:47: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
| | ||
16 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) | ||
17 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) | ||
18 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) | ||
18 | ssh_client.set_missing_host_key_policy(AutoAddPolicy) | ||
19 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) | ||
20 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) | ||
| ^^^^^^^^^^^^^^^^^^^^ S507 | ||
19 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) | ||
21 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) | ||
22 | ssh_client_from_paramiko.set_missing_host_key_policy(paramiko.AutoAddPolicy) | ||
| | ||
|
||
S507.py:19:47: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
S507.py:21:47: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
| | ||
17 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) | ||
18 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) | ||
19 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) | ||
19 | ssh_client.set_missing_host_key_policy(policy=client.AutoAddPolicy) | ||
20 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) | ||
21 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) | ||
| ^^^^^^^^^^^^^ S507 | ||
20 | | ||
21 | # Unrelated | ||
22 | ssh_client_from_paramiko.set_missing_host_key_policy(paramiko.AutoAddPolicy) | ||
| | ||
|
||
S507.py:22:54: S507 Paramiko call with policy set to automatically trust the unknown host key | ||
| | ||
20 | ssh_client.set_missing_host_key_policy(policy=client.WarningPolicy) | ||
21 | ssh_client.set_missing_host_key_policy(policy=WarningPolicy) | ||
22 | ssh_client_from_paramiko.set_missing_host_key_policy(paramiko.AutoAddPolicy) | ||
| ^^^^^^^^^^^^^^^^^^^^^^ S507 | ||
23 | | ||
24 | # Unrelated | ||
| | ||
|
||
|