Skip to content

Commit 8979844

Browse files
committed
cleaned up license_details hack
1 parent 1c8b20e commit 8979844

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ socketcli [-h] [--api-token API_TOKEN] [--repo REPO] [--integration {api,github,
1010
[--target-path TARGET_PATH] [--sbom-file SBOM_FILE] [--files FILES] [--default-branch] [--pending-head]
1111
[--generate-license] [--enable-debug] [--enable-json] [--enable-sarif] [--disable-overview] [--disable-security-issue]
1212
[--allow-unverified] [--ignore-commit-files] [--disable-blocking] [--scm SCM] [--timeout TIMEOUT]
13+
[--exclude-license-details]
1314
````
1415

1516
If you don't want to provide the Socket API Token every time then you can use the environment variable `SOCKET_SECURITY_API_KEY`
@@ -58,6 +59,7 @@ If you don't want to provide the Socket API Token every time then you can use th
5859
| --enable-json | False | False | Output in JSON format |
5960
| --enable-sarif | False | False | Enable SARIF output of results instead of table or JSON format|
6061
| --disable-overview | False | False | Disable overview output |
62+
| --exclude-license-details | False | False | Exclude license details from the diff report (boosts performance for large repos) |
6163

6264
#### Security Configuration
6365
| Parameter | Required | Default | Description |

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.0.6'
2+
__version__ = '2.0.7'

socketsecurity/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class CliConfig:
3333
integration_org_slug: Optional[str] = None
3434
pending_head: bool = False
3535
timeout: Optional[int] = 1200
36+
exclude_license_details: bool = False
3637
@classmethod
3738
def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
3839
parser = create_argument_parser()
@@ -71,6 +72,7 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
7172
'integration_type': args.integration,
7273
'pending_head': args.pending_head,
7374
'timeout': args.timeout,
75+
'exclude_license_details': args.exclude_license_details,
7476
}
7577

7678
if args.owner:
@@ -283,6 +285,12 @@ def create_argument_parser() -> argparse.ArgumentParser:
283285
action="store_true",
284286
help=argparse.SUPPRESS
285287
)
288+
output_group.add_argument(
289+
"--exclude-license-details",
290+
dest="exclude_license_details",
291+
action="store_true",
292+
help="Exclude license details from the diff report (boosts performance for large repos)"
293+
)
286294

287295
# Security Configuration
288296
security_group = parser.add_argument_group('Security Configuration')

socketsecurity/core/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ def create_new_diff(
462462
has_head_scan = False
463463

464464
# Create new scan
465-
params.include_license_details = False
466465
new_scan_start = time.time()
467466
new_full_scan = self.create_full_scan(files_for_sending, params, has_head_scan)
468467
new_scan_end = time.time()
@@ -479,7 +478,12 @@ def create_new_diff(
479478

480479
base_socket = "https://socket.dev/dashboard/org"
481480
diff.id = new_full_scan.id
482-
diff.report_url = f"{base_socket}/{self.config.org_slug}/sbom/{diff.id}?include_license_details=false"
481+
482+
report_url = f"{base_socket}/{self.config.org_slug}/sbom/{diff.id}"
483+
if not params.include_license_details:
484+
report_url += "?include_license_details=false"
485+
diff.report_url = report_url
486+
483487
if head_full_scan_id is not None:
484488
diff.diff_url = f"{base_socket}/{self.config.org_slug}/diff/{diff.id}/{head_full_scan_id}"
485489
else:

socketsecurity/socketcli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ def main_code():
160160
set_as_pending_head=True
161161
)
162162

163+
params.include_license_details = not config.exclude_license_details
164+
163165
# Initialize diff
164166
diff = Diff()
165167
diff.id = "NO_DIFF_RAN"

0 commit comments

Comments
 (0)