Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "hatchling.build"

[project]
name = "socketsecurity"
version = "2.2.6"
version = "2.2.7"
requires-python = ">= 3.10"
license = {"file" = "LICENSE"}
dependencies = [
Expand Down Expand Up @@ -52,6 +52,7 @@ dev = [

[project.scripts]
socketcli = "socketsecurity.socketcli:cli"
socketclidev = "socketsecurity.socketcli:cli"

[project.urls]
Homepage = "https://socket.dev"
Expand Down
2 changes: 1 addition & 1 deletion socketsecurity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__author__ = 'socket.dev'
__version__ = '2.2.6'
__version__ = '2.2.7'
16 changes: 16 additions & 0 deletions socketsecurity/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ def handle_output(self, diff_report: Diff) -> None:
plugin_mgr = PluginManager({"jira": jira_config})
plugin_mgr.send(diff_report, config=self.config)

# Debug Slack webhook configuration when debug is enabled (always show when debug is on)
if self.config.enable_debug:
import os
slack_enabled_env = os.getenv("SOCKET_SLACK_ENABLED", "Not set")
slack_config_env = os.getenv("SOCKET_SLACK_CONFIG_JSON", "Not set")
slack_url = "Not configured"
if self.config.slack_plugin.config and self.config.slack_plugin.config.get("url"):
slack_url = self.config.slack_plugin.config.get("url")
self.logger.debug("=== Slack Webhook Debug Information ===")
self.logger.debug(f"Slack Plugin Enabled: {self.config.slack_plugin.enabled}")
self.logger.debug(f"SOCKET_SLACK_ENABLED environment variable: {slack_enabled_env}")
self.logger.debug(f"SOCKET_SLACK_CONFIG_JSON environment variable: {slack_config_env}")
self.logger.debug(f"Slack Webhook URL: {slack_url}")
self.logger.debug(f"Slack Alert Levels: {self.config.slack_plugin.levels}")
self.logger.debug("=====================================")

if self.config.slack_plugin.enabled:
slack_config = {
"enabled": self.config.slack_plugin.enabled,
Expand Down
12 changes: 12 additions & 0 deletions socketsecurity/plugins/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ def get_name():

def send(self, diff, config: CliConfig):
if not self.config.get("enabled", False):
if config.enable_debug:
logger.debug("Slack plugin is disabled - skipping webhook notification")
return
if not self.config.get("url"):
logger.warning("Slack webhook URL not configured.")
if config.enable_debug:
logger.debug("Slack webhook URL is missing from configuration")
return
else:
url = self.config.get("url")
Expand All @@ -31,13 +35,21 @@ def send(self, diff, config: CliConfig):

message = self.create_slack_blocks_from_diff(diff, config)
logger.debug(f"Sending message to {url}")

if config.enable_debug:
logger.debug(f"Slack webhook URL: {url}")
logger.debug(f"Number of alerts to send: {len(diff.new_alerts)}")
logger.debug(f"Message blocks count: {len(message)}")

response = requests.post(
url,
json={"blocks": message}
)

if response.status_code >= 400:
logger.error("Slack error %s: %s", response.status_code, response.text)
elif config.enable_debug:
logger.debug(f"Slack webhook response: {response.status_code}")

@staticmethod
def create_slack_blocks_from_diff(diff: Diff, config: CliConfig):
Expand Down
Loading