suite-py 1.47.1__tar.gz → 1.47.2__tar.gz
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-1.47.1 → suite_py-1.47.2}/PKG-INFO +1 -1
- {suite_py-1.47.1 → suite_py-1.47.2}/pyproject.toml +1 -1
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/__version__.py +1 -1
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/pre_commit_handler.py +36 -30
- {suite_py-1.47.1 → suite_py-1.47.2}/LICENSE-APACHE +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/LICENSE-MIT +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/__init__.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/cli.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/__init__.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/ask_review.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/bump.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/check.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/common.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/context.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/create_branch.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/estimate_cone.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/login.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/merge_pr.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/open_pr.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/project_lock.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/release.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/set_token.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/commands/status.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/__init__.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/config.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/__init__.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/aws_handler.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/captainhook_handler.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/changelog_handler.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/frequent_reviewers_handler.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/git_handler.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/github_handler.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/metrics_handler.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/okta_handler.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/prompt_utils.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/version_handler.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/handler/youtrack_handler.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/logger.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/metrics.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/oauth.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/requests/__init__.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/requests/auth.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/requests/session.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/symbol.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/lib/tokens.py +0 -0
- {suite_py-1.47.1 → suite_py-1.47.2}/suite_py/templates/login.html +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
__version__ = "1.47.
|
|
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.
|
|
20
|
-
self.
|
|
19
|
+
if self._is_enabled() and not self._is_pre_commit_hooks_installed():
|
|
20
|
+
self._warn_missing_pre_commit_hook()
|
|
21
21
|
|
|
22
|
-
def
|
|
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
|
|
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.
|
|
30
|
+
return self._is_shell_script_hook_setup() or self._is_pre_commit_py_hook_setup()
|
|
29
31
|
|
|
30
|
-
def
|
|
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
|
|
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
|
-
|
|
49
|
+
Check whether the gitleaks hook is setup as a regular bash script:
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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(
|
|
57
|
+
return any(self._script_contains_keyword(path, keyword) for keyword in keywords)
|
|
60
58
|
|
|
61
|
-
def
|
|
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
|
-
#
|
|
66
|
-
|
|
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
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
91
|
-
|
|
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
|
-
|
|
95
|
+
logger.debug("pre-commit script(%s) not found", file_path)
|
|
96
|
+
return False
|
|
94
97
|
|
|
95
|
-
|
|
96
|
-
|
|
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)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|