Skip to content

Commit 9a1d030

Browse files
authored
Added 'api' event type to Gitlab and added new option --license-file-… (#100)
* Added 'api' event type to Gitlab and added new option --license-file-name that defaults to license_output.json instead of a dynamic name that could be a bad filename * Bumped dependencies
1 parent 1717d0a commit 9a1d030

File tree

8 files changed

+24
-18
lines changed

8 files changed

+24
-18
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ If you don't want to provide the Socket API Token every time then you can use th
4040
| --commit-sha | False | "" | Commit SHA |
4141
4242
#### Path and File
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-
| --excluded-ecosystems | False | [] | List of ecosystems to exclude from analysis (JSON array string). You can get supported files from the [Supported Files API](https://docs.socket.dev/reference/getsupportedfiles) |
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+
| --excluded-ecosystems | False | [] | List of ecosystems to exclude from analysis (JSON array string). You can get supported files from the [Supported Files API](https://docs.socket.dev/reference/getsupportedfiles) |
49+
| --license-file-name | False | `license_output.json` | Name of the file to save the license details to if enabled |
4950
5051
#### Branch and Scan Configuration
5152
| Parameter | Required | Default | Description |

pyproject.toml

Lines changed: 1 addition & 1 deletion
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.1.19"
9+
version = "2.1.21"
1010
requires-python = ">= 3.10"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

requirements-dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pytest-watch==4.2.0
5656
# via socketsecurity
5757
python-dotenv==1.0.1
5858
# via socketsecurity
59-
requests==2.32.3
59+
requests==2.32.4
6060
# via socket-sdk-python
6161
# via socketsecurity
6262
smmap==5.0.2
@@ -65,7 +65,7 @@ socket-sdk-python==2.0.15
6565
# via socketsecurity
6666
typing-extensions==4.12.2
6767
# via socket-sdk-python
68-
urllib3==2.3.0
68+
urllib3==2.5.0
6969
# via requests
7070
watchdog==6.0.0
7171
# via pytest-watch

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pytest-watch==4.2.0
5454
# via socketsecurity
5555
python-dotenv==1.0.1
5656
# via socketsecurity
57-
requests==2.32.3
57+
requests==2.32.4
5858
# via socket-sdk-python
5959
# via socketsecurity
6060
smmap==5.0.2
@@ -63,7 +63,7 @@ socket-sdk-python==2.1.5
6363
# via socketsecurity
6464
typing-extensions==4.12.2
6565
# via socket-sdk-python
66-
urllib3==2.3.0
66+
urllib3==2.5.0
6767
# via requests
6868
watchdog==6.0.0
6969
# via pytest-watch

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.1.19'
2+
__version__ = '2.1.21'

socketsecurity/config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class CliConfig:
5656
version: str = __version__
5757
jira_plugin: PluginConfig = field(default_factory=PluginConfig)
5858
slack_plugin: PluginConfig = field(default_factory=PluginConfig)
59+
license_file_name: str = "license_output.json"
5960

6061
@classmethod
6162
def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
@@ -99,6 +100,7 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
99100
'include_module_folders': args.include_module_folders,
100101
'repo_is_public': args.repo_is_public,
101102
"excluded_ecosystems": args.excluded_ecosystems,
103+
'license_file_name': args.license_file_name,
102104
'version': __version__
103105
}
104106
try:
@@ -253,6 +255,13 @@ def create_argument_parser() -> argparse.ArgumentParser:
253255
dest="sbom_file",
254256
help=argparse.SUPPRESS
255257
)
258+
path_group.add_argument(
259+
"--license-file-name",
260+
dest="license_file_name",
261+
default="license_output.json",
262+
metavar="<string>",
263+
help="SBOM file path"
264+
)
256265
path_group.add_argument(
257266
"--files",
258267
metavar="<json>",

socketsecurity/core/scm/gitlab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(self, client: CliClient, config: Optional[GitlabConfig] = None):
7171

7272
def check_event_type(self) -> str:
7373
pipeline_source = self.config.pipeline_source.lower()
74-
if pipeline_source in ["web", 'merge_request_event', "push"]:
74+
if pipeline_source in ["web", 'merge_request_event', "push", "api"]:
7575
if not self.config.mr_iid:
7676
return "main"
7777
return "diff"

socketsecurity/socketcli.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,7 @@ def main_code():
277277
"purl": package.purl,
278278
}
279279
all_packages[package.id] = output
280-
license_file = f"{config.repo}"
281-
if config.branch:
282-
license_file += f"_{config.branch}"
283-
license_file += ".json"
284-
core.save_file(license_file, json.dumps(all_packages))
280+
core.save_file(config.license_file_name, json.dumps(all_packages))
285281

286282
sys.exit(output_handler.return_exit_code(diff))
287283

0 commit comments

Comments
 (0)