diff --git a/pyproject.toml b/pyproject.toml index 37ad7cb..1311b95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = [ @@ -52,6 +52,7 @@ dev = [ [project.scripts] socketcli = "socketsecurity.socketcli:cli" +socketclidev = "socketsecurity.socketcli:cli" [project.urls] Homepage = "https://socket.dev" diff --git a/socketsecurity/__init__.py b/socketsecurity/__init__.py index 3a4e477..8210ef3 100644 --- a/socketsecurity/__init__.py +++ b/socketsecurity/__init__.py @@ -1,2 +1,2 @@ __author__ = 'socket.dev' -__version__ = '2.2.6' +__version__ = '2.2.7' diff --git a/socketsecurity/output.py b/socketsecurity/output.py index eca30a2..2948bb2 100644 --- a/socketsecurity/output.py +++ b/socketsecurity/output.py @@ -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, diff --git a/socketsecurity/plugins/slack.py b/socketsecurity/plugins/slack.py index 0c592dc..a1d1c43 100644 --- a/socketsecurity/plugins/slack.py +++ b/socketsecurity/plugins/slack.py @@ -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") @@ -31,6 +35,12 @@ 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} @@ -38,6 +48,8 @@ def send(self, diff, config: CliConfig): 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):