diff --git a/README.rst b/README.rst index 32e6c48..7d5da25 100644 --- a/README.rst +++ b/README.rst @@ -201,8 +201,8 @@ Delete an existing full scan. - **org_slug (str)** - The organization name - **full_scan_id (str)** - The ID of the full scan -fullscans.stream_diff(org_slug, before, after, preview) -""""""""""""""""""""""""""""""""""""""""""""""""""""""" +fullscans.stream_diff(org_slug, before, after, preview, include_license_details) +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" Stream a diff between two full scans. Returns a scan diff. **Usage:** @@ -218,7 +218,7 @@ Stream a diff between two full scans. Returns a scan diff. - **org_slug (str)** - The organization name - **before (str)** - The base full scan ID - **after (str)** - The comparison full scan ID -- **preview (bool)** - Create a diff-scan that is not persisted. Defaults to False +- **include_license_details (bool)** - Include license details. Can greatly increase response size. Defaults to False. fullscans.stream(org_slug, full_scan_id) """""""""""""""""""""""""""""""""""""""" diff --git a/socketdev/fullscans/__init__.py b/socketdev/fullscans/__init__.py index 68175ae..30b3955 100644 --- a/socketdev/fullscans/__init__.py +++ b/socketdev/fullscans/__init__.py @@ -486,6 +486,16 @@ def from_dict(cls, data: dict) -> "DiffArtifact": score_data = data.get("score") or data.get("scores") score = SocketScore.from_dict(score_data) if score_data else None + license_details_source = data.get("licenseDetails") + if license_details_source: + license_details = [LicenseDetail.from_dict(detail) for detail in license_details_source] + else: + license_details = [] + license_attrib_source = data.get("licenseAttrib") + if license_attrib_source: + license_attrib = [LicenseAttribution.from_dict(attrib) for attrib in license_attrib_source] + else: + license_attrib = [] return cls( diffType=DiffType(data["diffType"]), @@ -495,7 +505,7 @@ def from_dict(cls, data: dict) -> "DiffArtifact": score=score, version=data["version"], alerts=[SocketAlert.from_dict(alert) for alert in data.get("alerts", [])], - licenseDetails=[LicenseDetail.from_dict(detail) for detail in data["licenseDetails"]], + licenseDetails=license_details, files=data.get("files"), license=data.get("license"), capabilities=SecurityCapabilities.from_dict(data["capabilities"]) if data.get("capabilities") else None, @@ -510,7 +520,7 @@ def from_dict(cls, data: dict) -> "DiffArtifact": author=data.get("author", []), state=data.get("state"), error=data.get("error"), - licenseAttrib=[LicenseAttribution.from_dict(attrib) for attrib in data["licenseAttrib"]] + licenseAttrib=license_attrib if data.get("licenseAttrib") else None, ) @@ -766,9 +776,18 @@ def delete(self, org_slug: str, full_scan_id: str) -> dict: return {} def stream_diff( - self, org_slug: str, before: str, after: str, use_types: bool = False + self, + org_slug: str, + before: str, + after: str, + use_types: bool = True, + include_license_details: bool = False, + **kwargs, ) -> Union[dict, StreamDiffResponse]: - path = f"orgs/{org_slug}/full-scans/diff?before={before}&after={after}" + path = f"orgs/{org_slug}/full-scans/diff?before={before}&after={after}&{include_license_details}" + if kwargs: + for key, value in kwargs.items(): + path += f"&{key}={value}" response = self.api.do_request(path=path, method="GET") diff --git a/socketdev/version.py b/socketdev/version.py index 61663da..9d85eb1 100644 --- a/socketdev/version.py +++ b/socketdev/version.py @@ -1 +1 @@ -__version__ = "2.0.10" +__version__ = "2.0.11"