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
2 changes: 1 addition & 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.26"
version = "2.2.27"
requires-python = ">= 3.10"
license = {"file" = "LICENSE"}
dependencies = [
Expand Down
2 changes: 1 addition & 1 deletion socketsecurity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__author__ = 'socket.dev'
__version__ = '2.2.26'
__version__ = '2.2.27'
USER_AGENT = f'SocketPythonCLI/{__version__}'
22 changes: 13 additions & 9 deletions socketsecurity/core/scm/gitlab.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os
import sys
from dataclasses import dataclass
from typing import Optional
from typing import Optional, Union

import requests
from socketsecurity import USER_AGENT
from socketsecurity.core import log
from socketsecurity.core.classes import Comment
Expand Down Expand Up @@ -128,9 +129,9 @@ def _request_with_fallback(self, **kwargs):
try:
# Try the initial request with the configured headers
return self.client.request(**kwargs)
except Exception as e:
except requests.exceptions.HTTPError as e:
# Check if this is an authentication error (401)
if hasattr(e, 'response') and e.response and e.response.status_code == 401:
if e.response and e.response.status_code == 401:
log.debug(f"Authentication failed with initial headers, trying fallback method")

# Determine the fallback headers
Expand All @@ -144,6 +145,9 @@ def _request_with_fallback(self, **kwargs):

# Re-raise the original exception if it's not an auth error or fallback failed
raise
except Exception as e:
# Handle other types of exceptions that don't have response attribute
raise

def _get_fallback_headers(self, original_headers: dict) -> dict:
"""
Expand Down Expand Up @@ -235,13 +239,13 @@ def add_socket_comments(
new_security_comment: bool = True,
new_overview_comment: bool = True
) -> None:
existing_overview_comment = comments.get("overview", "")
existing_security_comment = comments.get("security", "")
existing_overview_comment = comments.get("overview")
existing_security_comment = comments.get("security")
if new_overview_comment:
log.debug("New Dependency Overview comment")
if existing_overview_comment is not None:
log.debug("Previous version of Dependency Overview, updating")
existing_overview_comment: Comment
# Type narrowing: after None check, mypy knows this is Comment
self.update_comment(overview_comment, str(existing_overview_comment.id))
else:
log.debug("No previous version of Dependency Overview, posting")
Expand All @@ -250,15 +254,15 @@ def add_socket_comments(
log.debug("New Security Issue Comment")
if existing_security_comment is not None:
log.debug("Previous version of Security Issue comment, updating")
existing_security_comment: Comment
# Type narrowing: after None check, mypy knows this is Comment
self.update_comment(security_comment, str(existing_security_comment.id))
else:
log.debug("No Previous version of Security Issue comment, posting")
self.post_comment(security_comment)

def remove_comment_alerts(self, comments: dict):
security_alert = comments.get("security", "")
security_alert = comments.get("security")
if security_alert is not None:
security_alert: Comment
# Type narrowing: after None check, mypy knows this is Comment
new_body = Comments.process_security_comment(security_alert, comments)
self.update_comment(new_body, str(security_alert.id))
14 changes: 9 additions & 5 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading