Skip to content

Commit b321dc9

Browse files
committed
fix: keep OpenGrep notify from being overwritten by an empty TruffleHog input
OpenGrep and TruffleHog both stored notify settings under notification_method, so the Action's empty INPUT_TRUFFLEHOG_NOTIFICATION_METHOD wiped INPUT_OPENGREP_NOTIFICATION_METHOD. Store each under its own key, matching Trivy.
1 parent 6b5c0c0 commit b321dc9

2 files changed

Lines changed: 45 additions & 2 deletions

File tree

socket_basics/connectors.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ connectors:
145145
env_variable: INPUT_ERLANG_SAST_ENABLED
146146
type: bool
147147
default: false
148-
- name: notification_method
148+
- name: opengrep_notification_method
149149
option: --opengrep-notify
150150
description: "Notification method for OpenGrep (e.g., console, slack)"
151151
env_variable: INPUT_OPENGREP_NOTIFICATION_METHOD
@@ -410,7 +410,7 @@ connectors:
410410
env_variable: INPUT_TRUFFLEHOG_EXCLUDE_DIR
411411
type: str
412412
default: ""
413-
- name: notification_method
413+
- name: trufflehog_notification_method
414414
option: --trufflehog-notify
415415
description: "Notification method for TruffleHog (e.g., console, slack)"
416416
env_variable: INPUT_TRUFFLEHOG_NOTIFICATION_METHOD
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""OpenGrep and TruffleHog notify inputs must not share a config key.
2+
3+
GitHub Actions always exports every ``runs.env`` entry, so an unset
4+
``trufflehog_notification_method`` arrives as ``INPUT_TRUFFLEHOG_NOTIFICATION_METHOD=""``.
5+
That empty string must not wipe a real OpenGrep notify setting.
6+
"""
7+
8+
from socket_basics.core.config import load_config_from_env
9+
from socket_basics.core.notification.manager import NotificationManager
10+
11+
NOTIFY_ENV_VARS = (
12+
"INPUT_OPENGREP_NOTIFICATION_METHOD",
13+
"INPUT_TRUFFLEHOG_NOTIFICATION_METHOD",
14+
"INPUT_TRIVY_NOTIFICATION_METHOD",
15+
)
16+
17+
18+
def test_empty_trufflehog_action_input_does_not_wipe_opengrep_notify(monkeypatch):
19+
for name in NOTIFY_ENV_VARS:
20+
monkeypatch.delenv(name, raising=False)
21+
monkeypatch.setenv("INPUT_OPENGREP_NOTIFICATION_METHOD", "slack")
22+
# Unset Action inputs are forwarded as empty strings, not omitted.
23+
monkeypatch.setenv("INPUT_TRUFFLEHOG_NOTIFICATION_METHOD", "")
24+
25+
config = load_config_from_env()
26+
27+
assert config.get("opengrep_notification_method") == "slack"
28+
assert not config.get("trufflehog_notification_method")
29+
30+
nm = NotificationManager(
31+
{
32+
"notifiers": {
33+
"slack": {
34+
"module_path": "socket_basics.core.notification.slack_notifier",
35+
"class": "SlackNotifier",
36+
"parameters": [],
37+
}
38+
}
39+
},
40+
app_config=config,
41+
)
42+
nm.load_from_config()
43+
assert any(getattr(n, "name", "") == "slack" for n in nm.notifiers)

0 commit comments

Comments
 (0)