Skip to content

Silence Codacy Bandit B105 false positive in executor leak test#63

Merged
JE-Chen merged 1 commit intodevfrom
fix/codacy-bandit-test-secret
Apr 25, 2026
Merged

Silence Codacy Bandit B105 false positive in executor leak test#63
JE-Chen merged 1 commit intodevfrom
fix/codacy-bandit-test-secret

Conversation

@JE-Chen
Copy link
Copy Markdown
Member

@JE-Chen JE-Chen commented Apr 25, 2026

Summary

PR #61 added test_substitute_does_not_leak_into_result_key with a literal os.environ["FA_EXEC_SECRET"] = "TOP_SECRET" to verify substituted env values don't leak into result keys. Codacy/Bandit flagged this as B105 — Possible hardcoded password (PR #62 / dev → main blocked on it).

This is a test-only false positive — the literal is a deliberately recognisable sentinel, not a credential. Refactor instead of suppressing:

  • Switch to pytest's monkeypatch (matching the existing pattern in test_substitution.py); auto-cleans, no try/finally needed.
  • Rename env var so the key no longer contains "SECRET".
  • Use a non-credential-looking sentinel value.

Behaviour under test is unchanged — still proves the un-substituted literal stays in the result key while the expanded value only reaches the callable.

Test plan

  • pytest tests/test_action_executor.py — 13 passed locally
  • Codacy clean on this PR
  • CI matrix green

Codacy/Bandit flagged the literal string assigned to FA_EXEC_SECRET as a
hardcoded password (B105). Switch to pytest's monkeypatch (matching
test_substitution.py's existing pattern), rename the env var so the key
itself does not contain "SECRET", and use a non-credential-looking
sentinel value. Behaviour under test is unchanged.
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@sonarqubecloud
Copy link
Copy Markdown

@JE-Chen JE-Chen merged commit ea2d62f into dev Apr 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant