Skip to content

Commit 43aa849

Browse files
committed
Use bare nosemgrep and ESLint block-disables so Codacy honours suppressions
1 parent 6117d3e commit 43aa849

7 files changed

Lines changed: 12 additions & 15 deletions

File tree

browser-extension/background.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ async function loadState() {
2626
// fires on the spread of an unsanitised storage value. ``stored``
2727
// is whatever chrome.storage round-trips for us; we only ever
2828
// copy own enumerable properties onto a fresh default.
29-
// eslint-disable-next-line security/detect-object-injection
29+
/* eslint-disable security/detect-object-injection */
3030
const saved = Object.prototype.hasOwnProperty.call(stored, STATE_KEY)
3131
? stored[STATE_KEY] : null;
32+
/* eslint-enable security/detect-object-injection */
3233
if (saved == null || typeof saved !== "object") {
3334
return Object.assign({}, DEFAULT_STATE);
3435
}
@@ -81,7 +82,7 @@ export function actionFor(event) {
8182
}
8283
}
8384

84-
// eslint-disable-next-line security-node/detect-unhandled-async-errors
85+
/* eslint-disable security-node/detect-unhandled-async-errors */
8586
async function handleMessage(message, _sender, sendResponse) {
8687
const state = await loadState();
8788
switch (message?.command) {
@@ -129,6 +130,7 @@ async function handleMessage(message, _sender, sendResponse) {
129130
sendResponse({ ok: false, reason: "unknown command" });
130131
}
131132
}
133+
/* eslint-enable security-node/detect-unhandled-async-errors */
132134

133135
if (typeof chrome !== "undefined" && chrome.runtime) {
134136
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {

browser-extension/popup.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ function send(command, extra = {}) {
1010
});
1111
}
1212

13-
// eslint-disable-next-line security-node/detect-unhandled-async-errors
13+
/* eslint-disable security-node/detect-unhandled-async-errors */
1414
async function refresh() {
1515
const reply = await send("status");
1616
const state = reply.state || {};
@@ -19,6 +19,7 @@ async function refresh() {
1919
document.getElementById("count").textContent =
2020
String((state.actions || []).length);
2121
}
22+
/* eslint-enable security-node/detect-unhandled-async-errors */
2223

2324
// Wrap every async event-handler invocation of refresh() in a logged
2425
// .catch so a thrown promise can't drop silently

je_auto_control/linux_wayland/keyboard.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def _run(argv: list, *, timeout: float = 5.0) -> None:
4545
# argv comes from a private allow-list (wtype / ydotool absolute
4646
# paths via shutil.which), never user input; no shell=True.
4747
try:
48-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
49-
subprocess.run( # nosec B603
48+
subprocess.run( # nosec B603 # nosemgrep
5049
argv, check=True, timeout=timeout,
5150
stdout=subprocess.DEVNULL, stderr=subprocess.PIPE,
5251
)

je_auto_control/linux_wayland/mouse.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ def _run(argv: list, *, timeout: float = 5.0) -> None:
4343
# argv comes from a private allow-list (ydotool absolute path via
4444
# shutil.which), never user input; no shell=True.
4545
try:
46-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
47-
subprocess.run( # nosec B603
46+
subprocess.run( # nosec B603 # nosemgrep
4847
argv, check=True, timeout=timeout,
4948
stdout=subprocess.DEVNULL, stderr=subprocess.PIPE,
5049
)

je_auto_control/linux_wayland/screen.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ def _run(argv: list, *, timeout: float = 10.0) -> bytes:
4040
# argv comes from a private allow-list (grim / wlr-randr absolute
4141
# paths via shutil.which), never user input; no shell=True.
4242
try:
43-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
44-
completed = subprocess.run( # nosec B603
43+
completed = subprocess.run( # nosec B603 # nosemgrep
4544
argv, check=True, timeout=timeout,
4645
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
4746
)

test/unit_test/headless/test_self_healing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,7 @@ def test_package_facade_stays_qt_free():
232232
)
233233
# subprocess spawned with [sys.executable, ...] — known interpreter,
234234
# fixed argv list, no shell=True, no user input.
235-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
236-
result = subprocess.run( # nosec B603
235+
result = subprocess.run( # nosec B603 # nosemgrep
237236
[sys.executable, "-c", script],
238237
capture_output=True, text=True, check=True, timeout=60,
239238
)

test/unit_test/headless/test_wayland_backend.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ def runner(argv, **_kwargs):
9696
captured.append(list(argv))
9797
# CompletedProcess is a *constructor* (not a process spawn);
9898
# used here to mock subprocess.run's return value.
99-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
100-
result = subprocess.CompletedProcess(argv, 0, b"", b"")
99+
result = subprocess.CompletedProcess(argv, 0, b"", b"") # nosemgrep
101100
return result
102101
return runner
103102

@@ -234,9 +233,8 @@ def test_screenshot_calls_grim_with_path():
234233
with patch.object(wayland_screen, "binary_path",
235234
return_value="/usr/bin/grim"), \
236235
patch.object(wayland_screen.subprocess, "run",
237-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
238236
side_effect=lambda argv, **kw: (captured.append(argv)
239-
or subprocess.CompletedProcess(argv, 0, b"", b""))):
237+
or subprocess.CompletedProcess(argv, 0, b"", b""))): # nosemgrep
240238
wayland_screen.screenshot("out.png")
241239
assert captured == [["/usr/bin/grim", "out.png"]]
242240

0 commit comments

Comments
 (0)