Skip to content

Added 'api' event type to Gitlab and added new option --license-file-… #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ If you don't want to provide the Socket API Token every time then you can use th
| --commit-sha | False | "" | Commit SHA |

#### Path and File
| Parameter | Required | Default | Description |
|:----------------------|:---------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| --target-path | False | ./ | Target path for analysis |
| --sbom-file | False | | SBOM file path |
| --files | False | [] | Files to analyze (JSON array string) |
| --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) |
| Parameter | Required | Default | Description |
|:----------------------|:---------|:----------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| --target-path | False | ./ | Target path for analysis |
| --sbom-file | False | | SBOM file path |
| --files | False | [] | Files to analyze (JSON array string) |
| --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) |
| --license-file-name | False | `license_output.json` | Name of the file to save the license details to if enabled |

#### Branch and Scan Configuration
| Parameter | Required | Default | Description |
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "hatchling.build"

[project]
name = "socketsecurity"
version = "2.1.19"
version = "2.1.21"
requires-python = ">= 3.10"
license = {"file" = "LICENSE"}
dependencies = [
Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pytest-watch==4.2.0
# via socketsecurity
python-dotenv==1.0.1
# via socketsecurity
requests==2.32.3
requests==2.32.4
# via socket-sdk-python
# via socketsecurity
smmap==5.0.2
Expand All @@ -65,7 +65,7 @@ socket-sdk-python==2.0.15
# via socketsecurity
typing-extensions==4.12.2
# via socket-sdk-python
urllib3==2.3.0
urllib3==2.5.0
# via requests
watchdog==6.0.0
# via pytest-watch
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pytest-watch==4.2.0
# via socketsecurity
python-dotenv==1.0.1
# via socketsecurity
requests==2.32.3
requests==2.32.4
# via socket-sdk-python
# via socketsecurity
smmap==5.0.2
Expand All @@ -63,7 +63,7 @@ socket-sdk-python==2.1.5
# via socketsecurity
typing-extensions==4.12.2
# via socket-sdk-python
urllib3==2.3.0
urllib3==2.5.0
# via requests
watchdog==6.0.0
# via pytest-watch
Expand Down
2 changes: 1 addition & 1 deletion socketsecurity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__author__ = 'socket.dev'
__version__ = '2.1.19'
__version__ = '2.1.21'
9 changes: 9 additions & 0 deletions socketsecurity/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class CliConfig:
version: str = __version__
jira_plugin: PluginConfig = field(default_factory=PluginConfig)
slack_plugin: PluginConfig = field(default_factory=PluginConfig)
license_file_name: str = "license_output.json"

@classmethod
def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
Expand Down Expand Up @@ -99,6 +100,7 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig':
'include_module_folders': args.include_module_folders,
'repo_is_public': args.repo_is_public,
"excluded_ecosystems": args.excluded_ecosystems,
'license_file_name': args.license_file_name,
'version': __version__
}
try:
Expand Down Expand Up @@ -253,6 +255,13 @@ def create_argument_parser() -> argparse.ArgumentParser:
dest="sbom_file",
help=argparse.SUPPRESS
)
path_group.add_argument(
"--license-file-name",
dest="license_file_name",
default="license_output.json",
metavar="<string>",
help="SBOM file path"
)
path_group.add_argument(
"--files",
metavar="<json>",
Expand Down
2 changes: 1 addition & 1 deletion socketsecurity/core/scm/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self, client: CliClient, config: Optional[GitlabConfig] = None):

def check_event_type(self) -> str:
pipeline_source = self.config.pipeline_source.lower()
if pipeline_source in ["web", 'merge_request_event', "push"]:
if pipeline_source in ["web", 'merge_request_event', "push", "api"]:
if not self.config.mr_iid:
return "main"
return "diff"
Expand Down
6 changes: 1 addition & 5 deletions socketsecurity/socketcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,7 @@ def main_code():
"purl": package.purl,
}
all_packages[package.id] = output
license_file = f"{config.repo}"
if config.branch:
license_file += f"_{config.branch}"
license_file += ".json"
core.save_file(license_file, json.dumps(all_packages))
core.save_file(config.license_file_name, json.dumps(all_packages))

sys.exit(output_handler.return_exit_code(diff))

Expand Down
Loading