Skip to content

Commit ea2d62f

Browse files
authored
Merge pull request #63 from Integration-Automation/fix/codacy-bandit-test-secret
Silence Codacy Bandit B105 false positive in executor leak test
2 parents 7a0072e + c1a43c2 commit ea2d62f

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

tests/test_action_executor.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,20 +112,16 @@ def test_duplicate_actions_do_not_collide() -> None:
112112
assert list(results.values()) == ["first", "first"]
113113

114114

115-
def test_substitute_does_not_leak_into_result_key() -> None:
115+
def test_substitute_does_not_leak_into_result_key(monkeypatch: pytest.MonkeyPatch) -> None:
116116
"""``substitute=True`` must keep the un-expanded literal in result keys."""
117-
import os
118-
119-
os.environ["FA_EXEC_SECRET"] = "TOP_SECRET"
120-
try:
121-
executor = _fresh_executor()
122-
results = executor.execute_action(
123-
[["echo", {"value": "${env:FA_EXEC_SECRET}"}]],
124-
substitute=True,
125-
)
126-
[(key, value)] = results.items()
127-
assert "TOP_SECRET" not in key
128-
assert "${env:FA_EXEC_SECRET}" in key
129-
assert value == "TOP_SECRET"
130-
finally:
131-
os.environ.pop("FA_EXEC_SECRET", None)
117+
sentinel = "sentinel-must-not-appear-in-key"
118+
monkeypatch.setenv("FA_EXEC_LEAK_PROBE", sentinel)
119+
executor = _fresh_executor()
120+
results = executor.execute_action(
121+
[["echo", {"value": "${env:FA_EXEC_LEAK_PROBE}"}]],
122+
substitute=True,
123+
)
124+
[(key, value)] = results.items()
125+
assert sentinel not in key
126+
assert "${env:FA_EXEC_LEAK_PROBE}" in key
127+
assert value == sentinel

0 commit comments

Comments
 (0)