Skip to content

Commit e250d14

Browse files
authored
Added support for exlcuded ecosystems (#81)
1 parent de2b480 commit e250d14

File tree

7 files changed

+37
-15
lines changed

7 files changed

+37
-15
lines changed

README.md

+14-12
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ If you don't want to provide the Socket API Token every time then you can use th
2323
| --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 |
33+
| --repo-is-public | False | False | If set, flags a new repository creation as public. Defaults to false. |
3334
3435
#### Pull Request and Commit
3536
| Parameter | Required | Default | Description |
@@ -39,11 +40,12 @@ If you don't want to provide the Socket API Token every time then you can use th
3940
| --commit-sha | False | "" | Commit SHA |
4041
4142
#### 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) |
43+
| Parameter | Required | Default | Description |
44+
|:-------------------|:---------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
45+
| --target-path | False | ./ | Target path for analysis |
46+
| --sbom-file | False | | SBOM file path |
47+
| --files | False | [] | Files to analyze (JSON array string) |
48+
| --exclude-patterns | False | [] | List of patterns to exclude from analysis (JSON array string). You can get supported files form the [Supported Files API](https://docs.socket.dev/reference/getsupportedfiles) |
4749
4850
#### Branch and Scan Configuration
4951
| Parameter | Required | Default | Description |

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.55"
9+
version = "2.0.56"
1010
requires-python = ">= 3.10"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

socketsecurity/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__author__ = 'socket.dev'
2-
__version__ = '2.0.55'
2+
__version__ = '2.0.56'

socketsecurity/config.py

+15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import logging
23
import os
34
from dataclasses import asdict, dataclass, field
45
from typing import List, Optional
@@ -51,6 +52,7 @@ class CliConfig:
5152
exclude_license_details: bool = False
5253
include_module_folders: bool = False
5354
repo_is_public: bool = False
55+
excluded_ecosystems: list[str] = field(default_factory=lambda: [])
5456
version: str = __version__
5557
jira_plugin: PluginConfig = field(default_factory=PluginConfig)
5658
slack_plugin: PluginConfig = field(default_factory=PluginConfig)
@@ -96,8 +98,14 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
9698
'exclude_license_details': args.exclude_license_details,
9799
'include_module_folders': args.include_module_folders,
98100
'repo_is_public': args.repo_is_public,
101+
"excluded_ecosystems": args.excluded_ecosystems,
99102
'version': __version__
100103
}
104+
try:
105+
config_args["excluded_ecosystems"] = json.loads(config_args["excluded_ecosystems"].replace("'", '"'))
106+
except json.JSONDecodeError:
107+
logging.error(f"Unable to parse excluded_ecosystems: {config_args['excluded_ecosystems']}")
108+
exit(1)
101109
config_args.update({
102110
"jira_plugin": PluginConfig(
103111
enabled=os.getenv("SOCKET_JIRA_ENABLED", "false").lower() == "true",
@@ -252,6 +260,13 @@ def create_argument_parser() -> argparse.ArgumentParser:
252260
help="Files to analyze (JSON array string)"
253261
)
254262

263+
path_group.add_argument(
264+
"--excluded-ecosystems",
265+
default="[]",
266+
dest="excluded_ecosystems",
267+
help="List of ecosystems to exclude from analysis (JSON array string)"
268+
)
269+
255270
# Branch and Scan Configuration
256271
config_group = parser.add_argument_group('Branch and Scan Configuration')
257272
config_group.add_argument(

socketsecurity/core/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ def find_files(self, path: str) -> List[str]:
184184
patterns = fallback_patterns
185185

186186
for ecosystem in patterns:
187+
if ecosystem in self.config.excluded_ecosystems:
188+
continue
187189
ecosystem_patterns = patterns[ecosystem]
188190
for file_name in ecosystem_patterns:
189191
original_pattern = ecosystem_patterns[file_name]["pattern"]

socketsecurity/core/socket_config.py

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

77
from socketsecurity.core.issues import AllIssues
@@ -29,6 +29,7 @@ class SocketConfig:
2929
repo_visibility: Optional[str] = 'private'
3030
all_issues: Optional['AllIssues'] = None
3131
excluded_dirs: Set[str] = field(default_factory=lambda: default_exclude_dirs)
32+
excluded_ecosystems: List[str] = field(default_factory=lambda: [])
3233
version: str = __version__
3334

3435
def __post_init__(self):

socketsecurity/socketcli.py

+2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ def main_code():
150150
org_slug = core.config.org_slug
151151
if config.repo_is_public:
152152
core.config.repo_visibility = "public"
153+
if config.excluded_ecosystems and len(config.excluded_ecosystems) > 0:
154+
core.config.excluded_ecosystems = config.excluded_ecosystems
153155
integration_type = config.integration_type
154156
integration_org_slug = config.integration_org_slug or org_slug
155157
try:

0 commit comments

Comments
 (0)