Skip to content

bandit check seems to link arguments not function call #9994

@Borda

Description

@Borda

It seems that Ruff reports wrong lines for this bandit issue

out = subprocess.check_output(  # <-- yesqa expected
    ["git", "rev-parse", "HEAD"],  # <-- ruff reported
    stderr=DEVNULL,
)

in fact, it creates deadlock as yesqa removes noqas from line 2 as it expects them with line 1, but then ruff reports line 2

2: S603 `subprocess` call: check for execution of untrusted input
2: S607 Starting a process with a partial executable path

adding a dummy line to the argument, and it seems to be baked with the first argument as this

out = subprocess.check_output(  # <-- yesqa expected
	print(), # <-- ruff reported
    ["git", "rev-parse", "HEAD"],
    stderr=DEVNULL,
)

still reports line 2 but the next one

out = subprocess.check_output(  # <-- yesqa expected
	# any line
    ["git", "rev-parse", "HEAD"],  # <-- ruff reported
    stderr=DEVNULL,
)

reports line 3

--

using pre-commit with

  - repo: https://github.com/asottile/yesqa
    rev: v1.5.0
    hooks:
      - id: yesqa
        additional_dependencies:
          - flake8-bandit

  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.2.1
    hooks:
      - id: ruff
        args: ["--fix"]

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions