Skip to content

Commit 021d006

Browse files
committed
Clear 5 Codacy main-branch findings
- rest_server: rename _JSONHandler.log_message parameter back to ``format`` so the signature matches BaseHTTPRequestHandler, silencing PyLint W0221 (arguments-renamed); add a pylint disable comment because the name deliberately shadows the builtin - conf.py: add ``# pylint: disable=redefined-builtin`` next to the existing ruff noqa for Sphinx's required ``copyright`` global (W0622) - clipboard._linux_get/_linux_set: annotate the two subprocess.run calls with nosemgrep for dangerous-subprocess-use-audit; the argv list is built from an allowlist (xclip/xsel) located via shutil.which - shell_process.exec_shell: same nosemgrep annotation on the Popen call; argv is shlex-split then validated by ``_normalize_command``
1 parent fa4acc1 commit 021d006

4 files changed

Lines changed: 6 additions & 3 deletions

File tree

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# -- Project information -----------------------------------------------------
1212

1313
project = 'AutoControl'
14-
copyright = '2020 ~ Now, JE-Chen' # noqa: A001 # reason: Sphinx-required name
14+
copyright = '2020 ~ Now, JE-Chen' # noqa: A001 # pylint: disable=redefined-builtin # reason: Sphinx-required name
1515
author = 'JE-Chen'
1616
release = '0.0.179'
1717

je_auto_control/utils/clipboard/clipboard.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def _linux_get() -> str:
143143
if cmd is None:
144144
raise RuntimeError("Install xclip or xsel for Linux clipboard support")
145145
read_cmd = cmd + ["-o"] if cmd[0] == "xclip" else cmd + ["--output"]
146+
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
146147
result = subprocess.run( # nosec B603 # reason: argv from allowlist (xclip/xsel) discovered via shutil.which
147148
read_cmd, capture_output=True, check=True, timeout=5,
148149
)
@@ -154,6 +155,7 @@ def _linux_set(text: str) -> None:
154155
if cmd is None:
155156
raise RuntimeError("Install xclip or xsel for Linux clipboard support")
156157
write_cmd = cmd + ["-i"] if cmd[0] == "xclip" else cmd + ["--input"]
158+
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
157159
subprocess.run( # nosec B603 # reason: argv from allowlist (xclip/xsel) discovered via shutil.which
158160
write_cmd, input=text.encode("utf-8"),
159161
check=True, timeout=5,

je_auto_control/utils/rest_api/rest_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ class _JSONHandler(BaseHTTPRequestHandler):
2525
server_version = "AutoControlREST/1.0"
2626

2727
# Suppress default stderr access logs — route through the project logger.
28-
def log_message(self, fmt: str, *args: Any) -> None:
28+
def log_message(self, format, *args) -> None: # noqa: A002 # pylint: disable=redefined-builtin # reason: stdlib BaseHTTPRequestHandler override
2929
autocontrol_logger.info("rest-api %s - %s",
30-
self.address_string(), fmt % args)
30+
self.address_string(), format % args)
3131

3232
def do_GET(self) -> None: # noqa: N802 # reason: stdlib API
3333
parsed = urlparse(self.path)

je_auto_control/utils/shell_process/shell_exec.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def exec_shell(self, shell_command: Union[str, List[str]]) -> None:
5151
try:
5252
self.exit_program()
5353
args = _normalize_command(shell_command)
54+
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit.dangerous-subprocess-use-audit
5455
self.process = subprocess.Popen( # nosec B603 # reason: shell=False, argv list validated via _normalize_command
5556
args,
5657
stdout=subprocess.PIPE,

0 commit comments

Comments
 (0)