Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S601 for sanitized command #42

Open
dmcnulla opened this issue Jan 12, 2023 · 0 comments
Open

S601 for sanitized command #42

dmcnulla opened this issue Jan 12, 2023 · 0 comments

Comments

@dmcnulla
Copy link

I'm getting flagged for S601 on the following code even though I've added sanitization of the command.

from paramiko import SSHClient
from shlex import join as shlex.join
...
class RemoteConnectionClass:
    ...

    def _create_ssh_client_conn(self, dbs_name: str, ssh_client=SSHClient) -> SSHClient:
        """Create, connect, and return ssh client."""
        ssh_client = ssh_client()
        ...
        return ssh_client
    
    def run_cmd(self, cmd: list[str], target_node: str, output_as_list=False,
                 std_out_timeout=DEFAULT_TIMEOUT) -> (str or [str], int):
        ssh_client = self._create_ssh_client_conn(target_node)

        # S601 is flagged for the following line
        std_in, std_out, std_err = ssh_client.exec_command(shlex_join(cmd))

        std_out.channel.settimeout(std_out_timeout)
        exit_code = std_out.channel.recv_exit_status()
        output = std_out.readlines() if output_as_list else std_out.read().decode()
        return output, exit_code

python 3.10.0 on macos Ventura 13.0.1
paramiko 2.9.5

Is there a recognized sanitization, or do I have to comment it with # noqa: S601 because it is already santized ?

Thanks,

Dave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant