Skip to content

Commit 02c8785

Browse files
authored
Version bump (#65)
1 parent b17e947 commit 02c8785

File tree

6 files changed

+74
-48
lines changed

6 files changed

+74
-48
lines changed

Diff for: README.md

+43-42
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Socket Security CLI
22

3-
The Socket Security CLI was created to enable integrations with other tools like Github Actions, Gitlab, BitBucket, local use cases and more. The tool will get the head scan for the provided repo from Socket, create a new one, and then report any new alerts detected. If there are new alerts against the Socket security policy it'll exit with a non-Zero exit code.
3+
The Socket Security CLI was created to enable integrations with other tools like GitHub Actions, Gitlab, BitBucket, local use cases and more. The tool will get the head scan for the provided repo from Socket, create a new one, and then report any new alerts detected. If there are new alerts against the Socket security policy it'll exit with a non-Zero exit code.
44

55
## Usage
66

@@ -18,62 +18,63 @@ If you don't want to provide the Socket API Token every time then you can use th
1818
### Parameters
1919
2020
#### Authentication
21-
| Parameter | Required | Default | Description |
22-
|:-------------|:---------|:--------|:--------------------------------------------------------------------------------------|
23-
| --api-token | False | | Socket Security API token (can also be set via SOCKET_SECURITY_API_KEY env var) |
21+
| Parameter | Required | Default | Description |
22+
|:------------|:---------|:--------|:--------------------------------------------------------------------------------|
23+
| --api-token | False | | Socket Security API token (can also be set via SOCKET_SECURITY_API_KEY env var) |
2424
2525
#### Repository
26-
| Parameter | Required | Default | Description |
27-
|:-------------|:---------|:--------|:-------------------------------------------------------------------------|
28-
| --repo | False | | Repository name in owner/repo format |
29-
| --integration| False | api | Integration type (api, github, gitlab) |
30-
| --owner | False | | Name of the integration owner, defaults to the socket organization slug |
31-
| --branch | False | "" | Branch name |
32-
| --committers | False | | Committer(s) to filter by |
26+
| Parameter | Required | Default | Description |
27+
|:--------------|:---------|:--------|:------------------------------------------------------------------------|
28+
| --repo | False | | Repository name in owner/repo format |
29+
| --integration | False | api | Integration type (api, github, gitlab) |
30+
| --owner | False | | Name of the integration owner, defaults to the socket organization slug |
31+
| --branch | False | "" | Branch name |
32+
| --committers | False | | Committer(s) to filter by |
3333
3434
#### Pull Request and Commit
35-
| Parameter | Required | Default | Description |
36-
|:----------------|:---------|:--------|:-------------------|
37-
| --pr-number | False | "0" | Pull request number|
38-
| --commit-message| False | | Commit message |
39-
| --commit-sha | False | "" | Commit SHA |
35+
| Parameter | Required | Default | Description |
36+
|:-----------------|:---------|:--------|:--------------------|
37+
| --pr-number | False | "0" | Pull request number |
38+
| --commit-message | False | | Commit message |
39+
| --commit-sha | False | "" | Commit SHA |
4040
4141
#### Path and File
42-
| Parameter | Required | Default | Description |
43-
|:-------------|:---------|:--------|:-------------------------------------------|
44-
| --target-path| False | ./ | Target path for analysis |
45-
| --sbom-file | False | | SBOM file path |
46-
| --files | False | [] | Files to analyze (JSON array string) |
42+
| Parameter | Required | Default | Description |
43+
|:--------------|:---------|:--------|:-------------------------------------|
44+
| --target-path | False | ./ | Target path for analysis |
45+
| --sbom-file | False | | SBOM file path |
46+
| --files | False | [] | Files to analyze (JSON array string) |
4747
4848
#### Branch and Scan Configuration
49-
| Parameter | Required | Default | Description |
50-
|:---------------|:---------|:--------|:----------------------------------------------------------|
51-
| --default-branch| False | False | Make this branch the default branch |
52-
| --pending-head | False | False | If true, the new scan will be set as the branch's head scan|
49+
| Parameter | Required | Default | Description |
50+
|:-----------------|:---------|:--------|:------------------------------------------------------------|
51+
| --default-branch | False | False | Make this branch the default branch |
52+
| --pending-head | False | False | If true, the new scan will be set as the branch's head scan |
5353

5454
#### Output Configuration
55-
| Parameter | Required | Default | Description |
56-
|:----------------------|:---------|:--------|:---------------------------------------------------------------|
57-
| --generate-license | False | False | Generate license information |
58-
| --enable-debug | False | False | Enable debug logging |
59-
| --enable-json | False | False | Output in JSON format |
60-
| --enable-sarif | False | False | Enable SARIF output of results instead of table or JSON format|
61-
| --disable-overview | False | False | Disable overview output |
55+
| Parameter | Required | Default | Description |
56+
|:--------------------------|:---------|:--------|:----------------------------------------------------------------------------------|
57+
| --generate-license | False | False | Generate license information |
58+
| --enable-debug | False | False | Enable debug logging |
59+
| --enable-json | False | False | Output in JSON format |
60+
| --enable-sarif | False | False | Enable SARIF output of results instead of table or JSON format |
61+
| --disable-overview | False | False | Disable overview output |
6262
| --exclude-license-details | False | False | Exclude license details from the diff report (boosts performance for large repos) |
6363

6464
#### Security Configuration
65-
| Parameter | Required | Default | Description |
66-
|:-----------------------|:---------|:--------|:-------------------------------|
67-
| --allow-unverified | False | False | Allow unverified packages |
68-
| --disable-security-issue| False | False | Disable security issue checks |
65+
| Parameter | Required | Default | Description |
66+
|:-------------------------|:---------|:--------|:------------------------------|
67+
| --allow-unverified | False | False | Allow unverified packages |
68+
| --disable-security-issue | False | False | Disable security issue checks |
6969

7070
#### Advanced Configuration
71-
| Parameter | Required | Default | Description |
72-
|:-------------------|:---------|:--------|:-----------------------------------------------|
73-
| --ignore-commit-files| False | False | Ignore commit files |
74-
| --disable-blocking | False | False | Disable blocking mode |
75-
| --scm | False | api | Source control management type |
76-
| --timeout | False | | Timeout in seconds for API requests |
71+
| Parameter | Required | Default | Description |
72+
|:-------------------------|:---------|:--------|:----------------------------------------------------------------------|
73+
| --ignore-commit-files | False | False | Ignore commit files |
74+
| --disable-blocking | False | False | Disable blocking mode |
75+
| --scm | False | api | Source control management type |
76+
| --timeout | False | | Timeout in seconds for API requests |
77+
| --include-module-folders | False | False | If enabled will include manifest files from folders like node_modules |
7778

7879
## File Selection Behavior
7980

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.32"
9+
version = "2.0.33"
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.32'
2+
__version__ = '2.0.33'
33

Diff for: socketsecurity/config.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class CliConfig:
3434
pending_head: bool = False
3535
timeout: Optional[int] = 1200
3636
exclude_license_details: bool = False
37+
include_module_folders: bool = False
3738
@classmethod
3839
def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
3940
parser = create_argument_parser()
@@ -73,6 +74,7 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
7374
'pending_head': args.pending_head,
7475
'timeout': args.timeout,
7576
'exclude_license_details': args.exclude_license_details,
77+
'include_module_folders': args.include_module_folders,
7678
}
7779

7880
if args.owner:
@@ -234,7 +236,6 @@ def create_argument_parser() -> argparse.ArgumentParser:
234236
action="store_true",
235237
help=argparse.SUPPRESS
236238
)
237-
238239
# Output Configuration
239240
output_group = parser.add_argument_group('Output Configuration')
240241
output_group.add_argument(
@@ -351,5 +352,12 @@ def create_argument_parser() -> argparse.ArgumentParser:
351352
help="Timeout in seconds for API requests",
352353
required=False
353354
)
355+
config_group.add_argument(
356+
"--include-module-folders",
357+
dest="include_module_folders",
358+
action="store_true",
359+
default=False,
360+
help="Enabling including module folders like node_modules"
361+
)
354362

355363
return parser

Diff for: socketsecurity/core/__init__.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ def expand_brace_pattern(pattern: str) -> List[str]:
146146

147147
return expanded_patterns
148148

149+
@staticmethod
150+
def is_excluded(file_path: str, excluded_dirs: Set[str]) -> bool:
151+
parts = os.path.normpath(file_path).split(os.sep)
152+
for part in parts:
153+
if part in excluded_dirs:
154+
return True
155+
return False
156+
149157
def find_files(self, path: str) -> List[str]:
150158
"""
151159
Finds supported manifest files in the given path.
@@ -186,7 +194,7 @@ def find_files(self, path: str) -> List[str]:
186194
glob_files = glob(file_path, recursive=True)
187195

188196
for glob_file in glob_files:
189-
if os.path.isfile(glob_file):
197+
if os.path.isfile(glob_file) and not Core.is_excluded(glob_file, self.config.excluded_dirs):
190198
files.add(glob_file)
191199

192200
glob_end = time.time()

Diff for: socketsecurity/core/socket_config.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
from dataclasses import dataclass
1+
from dataclasses import dataclass, field
22
from typing import Dict, Optional
33
from urllib.parse import urlparse
4+
from typing import Set
45
import os
56

67
from socketsecurity.core.issues import AllIssues
78

89

10+
default_exclude_dirs = {
11+
"node_modules", "bower_components", "jspm_packages", # JS/TS
12+
"__pycache__", ".venv", "venv", "build", "dist", # Python
13+
".tox", ".mypy_cache", ".pytest_cache", "*.egg-info",
14+
"vendor"
15+
}
16+
917
@dataclass
1018
class SocketConfig:
1119
api_key: str
@@ -18,6 +26,7 @@ class SocketConfig:
1826
repository_path: Optional[str] = None
1927
security_policy: Dict = None
2028
all_issues: Optional['AllIssues'] = None
29+
excluded_dirs: Set[str] = field(default_factory=lambda: default_exclude_dirs)
2130

2231
def __post_init__(self):
2332
"""Validate configuration after initialization"""
@@ -45,7 +54,7 @@ def _validate_api_url(url: str) -> None:
4554
parsed = urlparse(url)
4655
if not all([parsed.scheme, parsed.netloc]):
4756
raise ValueError("Invalid URL format")
48-
if parsed.scheme != "https":
57+
if parsed.scheme != "https" and os.getenv("RUN_ENVIRONMENT", 'prod') != "dev":
4958
raise ValueError("API URL must use HTTPS")
5059
except Exception as e:
5160
raise ValueError(f"Invalid API URL: {str(e)}")

0 commit comments

Comments
 (0)