Skip to content

Commit

Permalink
need these fixes for custoemr-facing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
flowstate committed Feb 19, 2025
1 parent 40937bb commit 298f1f7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
6 changes: 6 additions & 0 deletions socketsecurity/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ def create_argument_parser() -> argparse.ArgumentParser:
action="store_true",
help="Output in JSON format"
)
output_group.add_argument(
"--enable_json",
dest="enable_json",
action="store_true",
help=argparse.SUPPRESS
)
output_group.add_argument(
"--enable-sarif",
dest="enable_sarif",
Expand Down
14 changes: 9 additions & 5 deletions socketsecurity/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,25 @@ def find_files(path: str) -> List[str]:
for file_name in patterns:
pattern = Core.to_case_insensitive_regex(patterns[file_name]["pattern"])
file_path = f"{path}/**/{pattern}"
log.debug(f"Globbing {file_path}")
# log.debug(f"Globbing {file_path}")
glob_start = time.time()
glob_files = glob(file_path, recursive=True)
for glob_file in glob_files:
if glob_file not in files:
files.add(glob_file)
glob_end = time.time()
glob_total_time = glob_end - glob_start
log.debug(f"Glob for pattern {file_path} took {glob_total_time:.2f} seconds")
# log.debug(f"Glob for pattern {file_path} took {glob_total_time:.2f} seconds")

log.debug("Finished Find Files")
end_time = time.time()
total_time = end_time - start_time
log.info(f"Found {len(files)} in {total_time:.2f} seconds")
log.debug(f"Files found: {list(files)}")
files_list = list(files)
if len(files_list) > 5:
log.debug(f"{len(files_list)} Files found: {', '.join(files_list[:5])}, ...")
else:
log.debug(f"{len(files_list)} Files found: {', '.join(files_list)}")
return list(files)

@staticmethod
Expand Down Expand Up @@ -461,15 +465,15 @@ def create_new_diff(
no_change: bool = False
) -> Diff:
"""Create a new diff using the Socket SDK."""
log.debug(f"starting create_new_diff with no_change: {no_change}")
if no_change:
log.debug(f"starting create_new_diff with no_change: {no_change}")
return Diff(id="no_diff_id")

# Find manifest files
files = self.find_files(path)
files_for_sending = self.load_files_for_sending(files, path)

log.debug(f"files: {files} found at path {path}")

if not files:
return Diff(id="no_diff_id")

Expand Down
5 changes: 4 additions & 1 deletion socketsecurity/core/scm/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ def from_env(cls, pr_number: Optional[str] = None) -> 'GithubConfig':
owner = repository.split('/')[0]
repository = repository.split('/')[1]

is_default = os.getenv('DEFAULT_BRANCH', '').lower() == 'true'
default_branch_env = os.getenv('DEFAULT_BRANCH')
# Consider the variable truthy if it exists and isn't explicitly 'false'
is_default = default_branch_env is not None and default_branch_env.lower() != 'false'

return cls(
sha=os.getenv('GITHUB_SHA', ''),
api_url=os.getenv('GITHUB_API_URL', ''),
Expand Down
2 changes: 2 additions & 0 deletions socketsecurity/socketcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def main_code():
integration_type = config.integration_type
integration_org_slug = config.integration_org_slug or org_slug

log.debug(f"config: {config.to_dict()}")
params = FullScanParams(
org_slug=org_slug,
integration_type=integration_type,
Expand All @@ -159,6 +160,7 @@ def main_code():
make_default_branch=config.default_branch,
set_as_pending_head=True
)
log.debug(f"Params initially set to: {params}")

# Initialize diff
diff = Diff()
Expand Down

0 comments on commit 298f1f7

Please sign in to comment.