diff --git a/pyproject.toml b/pyproject.toml index 1799b19..1808d35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "socketsecurity" -version = "2.0.54" +version = "2.0.55" requires-python = ">= 3.10" license = {"file" = "LICENSE"} dependencies = [ diff --git a/socketsecurity/__init__.py b/socketsecurity/__init__.py index 92958d3..3791e05 100644 --- a/socketsecurity/__init__.py +++ b/socketsecurity/__init__.py @@ -1,2 +1,2 @@ __author__ = 'socket.dev' -__version__ = '2.0.54' +__version__ = '2.0.55' diff --git a/socketsecurity/config.py b/socketsecurity/config.py index 007eae2..5542402 100644 --- a/socketsecurity/config.py +++ b/socketsecurity/config.py @@ -50,6 +50,7 @@ class CliConfig: timeout: Optional[int] = 1200 exclude_license_details: bool = False include_module_folders: bool = False + repo_is_public: bool = False version: str = __version__ jira_plugin: PluginConfig = field(default_factory=PluginConfig) slack_plugin: PluginConfig = field(default_factory=PluginConfig) @@ -94,6 +95,7 @@ def from_args(cls, args_list: Optional[List[str]] = None) -> 'CliConfig': 'timeout': args.timeout, 'exclude_license_details': args.exclude_license_details, 'include_module_folders': args.include_module_folders, + 'repo_is_public': args.repo_is_public, 'version': __version__ } config_args.update({ @@ -147,30 +149,32 @@ def create_argument_parser() -> argparse.ArgumentParser: required=False ) repo_group.add_argument( + "--repo-is-public", + dest="repo_is_public", + action="store_true", + help="If set it will flag a new repository creation as public. Defaults to false." + ) + repo_group.add_argument( + "--branch", + metavar="", + help="Branch name", + default="" + ) + + integration_group = parser.add_argument_group('Integration') + integration_group.add_argument( "--integration", choices=INTEGRATION_TYPES, metavar="", - help="Integration type", + help="Integration type of api, github, gitlab, azure, or bitbucket. Defaults to api", default="api" ) - repo_group.add_argument( + integration_group.add_argument( "--owner", metavar="", help="Name of the integration owner, defaults to the socket organization slug", required=False ) - repo_group.add_argument( - "--branch", - metavar="", - help="Branch name", - default="" - ) - repo_group.add_argument( - "--committers", - metavar="", - help="Committer(s) to filter by", - nargs="*" - ) # Pull Request and Commit info pr_group = parser.add_argument_group('Pull Request and Commit') @@ -209,6 +213,12 @@ def create_argument_parser() -> argparse.ArgumentParser: dest="commit_sha", help=argparse.SUPPRESS ) + pr_group.add_argument( + "--committers", + metavar="", + help="Committer for the commit (comma separated)", + nargs="*" + ) # Path and File options path_group = parser.add_argument_group('Path and File') diff --git a/socketsecurity/core/__init__.py b/socketsecurity/core/__init__.py index 007af25..7329ea7 100644 --- a/socketsecurity/core/__init__.py +++ b/socketsecurity/core/__init__.py @@ -439,7 +439,12 @@ def get_repo_info(self, repo_slug: str, default_branch: str = "socket-default-br log.warning(f"Failed to get repository {repo_slug}, attempting to create it") try: - create_response = self.sdk.repos.post(self.config.org_slug, name=repo_slug, default_branch=default_branch) + create_response = self.sdk.repos.post( + self.config.org_slug, + name=repo_slug, + default_branch=default_branch, + visibility=self.config.repo_visibility + ) # Check if the response is empty (failure) or has content (success) if not create_response: diff --git a/socketsecurity/core/socket_config.py b/socketsecurity/core/socket_config.py index f119d4b..1b5676c 100644 --- a/socketsecurity/core/socket_config.py +++ b/socketsecurity/core/socket_config.py @@ -26,6 +26,7 @@ class SocketConfig: full_scan_path: Optional[str] = None repository_path: Optional[str] = None security_policy: Dict = None + repo_visibility: Optional[str] = 'private' all_issues: Optional['AllIssues'] = None excluded_dirs: Set[str] = field(default_factory=lambda: default_exclude_dirs) version: str = __version__ diff --git a/socketsecurity/socketcli.py b/socketsecurity/socketcli.py index 64c3f3c..fdb038e 100644 --- a/socketsecurity/socketcli.py +++ b/socketsecurity/socketcli.py @@ -148,8 +148,14 @@ def main_code(): log.debug("Found manifest files or forced scan, proceeding") org_slug = core.config.org_slug + if config.repo_is_public: + core.config.repo_visibility = "public" integration_type = config.integration_type integration_org_slug = config.integration_org_slug or org_slug + try: + pr_number = int(config.pr_number) + except (ValueError, TypeError): + pr_number = 0 params = FullScanParams( org_slug=org_slug, @@ -159,7 +165,7 @@ def main_code(): branch=config.branch, commit_message=config.commit_message, commit_hash=config.commit_sha, - pull_request=config.pr_number, + pull_request=pr_number, committers=config.committers, make_default_branch=config.default_branch, set_as_pending_head=True