Skip to content

Updated version #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2025
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.0.35"
version = "2.0.36"
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.0.35'
__version__ = '2.0.36'

9 changes: 9 additions & 0 deletions socketsecurity/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
from dataclasses import asdict, dataclass
from typing import List, Optional
from socketdev import __version__

from socketdev import INTEGRATION_TYPES, IntegrationType

Expand Down Expand Up @@ -35,6 +36,7 @@ class CliConfig:
timeout: Optional[int] = 1200
exclude_license_details: bool = False
include_module_folders: bool = False
version: str = __version__
@classmethod
def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
parser = create_argument_parser()
Expand Down Expand Up @@ -75,6 +77,7 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
'timeout': args.timeout,
'exclude_license_details': args.exclude_license_details,
'include_module_folders': args.include_module_folders,
'version': __version__
}

if args.owner:
Expand Down Expand Up @@ -360,4 +363,10 @@ def create_argument_parser() -> argparse.ArgumentParser:
help="Enabling including module folders like node_modules"
)

parser.add_argument(
'--version',
action='version',
version=f'%(prog)s {__version__}'
)

return parser
21 changes: 14 additions & 7 deletions socketsecurity/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
)
from socketsecurity.core.exceptions import APIResourceNotFound
from socketsecurity.core.licenses import Licenses

from .socket_config import SocketConfig
from .utils import socket_globs
import importlib
logging_std = importlib.import_module("logging")


__all__ = [
"Core",
Expand Down Expand Up @@ -375,11 +377,12 @@ def create_packages_dict(self, sbom_artifacts: list[SocketArtifact]) -> dict[str
else:
package.license_text = self.get_package_license_text(package)
packages[package.id] = package
for top_id in package.topLevelAncestors:
if top_id not in top_level_count:
top_level_count[top_id] = 1
else:
top_level_count[top_id] += 1
if package.topLevelAncestors:
for top_id in package.topLevelAncestors:
if top_id not in top_level_count:
top_level_count[top_id] = 1
else:
top_level_count[top_id] += 1

for package_id, package in packages.items():
package.transitives = top_level_count.get(package_id, 0)
Expand Down Expand Up @@ -424,10 +427,14 @@ def get_repo_info(self, repo_slug: str, default_branch: str = "socket-default-br
Exception: If API request fails
"""
try:
sdk_logger = logging_std.getLogger("socketdev")
original_level = sdk_logger.level
sdk_logger.setLevel(logging_std.CRITICAL)
response = self.sdk.repos.repo(self.config.org_slug, repo_slug, use_types=True)
sdk_logger.setLevel(original_level)
if not response.success:
log.error(f"Failed to get repository: {response.status}")
log.error(response.message)
# log.error(response.message)
except APIFailure:
log.warning(f"Failed to get repository {repo_slug}, attempting to create it")
try:
Expand Down
Loading