Skip to content

Commit d6e97a4

Browse files
authored
Bumped version for release (#66)
1 parent 02c8785 commit d6e97a4

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

Diff for: pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.0.33"
9+
version = "2.0.34"
1010
requires-python = ">= 3.10"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

Diff for: socketsecurity/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.0.33'
2+
__version__ = '2.0.34'
33

Diff for: socketsecurity/core/__init__.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,17 @@ def get_org_id_slug(self) -> Tuple[str, str]:
8282
return org_id, organizations[org_id]['slug']
8383
return None, None
8484

85-
def get_sbom_data(self, full_scan_id: str) -> Dict[str, SocketArtifact]:
85+
def get_sbom_data(self, full_scan_id: str) -> List[SocketArtifact]:
8686
"""Returns the list of SBOM artifacts for a full scan."""
8787
response = self.sdk.fullscans.stream(self.config.org_slug, full_scan_id, use_types=True)
88+
artifacts: List[SocketArtifact] = []
8889
if not response.success:
8990
log.debug(f"Failed to get SBOM data for full-scan {full_scan_id}")
9091
log.debug(response.message)
9192
return {}
92-
93-
return response.artifacts
93+
for artifact_id in response.artifacts:
94+
artifacts.append(response.artifacts[artifact_id])
95+
return artifacts
9496

9597
def get_sbom_data_list(self, artifacts_dict: Dict[str, SocketArtifact]) -> list[SocketArtifact]:
9698
"""Converts artifacts dictionary to a list."""
@@ -326,8 +328,7 @@ def create_full_scan(self, files: List[str], params: FullScanParams, has_head_sc
326328

327329
full_scan = FullScan(**asdict(res.data))
328330
if not has_head_scan:
329-
full_scan_artifacts_dict = self.get_sbom_data(full_scan.id)
330-
full_scan.sbom_artifacts = self.get_sbom_data_list(full_scan_artifacts_dict)
331+
full_scan.sbom_artifacts = self.get_sbom_data(full_scan.id)
331332
full_scan.packages = self.create_packages_dict(full_scan.sbom_artifacts)
332333

333334
create_full_end = time.time()
@@ -436,7 +437,8 @@ def get_repo_info(self, repo_slug: str, default_branch: str = "socket-default-br
436437
log.error("Failed to create repository: empty response")
437438
raise Exception("Failed to create repository: empty response")
438439
else:
439-
return create_response
440+
response = self.sdk.repos.repo(self.config.org_slug, repo_slug, use_types=True)
441+
return response.data
440442

441443
except APIFailure as e:
442444
log.error(f"API failure while creating repository: {e}")
@@ -554,22 +556,23 @@ def create_new_diff(
554556
# Find manifest files
555557
files = self.find_files(path)
556558
files_for_sending = self.load_files_for_sending(files, path)
557-
559+
has_head_scan = False
558560
if not files:
559561
return Diff(id="no_diff_id")
560562

561563
try:
562564
# Get head scan ID
563565
head_full_scan_id = self.get_head_scan_for_repo(params.repo)
564-
has_head_scan = True
566+
if head_full_scan_id is not None:
567+
has_head_scan = True
565568
except APIResourceNotFound:
566569
head_full_scan_id = None
567-
has_head_scan = False
568570

569571
# Create new scan
570572
try:
571573
new_scan_start = time.time()
572574
new_full_scan = self.create_full_scan(files_for_sending, params, has_head_scan)
575+
new_full_scan.sbom_artifacts = self.get_sbom_data(new_full_scan.id)
573576
new_scan_end = time.time()
574577
log.info(f"Total time to create new full scan: {new_scan_end - new_scan_start:.2f}")
575578
except APIFailure as e:

Diff for: socketsecurity/core/classes.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ def from_socket_artifact(cls, data: dict) -> "Package":
138138
Returns:
139139
New Package instance
140140
"""
141+
purl = f"{data['type']}/"
142+
namespace = data.get("namespace")
143+
if namespace:
144+
purl += f"{namespace}@"
145+
purl += f"{data['name']}@{data['version']}"
146+
base_url = "https://socket.dev"
147+
url = f"{base_url}/{data['type']}/package/{namespace or ''}{data['name']}/overview/{data['version']}"
141148
return cls(
142149
id=data["id"],
143150
name=data["name"],
@@ -152,7 +159,10 @@ def from_socket_artifact(cls, data: dict) -> "Package":
152159
direct=data.get("direct", False),
153160
manifestFiles=data.get("manifestFiles", []),
154161
dependencies=data.get("dependencies"),
155-
artifact=data.get("artifact")
162+
artifact=data.get("artifact"),
163+
purl=purl,
164+
url=url,
165+
namespace=namespace
156166
)
157167

158168
@classmethod

0 commit comments

Comments
 (0)