socketsecurity 2.2.5__tar.gz → 2.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/PKG-INFO +1 -1
  2. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/pyproject.toml +2 -1
  3. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/__init__.py +1 -1
  4. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/git_interface.py +78 -2
  5. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/output.py +16 -0
  6. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/slack.py +12 -0
  7. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/CODEOWNERS +0 -0
  8. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/PULL_REQUEST_TEMPLATE/bug-fix.md +0 -0
  9. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -0
  10. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/PULL_REQUEST_TEMPLATE/improvement.md +0 -0
  11. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  12. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/workflows/docker-stable.yml +0 -0
  13. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/workflows/pr-preview.yml +0 -0
  14. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/workflows/release.yml +0 -0
  15. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/workflows/version-check.yml +0 -0
  16. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.gitignore +0 -0
  17. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.hooks/sync_version.py +0 -0
  18. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.pre-commit-config.yaml +0 -0
  19. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.python-version +0 -0
  20. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/Dockerfile +0 -0
  21. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/LICENSE +0 -0
  22. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/Makefile +0 -0
  23. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/Pipfile.lock +0 -0
  24. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/README.md +0 -0
  25. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/docs/README.md +0 -0
  26. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/pytest.ini +0 -0
  27. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/scripts/build_container.sh +0 -0
  28. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/scripts/deploy-test-docker.sh +0 -0
  29. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/scripts/deploy-test-pypi.sh +0 -0
  30. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/scripts/run.sh +0 -0
  31. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/config.py +0 -0
  32. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/__init__.py +0 -0
  33. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/classes.py +0 -0
  34. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/cli_client.py +0 -0
  35. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/exceptions.py +0 -0
  36. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/helper/__init__.py +0 -0
  37. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/lazy_file_loader.py +0 -0
  38. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/logging.py +0 -0
  39. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/messages.py +0 -0
  40. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/resource_utils.py +0 -0
  41. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/scm/__init__.py +0 -0
  42. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/scm/base.py +0 -0
  43. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/scm/client.py +0 -0
  44. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/scm/github.py +0 -0
  45. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/scm/gitlab.py +0 -0
  46. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/scm_comments.py +0 -0
  47. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/socket_config.py +0 -0
  48. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/utils.py +0 -0
  49. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/__init__.py +0 -0
  50. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/base.py +0 -0
  51. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/jira.py +0 -0
  52. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/manager.py +0 -0
  53. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/teams.py +0 -0
  54. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/webhook.py +0 -0
  55. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/socketcli.py +0 -0
  56. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/__init__.py +0 -0
  57. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/core/conftest.py +0 -0
  58. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/core/create_diff_input.json +0 -0
  59. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/core/test_diff_generation.py +0 -0
  60. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/core/test_package_and_alerts.py +0 -0
  61. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/core/test_sdk_methods.py +0 -0
  62. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/core/test_supporting_methods.py +0 -0
  63. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/create_response.json +0 -0
  64. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/diff/stream_diff.json +0 -0
  65. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/diff/stream_diff_full.json +0 -0
  66. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/head_scan/metadata.json +0 -0
  67. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/head_scan/stream_scan.json +0 -0
  68. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/head_scan/stream_scan_full.json +0 -0
  69. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/new_scan/metadata.json +0 -0
  70. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/new_scan/stream_scan.json +0 -0
  71. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/repos/repo_info_error.json +0 -0
  72. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/repos/repo_info_no_head.json +0 -0
  73. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/repos/repo_info_success.json +0 -0
  74. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/settings/security-policy.json +0 -0
  75. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/__init__.py +0 -0
  76. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/test_cli_config.py +0 -0
  77. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/test_client.py +0 -0
  78. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/test_config.py +0 -0
  79. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/test_gitlab_auth.py +0 -0
  80. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/test_gitlab_auth_fallback.py +0 -0
  81. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/test_output.py +0 -0
  82. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/uv.lock +0 -0
  83. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/workflows/bitbucket-pipelines.yml +0 -0
  84. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/workflows/github-actions.yml +0 -0
  85. {socketsecurity-2.2.5 → socketsecurity-2.2.7}/workflows/gitlab-ci.yml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: socketsecurity
3
- Version: 2.2.5
3
+ Version: 2.2.7
4
4
  Summary: Socket Security CLI for CI/CD
5
5
  Project-URL: Homepage, https://socket.dev
6
6
  Author-email: Douglas Coburn <douglas@socket.dev>
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "socketsecurity"
9
- version = "2.2.5"
9
+ version = "2.2.7"
10
10
  requires-python = ">= 3.10"
11
11
  license = {"file" = "LICENSE"}
12
12
  dependencies = [
@@ -52,6 +52,7 @@ dev = [
52
52
 
53
53
  [project.scripts]
54
54
  socketcli = "socketsecurity.socketcli:cli"
55
+ socketclidev = "socketsecurity.socketcli:cli"
55
56
 
56
57
  [project.urls]
57
58
  Homepage = "https://socket.dev"
@@ -1,2 +1,2 @@
1
1
  __author__ = 'socket.dev'
2
- __version__ = '2.2.5'
2
+ __version__ = '2.2.7'
@@ -218,8 +218,21 @@ class Git:
218
218
  log.debug(f"Failed to get changed files via git diff (Bitbucket): {error}")
219
219
  # Fallback to git show for single commit
220
220
  if not detected:
221
- self.show_files = self.repo.git.show(self.commit, name_only=True, format="%n").splitlines()
222
- log.debug(f"Changed files detected via git show: {self.show_files}")
221
+ # Check if this is a merge commit first
222
+ if self._is_merge_commit():
223
+ # For merge commits, use git diff with parent
224
+ if self._detect_merge_commit_changes():
225
+ detected = True
226
+ else:
227
+ # Fallback to git show if merge detection fails
228
+ self.show_files = self.repo.git.show(self.commit, name_only=True, format="%n").splitlines()
229
+ log.debug(f"Changed files detected via git show (merge commit fallback): {self.show_files}")
230
+ detected = True
231
+ else:
232
+ # Regular single commit
233
+ self.show_files = self.repo.git.show(self.commit, name_only=True, format="%n").splitlines()
234
+ log.debug(f"Changed files detected via git show: {self.show_files}")
235
+ detected = True
223
236
  self.changed_files = []
224
237
  for item in self.show_files:
225
238
  if item != "":
@@ -380,6 +393,69 @@ class Git:
380
393
  log.debug("Using fallback committer: unknown")
381
394
  return "unknown"
382
395
 
396
+ def _is_merge_commit(self) -> bool:
397
+ """
398
+ Check if the current commit is a merge commit.
399
+
400
+ Returns:
401
+ True if this is a merge commit (has multiple parents), False otherwise
402
+ """
403
+ try:
404
+ # A merge commit has multiple parents
405
+ is_merge = len(self.commit.parents) > 1
406
+ log.debug(f"Commit {self.commit.hexsha[:8]} has {len(self.commit.parents)} parents, is_merge: {is_merge}")
407
+ return is_merge
408
+ except Exception as error:
409
+ log.debug(f"Error checking if commit is merge commit: {error}")
410
+ return False
411
+
412
+ def _detect_merge_commit_changes(self) -> bool:
413
+ """
414
+ Detect changed files in a merge commit using git diff with parent.
415
+
416
+ This method handles the case where git show --name-only doesn't work
417
+ for merge commits (expected Git behavior).
418
+
419
+ Returns:
420
+ True if detection was successful, False otherwise
421
+ """
422
+ try:
423
+ if not self._is_merge_commit():
424
+ log.debug("Not a merge commit, skipping merge commit detection")
425
+ return False
426
+
427
+ # For merge commits, we need to diff against a parent
428
+ # We'll use the first parent (typically the target branch)
429
+ if not self.commit.parents:
430
+ log.debug("Merge commit has no parents - cannot perform merge-aware diff")
431
+ return False
432
+
433
+ parent_commit = self.commit.parents[0]
434
+
435
+ # Verify parent commit is accessible
436
+ try:
437
+ parent_sha = parent_commit.hexsha
438
+ # Quick validation that parent exists
439
+ self.repo.commit(parent_sha)
440
+ except Exception as parent_error:
441
+ log.error(f"Cannot resolve parent commit {parent_sha}: {parent_error}")
442
+ return False
443
+
444
+ # Use git diff to show changes from parent to merge commit
445
+ diff_range = f'{parent_sha}..{self.commit.hexsha}'
446
+ log.debug(f"Attempting merge commit diff: git diff --name-only {diff_range}")
447
+
448
+ diff_files = self.repo.git.diff('--name-only', diff_range)
449
+ self.show_files = diff_files.splitlines()
450
+
451
+ log.debug(f"Changed files detected via git diff (merge commit): {self.show_files}")
452
+ log.info(f"Changed file detection: method=merge-diff, source=merge-commit-fallback, files={len(self.show_files)}")
453
+ return True
454
+
455
+ except Exception as error:
456
+ log.debug(f"Failed to detect merge commit changes: {error}")
457
+ return False
458
+
383
459
  def get_default_branch_name(self) -> str:
384
460
  """
385
461
  Get the default branch name from the remote origin.
@@ -34,6 +34,22 @@ class OutputHandler:
34
34
  plugin_mgr = PluginManager({"jira": jira_config})
35
35
  plugin_mgr.send(diff_report, config=self.config)
36
36
 
37
+ # Debug Slack webhook configuration when debug is enabled (always show when debug is on)
38
+ if self.config.enable_debug:
39
+ import os
40
+ slack_enabled_env = os.getenv("SOCKET_SLACK_ENABLED", "Not set")
41
+ slack_config_env = os.getenv("SOCKET_SLACK_CONFIG_JSON", "Not set")
42
+ slack_url = "Not configured"
43
+ if self.config.slack_plugin.config and self.config.slack_plugin.config.get("url"):
44
+ slack_url = self.config.slack_plugin.config.get("url")
45
+ self.logger.debug("=== Slack Webhook Debug Information ===")
46
+ self.logger.debug(f"Slack Plugin Enabled: {self.config.slack_plugin.enabled}")
47
+ self.logger.debug(f"SOCKET_SLACK_ENABLED environment variable: {slack_enabled_env}")
48
+ self.logger.debug(f"SOCKET_SLACK_CONFIG_JSON environment variable: {slack_config_env}")
49
+ self.logger.debug(f"Slack Webhook URL: {slack_url}")
50
+ self.logger.debug(f"Slack Alert Levels: {self.config.slack_plugin.levels}")
51
+ self.logger.debug("=====================================")
52
+
37
53
  if self.config.slack_plugin.enabled:
38
54
  slack_config = {
39
55
  "enabled": self.config.slack_plugin.enabled,
@@ -15,9 +15,13 @@ class SlackPlugin(Plugin):
15
15
 
16
16
  def send(self, diff, config: CliConfig):
17
17
  if not self.config.get("enabled", False):
18
+ if config.enable_debug:
19
+ logger.debug("Slack plugin is disabled - skipping webhook notification")
18
20
  return
19
21
  if not self.config.get("url"):
20
22
  logger.warning("Slack webhook URL not configured.")
23
+ if config.enable_debug:
24
+ logger.debug("Slack webhook URL is missing from configuration")
21
25
  return
22
26
  else:
23
27
  url = self.config.get("url")
@@ -31,6 +35,12 @@ class SlackPlugin(Plugin):
31
35
 
32
36
  message = self.create_slack_blocks_from_diff(diff, config)
33
37
  logger.debug(f"Sending message to {url}")
38
+
39
+ if config.enable_debug:
40
+ logger.debug(f"Slack webhook URL: {url}")
41
+ logger.debug(f"Number of alerts to send: {len(diff.new_alerts)}")
42
+ logger.debug(f"Message blocks count: {len(message)}")
43
+
34
44
  response = requests.post(
35
45
  url,
36
46
  json={"blocks": message}
@@ -38,6 +48,8 @@ class SlackPlugin(Plugin):
38
48
 
39
49
  if response.status_code >= 400:
40
50
  logger.error("Slack error %s: %s", response.status_code, response.text)
51
+ elif config.enable_debug:
52
+ logger.debug(f"Slack webhook response: {response.status_code}")
41
53
 
42
54
  @staticmethod
43
55
  def create_slack_blocks_from_diff(diff: Diff, config: CliConfig):
File without changes
File without changes
File without changes
File without changes