suite-py 1.47.0__py3-none-any.whl → 1.47.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
suite_py/__version__.py CHANGED
@@ -1,2 +1,2 @@
1
1
  # -*- encoding: utf-8 -*-
2
- __version__ = "1.47.0"
2
+ __version__ = "1.47.2"
@@ -16,18 +16,20 @@ class PreCommit:
16
16
  self._git = GitHandler(project, config)
17
17
 
18
18
  def check_and_warn(self):
19
- if self.is_enabled() and not self.is_pre_commit_hooks_installed():
20
- self.warn_missing_pre_commit_hook()
19
+ if self._is_enabled() and not self._is_pre_commit_hooks_installed():
20
+ self._warn_missing_pre_commit_hook()
21
21
 
22
- def is_pre_commit_hooks_installed(self):
22
+ def _is_enabled(self):
23
+ return self._git.get_git_config("suite-py.disable-pre-commit-warning") != "true"
24
+
25
+ def _is_pre_commit_hooks_installed(self):
23
26
  """
24
- Apply some heuteristics to check whether the gitleaks pre-commit hook is installed.
27
+ Apply some heuristics to check whether the gitleaks pre-commit hook is installed.
25
28
  This is extremely imperfect, and only supports direct calls in shell scripts.
26
- More hooks, like husky should be added later
27
29
  """
28
- return self.is_vanilla_hook_setup() or self.is_pre_commit_py_hook_setup()
30
+ return self._is_shell_script_hook_setup() or self._is_pre_commit_py_hook_setup()
29
31
 
30
- def warn_missing_pre_commit_hook(self):
32
+ def _warn_missing_pre_commit_hook(self):
31
33
  logger.warning(
32
34
  """
33
35
  Looks like the current repo is missing the gitleaks pre-commit hook!
@@ -42,28 +44,25 @@ to disable it globally
42
44
  """
43
45
  )
44
46
 
45
- def is_vanilla_hook_setup(self):
46
- """
47
- Check whether the gitleaks hook is setup as a regular bash script
47
+ def _is_shell_script_hook_setup(self):
48
48
  """
49
- pre_commit_file = self.read_pre_commit_hook()
49
+ Check whether the gitleaks hook is setup as a regular bash script:
50
50
 
51
- # Assume everything is a shell script.
52
- # Technically you could use a binary, or even python code,
53
- # But those are out of scope for us, and the user should just disable the warning themselves
54
- lines = pre_commit_file.splitlines()
55
-
56
- # Filter out lines that start with '#' since those are probably just comments.
57
- without_comments = filter(lambda l: not l.strip().startswith("#"), lines)
51
+ * is there a `.git/hooks/pre-commit` shell script that contains keyword "gitleaks"
52
+ * is there a `.husky/pre-commit` shell script that contains keyword "security-hooks" (primait/security-hooks repo)
53
+ """
54
+ path = os.path.join(self._git.hooks_path(), "pre-commit")
55
+ keywords = ["gitleaks", "security-hooks"]
58
56
 
59
- return any("gitleaks" in line for line in without_comments)
57
+ return any(self._script_contains_keyword(path, keyword) for keyword in keywords)
60
58
 
61
- def is_pre_commit_py_hook_setup(self):
59
+ def _is_pre_commit_py_hook_setup(self):
62
60
  """
63
61
  Check whether the gitleaks hook is setup with the pre-commit python framework
64
62
  """
65
- # If the framework is not setup skip
66
- if "pre-commit" not in self.read_pre_commit_hook():
63
+ # is there a `.git/hooks/pre-commit` shell script that contains keyword "pre-commit"
64
+ pre_commit_file_path = os.path.join(self._git.hooks_path(), "pre-commit")
65
+ if not self._script_contains_keyword(pre_commit_file_path, "pre-commit"):
67
66
  logger.debug("pre-commit.com not installed, skipping config check")
68
67
  return False
69
68
 
@@ -83,14 +82,21 @@ to disable it globally
83
82
  for repo in config.get("repos", [])
84
83
  )
85
84
 
86
- def read_pre_commit_hook(self):
87
- pre_commit_file_path = os.path.join(self._git.hooks_path(), "pre-commit")
88
- logger.debug("Reading pre-commit script from %s", pre_commit_file_path)
85
+ def _script_contains_keyword(self, file_path, keyword):
86
+ """
87
+ Check if a keyword appears in a shell script, ignoring comment lines
88
+ (binaries and python code are out of scope for us).
89
+ """
89
90
  try:
90
- with open(pre_commit_file_path, encoding="utf-8") as f:
91
- return f.read()
91
+ logger.debug("checking pre-commit script(%s)", file_path)
92
+ with open(file_path, encoding="utf-8") as f:
93
+ content = f.read()
92
94
  except FileNotFoundError:
93
- return ""
95
+ logger.debug("pre-commit script(%s) not found", file_path)
96
+ return False
94
97
 
95
- def is_enabled(self):
96
- return self._git.get_git_config("suite-py.disable-pre-commit-warning") != "true"
98
+ # Filter out comments (lines starting with '#').
99
+ lines_without_comments = (
100
+ line for line in content.splitlines() if not line.strip().startswith("#")
101
+ )
102
+ return any(keyword in line for line in lines_without_comments)
suite_py/lib/logger.py CHANGED
@@ -17,7 +17,15 @@ def setup(verbose):
17
17
  level=level,
18
18
  format=LOG_FORMAT,
19
19
  datefmt="[%X]",
20
- handlers=[RichHandler(rich_tracebacks=True, markup=False, show_path=False)],
20
+ handlers=[
21
+ RichHandler(
22
+ rich_tracebacks=True,
23
+ markup=False,
24
+ show_path=False,
25
+ show_level=False,
26
+ show_time=False,
27
+ )
28
+ ],
21
29
  )
22
30
 
23
31
  logger = logging.getLogger(LOGGER_NAME)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: suite-py
3
- Version: 1.47.0
3
+ Version: 1.47.2
4
4
  Summary:
5
5
  Author: larrywax, EugenioLaghi, michelangelomo
6
6
  Author-email: devops@prima.it
@@ -1,5 +1,5 @@
1
1
  suite_py/__init__.py,sha256=REmi3D0X2G1ZWnYpKs8Ffm3NIj-Hw6dMuvz2b9NW344,142
2
- suite_py/__version__.py,sha256=MAUpG5q0Rn7dwAd-YiBXREx3zP4X9kP0bBH9hPHdk74,49
2
+ suite_py/__version__.py,sha256=kvsaCaiN9_S0SML3PK6KymI83Qay7-_HSBXG0J1EN00,49
3
3
  suite_py/cli.py,sha256=hBbNXb9vVk8lSJXRrb1GctTp3EUjMYFWS9mn_HaNG9I,11155
4
4
  suite_py/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  suite_py/commands/ask_review.py,sha256=yN__Ac-fiZBPShjRDhyCCQZGfVlQE16KozoJk4UtiNw,3788
@@ -27,11 +27,11 @@ suite_py/lib/handler/git_handler.py,sha256=8UVttqo65CTg5LCvOBTDXb_sNxLKUrpevCGio
27
27
  suite_py/lib/handler/github_handler.py,sha256=xnBATLOTnOLpiYE29WwUrtDr7hxusfId9a1KbfK1OyA,2952
28
28
  suite_py/lib/handler/metrics_handler.py,sha256=-Tp62pFIiYsBkDga0nQG3lWU-gxH68wEjIIIJeU1jHk,3159
29
29
  suite_py/lib/handler/okta_handler.py,sha256=UiRcBDmFkMFi9H7Me1QaruC8yPI5fFbnLGzOf3kfxG0,2805
30
- suite_py/lib/handler/pre_commit_handler.py,sha256=nwqVgC-KnUjn7NVIHZ0VmDdUfp6Q1ieFIth-1_U76Gw,3740
30
+ suite_py/lib/handler/pre_commit_handler.py,sha256=NLqwIkggh0FRoiKFVCMdRIkaafKrfnNXgaDHGlfpQMA,4144
31
31
  suite_py/lib/handler/prompt_utils.py,sha256=vgk1O7h-iYEAZv1sXtMh8xIgH1djI398rzxRIgZWZcg,2474
32
32
  suite_py/lib/handler/version_handler.py,sha256=DXTx4yCAbFVC6CdMqPJ-LiN5YM-dT2zklG8POyKTP5A,6774
33
33
  suite_py/lib/handler/youtrack_handler.py,sha256=_CwzeFhj7kMYb61CN8IYF0IE55Zrj6vZT38SUZLA5B8,10192
34
- suite_py/lib/logger.py,sha256=aL870R69enNL9K8mQrMFgSAVUPXXgkvaVp6xTprCBWA,1029
34
+ suite_py/lib/logger.py,sha256=SsJ1MpA3Kkt_4VTscfmsnlYZRZdzWwkxfWfVWVgsADI,1181
35
35
  suite_py/lib/metrics.py,sha256=urTBVzIc1Ys6OHPOO32fLPPRcQU45tzM3XMJ7mUl5dc,1629
36
36
  suite_py/lib/oauth.py,sha256=tE3MgCnYhW6ZIbkyeUohFTOUvnBsrJXfHN8XsAVQNXk,5077
37
37
  suite_py/lib/requests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -40,7 +40,7 @@ suite_py/lib/requests/session.py,sha256=P32H3cWnCWunu91WIj2iDM5U3HzaBglg60VN_C9J
40
40
  suite_py/lib/symbol.py,sha256=z3QYBuNIwD3qQ3zF-cLOomIr_-C3bO_u5UIDAHMiyTo,60
41
41
  suite_py/lib/tokens.py,sha256=4DbsHDFLIxs40t3mRw_ZyhmejZQ0Bht7iAL8dTCTQd4,5458
42
42
  suite_py/templates/login.html,sha256=fJLls2SB84oZTSrxTdA5q1PqfvIHcCD4fhVWfyco7Ig,861
43
- suite_py-1.47.0.dist-info/METADATA,sha256=BQ89I8Mw0ramSkm1bIPTIteQJpi4huQCRWwAuh4L6NU,1250
44
- suite_py-1.47.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
45
- suite_py-1.47.0.dist-info/entry_points.txt,sha256=dVKLC-9Infy-dHJT_MkK6LcDjOgBCJ8lfPkURJhBjxE,46
46
- suite_py-1.47.0.dist-info/RECORD,,
43
+ suite_py-1.47.2.dist-info/METADATA,sha256=Im2wlMuvnyUlrS78imSKRRMLFhWQsk7XoH2Ij8thbCI,1250
44
+ suite_py-1.47.2.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
45
+ suite_py-1.47.2.dist-info/entry_points.txt,sha256=dVKLC-9Infy-dHJT_MkK6LcDjOgBCJ8lfPkURJhBjxE,46
46
+ suite_py-1.47.2.dist-info/RECORD,,