t-bug-catcher 0.6.2__tar.gz → 0.6.4__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.
Files changed (26) hide show
  1. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/PKG-INFO +1 -2
  2. t_bug_catcher-0.6.2/t_bug_catcher.egg-info/requires.txt → t_bug_catcher-0.6.4/requirements.txt +1 -2
  3. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/setup.cfg +1 -1
  4. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/setup.py +1 -1
  5. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher/__init__.py +1 -1
  6. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher/config.py +14 -0
  7. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher/jira.py +6 -5
  8. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher/stack_saver.py +32 -20
  9. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher.egg-info/PKG-INFO +1 -2
  10. t_bug_catcher-0.6.2/requirements.txt → t_bug_catcher-0.6.4/t_bug_catcher.egg-info/requires.txt +0 -1
  11. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/MANIFEST.in +0 -0
  12. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/README.rst +0 -0
  13. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/pyproject.toml +0 -0
  14. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher/bug_catcher.py +0 -0
  15. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher/bug_snag.py +0 -0
  16. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher/exceptions.py +0 -0
  17. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher/resources/whispers_config.yml +0 -0
  18. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher/utils/__init__.py +0 -0
  19. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher/utils/common.py +0 -0
  20. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher/utils/logger.py +0 -0
  21. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher/workitems.py +0 -0
  22. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher.egg-info/SOURCES.txt +0 -0
  23. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher.egg-info/dependency_links.txt +0 -0
  24. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher.egg-info/not-zip-safe +0 -0
  25. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/t_bug_catcher.egg-info/top_level.txt +0 -0
  26. {t_bug_catcher-0.6.2 → t_bug_catcher-0.6.4}/tests/test_t_bug_catcher.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: t_bug_catcher
3
- Version: 0.6.2
3
+ Version: 0.6.4
4
4
  Summary: Bug catcher
5
5
  Home-page: https://www.thoughtful.ai/
6
6
  Author: Thoughtful
@@ -14,7 +14,6 @@ Requires-Python: >=3.9
14
14
  Requires-Dist: requests<3.0.0,>=2.31.0
15
15
  Requires-Dist: bugsnag>=4.6.1
16
16
  Requires-Dist: retry~=0.9.2
17
- Requires-Dist: whispers>=2.2.1
18
17
 
19
18
  t-bug-catcher
20
19
  ==============
@@ -1,4 +1,3 @@
1
1
  requests<3.0.0,>=2.31.0
2
2
  bugsnag>=4.6.1
3
- retry~=0.9.2
4
- whispers>=2.2.1
3
+ retry~=0.9.2
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.6.2
2
+ current_version = 0.6.4
3
3
  commit = True
4
4
  tag = False
5
5
 
@@ -26,7 +26,7 @@ setup(
26
26
  packages=find_packages(include=["t_bug_catcher", "t_bug_catcher.*"]),
27
27
  test_suite="tests",
28
28
  url="https://www.thoughtful.ai/",
29
- version="0.6.2",
29
+ version="0.6.4",
30
30
  zip_safe=False,
31
31
  install_requires=install_requirements,
32
32
  include_package_data=True,
@@ -3,7 +3,7 @@
3
3
  __author__ = """Thoughtful"""
4
4
  __email__ = "support@thoughtful.ai"
5
5
  # fmt: off
6
- __version__ = '0.6.2'
6
+ __version__ = '0.6.4'
7
7
  # fmt: on
8
8
 
9
9
  from .bug_catcher import (
@@ -32,6 +32,20 @@ class Config:
32
32
  BC_BOARD = "BC"
33
33
 
34
34
  KEYS_TO_REMOVE = ["credential", "password"]
35
+
36
+ SENSITIVE_KEYS = [
37
+ r"user(?:name|_name)?",
38
+ r"id",
39
+ r"uid",
40
+ r"otp",
41
+ r"api(?:[_]?key|[_]?token)",
42
+ r"\w+api(?:[_]?key|[_]?token)",
43
+ r"key",
44
+ r"account",
45
+ r"client_(?:id|secret)",
46
+ ]
47
+ PARTIAL_MATCH_KEYS = [r"login", r"password", r"token", r"secret"]
48
+
35
49
  BUILD_INFO_FILE = "commit_info.json"
36
50
 
37
51
  HOST = socket.gethostname() if os.name.lower() == "nt" else None
@@ -1155,7 +1155,7 @@ class Jira:
1155
1155
  else []
1156
1156
  )
1157
1157
 
1158
- if len(issue.get("fields", {}).get("comment", [])) >= CONFIG.LIMITS.COMMENT_LIMIT:
1158
+ if len(issue.get("fields", {}).get("comment", {}).get("comments", [])) >= CONFIG.LIMITS.COMMENT_LIMIT:
1159
1159
  logger.warning(
1160
1160
  f"Comments for '{issue.get('key')}' were not posted due to exceeding JIRA comments limit "
1161
1161
  f"({CONFIG.LIMITS.COMMENT_LIMIT})."
@@ -1355,10 +1355,6 @@ class Jira:
1355
1355
  group_id = self.generate_group_id(group_by)
1356
1356
 
1357
1357
  all_issues = self.get_issues()["issues"]
1358
- existing_ticket = self.filter_tickets(
1359
- all_tickets=all_issues,
1360
- error_id=error_id,
1361
- )
1362
1358
 
1363
1359
  if group_id:
1364
1360
  existing_tickets = [
@@ -1376,6 +1372,11 @@ class Jira:
1376
1372
  else:
1377
1373
  summary = self.__create_summary(type(exception), exception, exception.__traceback__)
1378
1374
 
1375
+ existing_ticket = self.filter_tickets(
1376
+ all_tickets=all_issues,
1377
+ error_id=error_id,
1378
+ )
1379
+
1379
1380
  if existing_ticket:
1380
1381
  self.__update_existing_ticket(
1381
1382
  existing_ticket=existing_ticket,
@@ -3,12 +3,9 @@ import linecache
3
3
  import re
4
4
  import sys
5
5
  from datetime import datetime
6
- from pathlib import Path
7
6
  from types import FunctionType, ModuleType
8
7
  from typing import Optional
9
8
 
10
- import whispers
11
-
12
9
  from .config import CONFIG
13
10
  from .utils import logger
14
11
  from .utils.common import Encoder, convert_keys_to_primitives, strip_path
@@ -74,31 +71,46 @@ class StackSaver:
74
71
  Returns:
75
72
  None
76
73
  """
74
+ partial_match_pattern = re.compile(
75
+ r"(['\"])([^'\"]*?(%s)[^'\"]*?)(['\"])\s*([:,])\s*(['\"])([^'\"]*)(['\"])"
76
+ % (r"|".join(CONFIG.PARTIAL_MATCH_KEYS)),
77
+ re.IGNORECASE,
78
+ )
79
+
80
+ full_match_pattern = re.compile(
81
+ r"(['\"])(%s)(['\"])\s*([:,])\s*(['\"])([^'\"]*)(['\"])" % (r"|".join(CONFIG.SENSITIVE_KEYS)), re.IGNORECASE
82
+ )
83
+
77
84
  with open(file_path, "r") as f:
78
- filedata = f.readlines()
85
+ filedata = f.read()
79
86
 
80
- config_path = Path(__file__).parent.resolve().as_posix() + "/resources/whispers_config.yml"
87
+ partial_replace = self.mask_data((1, 2, 5))
88
+ full_replace = self.mask_data((1, 2, 4))
81
89
 
82
- args = f"-c {config_path} {file_path}"
90
+ masked_data = partial_match_pattern.sub(partial_replace, filedata)
91
+ masked_data = full_match_pattern.sub(full_replace, masked_data)
83
92
 
84
- secrets = [secret for secret in whispers.secrets(args)]
93
+ with open(file_path, "w") as file:
94
+ file.write(masked_data)
85
95
 
86
- for index, line in enumerate(filedata):
87
- if not secrets:
88
- break
96
+ def mask_data(self, indicates: tuple):
97
+ """A method to mask the data.
89
98
 
90
- for secret in secrets:
91
- if secret.key in line and secret.value in line:
92
- filedata[index] = line.replace(secret.value, secret.value[:1] + "***")
93
- secrets.pop(secrets.index(secret))
94
- break
99
+ Args:
100
+ indicates (tuple): The indicates of the data to be masked.
95
101
 
96
- if secrets:
97
- logger.warning("Failed to mask credentials")
98
- raise Exception("Failed to mask credentials")
102
+ Returns:
103
+ function: The function to mask the data.
104
+ """
99
105
 
100
- with open(file_path, "w") as file:
101
- file.writelines(filedata)
106
+ def mask_sensitive(match):
107
+ if match.group(2):
108
+ quote = match.group(indicates[0])
109
+ key_part = match.group(indicates[1])
110
+ delimiter = match.group(indicates[2])
111
+ return f"{quote}{key_part}{quote}{delimiter} {quote}***{quote}"
112
+
113
+ return mask_sensitive
102
114
 
103
115
  def save_stack_trace(self, exception: Optional[Exception] = None):
104
116
  """A method to save the stack trace.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: t_bug_catcher
3
- Version: 0.6.2
3
+ Version: 0.6.4
4
4
  Summary: Bug catcher
5
5
  Home-page: https://www.thoughtful.ai/
6
6
  Author: Thoughtful
@@ -14,7 +14,6 @@ Requires-Python: >=3.9
14
14
  Requires-Dist: requests<3.0.0,>=2.31.0
15
15
  Requires-Dist: bugsnag>=4.6.1
16
16
  Requires-Dist: retry~=0.9.2
17
- Requires-Dist: whispers>=2.2.1
18
17
 
19
18
  t-bug-catcher
20
19
  ==============
@@ -1,4 +1,3 @@
1
1
  requests<3.0.0,>=2.31.0
2
2
  bugsnag>=4.6.1
3
3
  retry~=0.9.2
4
- whispers>=2.2.1
File without changes
File without changes