Skip to content

Commit e506d86

Browse files
committed
Move Codacy suppressions inline so Semgrep/ESLint/Bandit honour them
1 parent 5de3c77 commit e506d86

9 files changed

Lines changed: 34 additions & 30 deletions

File tree

.github/workflows/docker.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ jobs:
2828
- uses: actions/checkout@v4
2929

3030
- name: Set up Docker Buildx
31-
uses: docker/setup-buildx-action@v3 # NOSONAR githubactions:S7637 — project convention pins to vendored major version tags (matches dev.yml / stable.yml / quality.yml)
31+
# nosemgrep: yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha.third-party-action-not-pinned-to-commit-sha
32+
uses: docker/setup-buildx-action@v3 # NOSONAR githubactions:S7637
3233

3334
- name: Build image (no push)
34-
uses: docker/build-push-action@v5 # NOSONAR githubactions:S7637 — project convention pins to vendored major version tags
35+
# nosemgrep: yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha.third-party-action-not-pinned-to-commit-sha
36+
uses: docker/build-push-action@v5 # NOSONAR githubactions:S7637
3537
with:
3638
context: .
3739
file: docker/Dockerfile
@@ -52,10 +54,12 @@ jobs:
5254
- uses: actions/checkout@v4
5355

5456
- name: Set up Docker Buildx
55-
uses: docker/setup-buildx-action@v3 # NOSONAR githubactions:S7637 — project convention pins to vendored major version tags (matches dev.yml / stable.yml / quality.yml)
57+
# nosemgrep: yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha.third-party-action-not-pinned-to-commit-sha
58+
uses: docker/setup-buildx-action@v3 # NOSONAR githubactions:S7637
5659

5760
- name: Rebuild image (cached)
58-
uses: docker/build-push-action@v5 # NOSONAR githubactions:S7637 — project convention pins to vendored major version tags
61+
# nosemgrep: yaml.github-actions.security.third-party-action-not-pinned-to-commit-sha.third-party-action-not-pinned-to-commit-sha
62+
uses: docker/build-push-action@v5 # NOSONAR githubactions:S7637
5963
with:
6064
context: .
6165
file: docker/Dockerfile

browser-extension/background.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
// unit-tested by importing this module from a Node test runner.
66

77
// nosemgrep: codacy.javascript.security.hard-coded-password
8-
// reason: this is a chrome.storage key, not a credential.
9-
const STATE_KEY = "autocontrol.recorder.state";
8+
const STATE_KEY = "autocontrol.recorder.state"; // nosemgrep: codacy.javascript.security.hard-coded-password
109

1110
/**
1211
* @typedef {Object} RecorderState
@@ -27,6 +26,7 @@ async function loadState() {
2726
// fires on the spread of an unsanitised storage value. ``stored``
2827
// is whatever chrome.storage round-trips for us; we only ever
2928
// copy own enumerable properties onto a fresh default.
29+
// eslint-disable-next-line security/detect-object-injection
3030
const saved = Object.prototype.hasOwnProperty.call(stored, STATE_KEY)
3131
? stored[STATE_KEY] : null;
3232
if (saved == null || typeof saved !== "object") {
@@ -81,6 +81,7 @@ export function actionFor(event) {
8181
}
8282
}
8383

84+
// eslint-disable-next-line security-node/detect-unhandled-async-errors
8485
async function handleMessage(message, _sender, sendResponse) {
8586
const state = await loadState();
8687
switch (message?.command) {

browser-extension/popup.js

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

13+
// eslint-disable-next-line security-node/detect-unhandled-async-errors
1314
async function refresh() {
1415
const reply = await send("status");
1516
const state = reply.state || {};

examples/18_slack_daily_report.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,10 @@ def fetch_slack_messages(channel_id: str, *,
8686
f"https://slack.com/api/conversations.history?{params}",
8787
headers={"Authorization": f"Bearer {token}"},
8888
)
89+
# URL is built from the literal ``https://slack.com/api/...`` above
90+
# so file:// / custom schemes can't reach urlopen here.
8991
try:
90-
# nosec B310 # reason: URL is built from the literal
91-
# ``https://slack.com/api/...`` above — scheme is fixed,
92-
# never user-supplied, so file:// / custom schemes can't
93-
# reach urlopen here.
94-
with urllib.request.urlopen( # noqa: S310
92+
with urllib.request.urlopen( # nosec B310 # noqa: S310
9593
request, timeout=30.0) as resp:
9694
body = json.loads(resp.read().decode("utf-8"))
9795
except urllib.error.URLError as error:

je_auto_control/linux_wayland/keyboard.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ def _require(name: str, hint: str) -> str:
4242

4343

4444
def _run(argv: list, *, timeout: float = 5.0) -> None:
45-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
46-
# reason: argv comes from a private allow-list (wtype / ydotool
47-
# absolute paths via shutil.which), never user input; no shell=True.
45+
# argv comes from a private allow-list (wtype / ydotool absolute
46+
# paths via shutil.which), never user input; no shell=True.
4847
try:
49-
subprocess.run( # nosec B603 # reason: argv-list, validated binary
48+
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
49+
subprocess.run( # nosec B603
5050
argv, check=True, timeout=timeout,
5151
stdout=subprocess.DEVNULL, stderr=subprocess.PIPE,
5252
)

je_auto_control/linux_wayland/mouse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def _require_ydotool() -> str:
4040

4141

4242
def _run(argv: list, *, timeout: float = 5.0) -> None:
43-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
44-
# reason: argv comes from a private allow-list (ydotool absolute
45-
# path via shutil.which), never user input; no shell=True.
43+
# argv comes from a private allow-list (ydotool absolute path via
44+
# shutil.which), never user input; no shell=True.
4645
try:
47-
subprocess.run( # nosec B603 # reason: argv-list, validated binary
46+
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
47+
subprocess.run( # nosec B603
4848
argv, check=True, timeout=timeout,
4949
stdout=subprocess.DEVNULL, stderr=subprocess.PIPE,
5050
)

je_auto_control/linux_wayland/screen.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def _require_grim() -> str:
3737

3838

3939
def _run(argv: list, *, timeout: float = 10.0) -> bytes:
40-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
41-
# reason: argv comes from a private allow-list (grim / wlr-randr
42-
# absolute paths via shutil.which), never user input; no shell=True.
40+
# argv comes from a private allow-list (grim / wlr-randr absolute
41+
# paths via shutil.which), never user input; no shell=True.
4342
try:
44-
completed = subprocess.run( # nosec B603 # reason: argv-list, validated binary
43+
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
44+
completed = subprocess.run( # nosec B603
4545
argv, check=True, timeout=timeout,
4646
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
4747
)

test/unit_test/headless/test_self_healing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ def test_package_facade_stays_qt_free():
230230
"qt = [m for m in sys.modules if 'PySide6' in m]\n"
231231
"import json; print(json.dumps(qt))\n"
232232
)
233+
# subprocess spawned with [sys.executable, ...] — known interpreter,
234+
# fixed argv list, no shell=True, no user input.
233235
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
234-
# reason: subprocess spawned with [sys.executable, ...] — known
235-
# interpreter, fixed argv list, no shell=True, no user input.
236-
result = subprocess.run(
236+
result = subprocess.run( # nosec B603
237237
[sys.executable, "-c", script],
238238
capture_output=True, text=True, check=True, timeout=60,
239239
)

test/unit_test/headless/test_wayland_backend.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ def test_keymap_function_keys_present():
9494
def _fake_run(captured):
9595
def runner(argv, **_kwargs):
9696
captured.append(list(argv))
97+
# CompletedProcess is a *constructor* (not a process spawn);
98+
# used here to mock subprocess.run's return value.
9799
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
98-
# reason: CompletedProcess is a *constructor* (not a call to
99-
# spawn a process); used here to mock subprocess.run's return.
100100
result = subprocess.CompletedProcess(argv, 0, b"", b"")
101101
return result
102102
return runner
@@ -230,11 +230,11 @@ def test_mouse_raises_when_ydotool_missing():
230230

231231
def test_screenshot_calls_grim_with_path():
232232
captured: list = []
233-
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
234-
# reason: CompletedProcess constructor used to mock subprocess.run.
233+
# CompletedProcess constructor used to mock subprocess.run.
235234
with patch.object(wayland_screen, "binary_path",
236235
return_value="/usr/bin/grim"), \
237236
patch.object(wayland_screen.subprocess, "run",
237+
# nosemgrep: python.lang.security.audit.dangerous-subprocess-use-audit
238238
side_effect=lambda argv, **kw: (captured.append(argv)
239239
or subprocess.CompletedProcess(argv, 0, b"", b""))):
240240
wayland_screen.screenshot("out.png")

0 commit comments

Comments
 (0)