Skip to content

Commit

Permalink
updated so that hooks will update prior to initial scan
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-heist-slalom committed Apr 23, 2024
1 parent cb45b35 commit adf7b1e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
27 changes: 27 additions & 0 deletions secureli/actions/action.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from abc import ABC
from pathlib import Path
from rich.progress import Progress

from secureli.modules.shared.abstractions.echo import EchoAbstraction
from secureli.modules.observability.consts.logging import TELEMETRY_DEFAULT_ENDPOINT
from secureli.modules.shared.models.echo import Color
from secureli.modules.shared.models.install import VerifyOutcome, VerifyResult
from secureli.modules.shared.models import language
from secureli.modules.shared.models.logging import LogAction
from secureli.modules.shared.models.scan import ScanMode
from secureli.modules.language_analyzer import language_analyzer, language_support
from secureli.modules.core.core_services.scanner import HooksScannerService
Expand Down Expand Up @@ -296,6 +299,9 @@ def _run_post_install_scan(
)
)

# Updated hooks prior to initial scan
self._initial_hooks_update(folder_path)

if secret_test_id := metadata.security_hook_id:
self.action_deps.echo.print(
f"The following language(s) support secrets detection: {format_sentence_list(config.languages)}"
Expand Down Expand Up @@ -459,3 +465,24 @@ def _update_secureli_pre_commit_config_location(
return VerifyResult(
outcome=VerifyOutcome.UPDATE_CANCELED, file_path=deprecated_location
)

def _initial_hooks_update(self, folder_path: Path):
with Progress(transient=True) as progress:
self.action_deps.echo.print(
"Updating hooks to the latest version prior to initial scan..."
)
progress.add_task("Updating...", start=False, total=None)
update_result = self.action_deps.updater.update_hooks(folder_path)
details = (
update_result.output
or "Unknown output while updating hooks to latest version"
)
progress.stop()
self.action_deps.echo.print(details)
if not update_result.successful:
self.logging.failure(LogAction.update, details)
else:
self.action_deps.echo.print(
"Hooks successfully updated to latest version"
)
self.logging.success(LogAction.update)
1 change: 0 additions & 1 deletion secureli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def init(
Path(directory), reset, yes
)
if init_result.outcome in [
VerifyOutcome.INSTALL_SUCCEEDED,
VerifyOutcome.UP_TO_DATE,
VerifyOutcome.UPDATE_SUCCEEDED,
]:
Expand Down

0 comments on commit adf7b1e

Please sign in to comment.