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.
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/PKG-INFO +1 -1
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/pyproject.toml +2 -1
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/__init__.py +1 -1
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/git_interface.py +78 -2
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/output.py +16 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/slack.py +12 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/CODEOWNERS +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/PULL_REQUEST_TEMPLATE/bug-fix.md +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/PULL_REQUEST_TEMPLATE/improvement.md +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/workflows/docker-stable.yml +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/workflows/pr-preview.yml +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/workflows/release.yml +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.github/workflows/version-check.yml +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.gitignore +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.hooks/sync_version.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.pre-commit-config.yaml +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/.python-version +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/Dockerfile +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/LICENSE +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/Makefile +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/Pipfile.lock +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/README.md +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/docs/README.md +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/pytest.ini +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/scripts/build_container.sh +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/scripts/deploy-test-docker.sh +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/scripts/deploy-test-pypi.sh +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/scripts/run.sh +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/config.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/__init__.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/classes.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/cli_client.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/exceptions.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/helper/__init__.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/lazy_file_loader.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/logging.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/messages.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/resource_utils.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/scm/__init__.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/scm/base.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/scm/client.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/scm/github.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/scm/gitlab.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/scm_comments.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/socket_config.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/core/utils.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/__init__.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/base.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/jira.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/manager.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/teams.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/plugins/webhook.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/socketsecurity/socketcli.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/__init__.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/core/conftest.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/core/create_diff_input.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/core/test_diff_generation.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/core/test_package_and_alerts.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/core/test_sdk_methods.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/core/test_supporting_methods.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/create_response.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/diff/stream_diff.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/diff/stream_diff_full.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/head_scan/metadata.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/head_scan/stream_scan.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/head_scan/stream_scan_full.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/new_scan/metadata.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/new_scan/stream_scan.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/repos/repo_info_error.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/repos/repo_info_no_head.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/repos/repo_info_success.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/settings/security-policy.json +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/__init__.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/test_cli_config.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/test_client.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/test_config.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/test_gitlab_auth.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/test_gitlab_auth_fallback.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/unit/test_output.py +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/uv.lock +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/workflows/bitbucket-pipelines.yml +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/workflows/github-actions.yml +0 -0
- {socketsecurity-2.2.5 → socketsecurity-2.2.7}/workflows/gitlab-ci.yml +0 -0
|
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "socketsecurity"
|
|
9
|
-
version = "2.2.
|
|
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.
|
|
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
|
-
|
|
222
|
-
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/diff/stream_diff_full.json
RENAMED
|
File without changes
|
|
File without changes
|
{socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/head_scan/stream_scan.json
RENAMED
|
File without changes
|
{socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/head_scan/stream_scan_full.json
RENAMED
|
File without changes
|
|
File without changes
|
{socketsecurity-2.2.5 → socketsecurity-2.2.7}/tests/data/fullscans/new_scan/stream_scan.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|