From 3a0138b399eda2d590a8e42961fb44bb8f784fa4 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Tue, 4 Mar 2025 08:09:13 -0600 Subject: [PATCH 1/2] Resolve bandit warnings The `nosec` flags benefit from human-readable explanation, but bandit was seeing the trailing text and throwing warnings: ``` WARNING Test in comment: Needed is not a test name or id, ignoring WARNING Test in comment: for is not a test name or id, ignoring WARNING Test in comment: gitignore is not a test name or id, ignoring WARNING Test in comment: support is not a test name or id, ignoring ``` This is addressed by using another `#` character to hide the text. --- isort/hooks.py | 4 ++-- isort/settings.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/isort/hooks.py b/isort/hooks.py index b248d354..e5e5b625 100644 --- a/isort/hooks.py +++ b/isort/hooks.py @@ -5,7 +5,7 @@ """ import os -import subprocess # nosec - Needed for hook +import subprocess # nosec # Needed for hook from pathlib import Path from typing import List, Optional @@ -18,7 +18,7 @@ def get_output(command: List[str]) -> str: :param str command: the command to run :returns: the stdout output of the command """ - result = subprocess.run(command, stdout=subprocess.PIPE, check=True) # nosec - trusted input + result = subprocess.run(command, stdout=subprocess.PIPE, check=True) # nosec # trusted input return result.stdout.decode() diff --git a/isort/settings.py b/isort/settings.py index b8281a41..1ce83229 100644 --- a/isort/settings.py +++ b/isort/settings.py @@ -9,7 +9,7 @@ import posixpath import re import stat -import subprocess # nosec: Needed for gitignore support. +import subprocess # nosec # Needed for gitignore support. import sys from dataclasses import dataclass, field from pathlib import Path From e42578f21936bfc040ac22bcd7b6184570bced71 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Tue, 18 Mar 2025 16:01:00 -0500 Subject: [PATCH 2/2] Feedback: Remove context from `nosec` bandit comments --- isort/hooks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/isort/hooks.py b/isort/hooks.py index e5e5b625..4a58f475 100644 --- a/isort/hooks.py +++ b/isort/hooks.py @@ -5,7 +5,7 @@ """ import os -import subprocess # nosec # Needed for hook +import subprocess # nosec from pathlib import Path from typing import List, Optional @@ -18,7 +18,7 @@ def get_output(command: List[str]) -> str: :param str command: the command to run :returns: the stdout output of the command """ - result = subprocess.run(command, stdout=subprocess.PIPE, check=True) # nosec # trusted input + result = subprocess.run(command, stdout=subprocess.PIPE, check=True) # nosec return result.stdout.decode()