Skip to content

Doug/add private flag for repo #80

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 3 commits into from
Apr 21, 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
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.0.54"
version = "2.0.55"
requires-python = ">= 3.10"
license = {"file" = "LICENSE"}
dependencies = [
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.0.54'
__version__ = '2.0.55'
38 changes: 24 additions & 14 deletions socketsecurity/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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="<name>",
help="Branch name",
default=""
)

integration_group = parser.add_argument_group('Integration')
integration_group.add_argument(
"--integration",
choices=INTEGRATION_TYPES,
metavar="<type>",
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="<name>",
help="Name of the integration owner, defaults to the socket organization slug",
required=False
)
repo_group.add_argument(
"--branch",
metavar="<name>",
help="Branch name",
default=""
)
repo_group.add_argument(
"--committers",
metavar="<name>",
help="Committer(s) to filter by",
nargs="*"
)

# Pull Request and Commit info
pr_group = parser.add_argument_group('Pull Request and Commit')
Expand Down Expand Up @@ -209,6 +213,12 @@ def create_argument_parser() -> argparse.ArgumentParser:
dest="commit_sha",
help=argparse.SUPPRESS
)
pr_group.add_argument(
"--committers",
metavar="<name>",
help="Committer for the commit (comma separated)",
nargs="*"
)

# Path and File options
path_group = parser.add_argument_group('Path and File')
Expand Down
7 changes: 6 additions & 1 deletion socketsecurity/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions socketsecurity/core/socket_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
8 changes: 7 additions & 1 deletion socketsecurity/socketcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
Loading