ae-shell 0.3.11__tar.gz → 0.3.12__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ae_shell
3
- Version: 0.3.11
3
+ Version: 0.3.12
4
4
  Summary: ae namespace module portion shell: shell execution and environment helpers
5
5
  Home-page: https://gitlab.com/ae-group/ae_shell
6
6
  Author: AndiEcker
@@ -67,13 +67,13 @@ Dynamic: summary
67
67
 
68
68
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.101 -->
69
69
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.namespace_root_tpls v0.3.22 -->
70
- # shell 0.3.11
70
+ # shell 0.3.12
71
71
 
72
72
  [![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/develop?logo=python)](
73
73
  https://gitlab.com/ae-group/ae_shell)
74
74
  [![LatestPyPIrelease](
75
- https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.11?logo=python)](
76
- https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.11)
75
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.12?logo=python)](
76
+ https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.12)
77
77
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_shell)](
78
78
  https://pypi.org/project/ae-shell/#history)
79
79
 
@@ -1,12 +1,12 @@
1
1
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.101 -->
2
2
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.namespace_root_tpls v0.3.22 -->
3
- # shell 0.3.11
3
+ # shell 0.3.12
4
4
 
5
5
  [![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/develop?logo=python)](
6
6
  https://gitlab.com/ae-group/ae_shell)
7
7
  [![LatestPyPIrelease](
8
- https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.11?logo=python)](
9
- https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.11)
8
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.12?logo=python)](
9
+ https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.12)
10
10
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_shell)](
11
11
  https://pypi.org/project/ae-shell/#history)
12
12
 
@@ -31,7 +31,7 @@ from ae.core import main_app_instance, AppBase
31
31
  from ae.console import MAIN_SECTION_NAME, ConsoleApp # type: ignore
32
32
 
33
33
 
34
- __version__ = '0.3.11'
34
+ __version__ = '0.3.12'
35
35
 
36
36
 
37
37
  STDERR_BEG_MARKER = "vvv STDERR vvv" #: :paramref:`ae.shell.sh_exec.lines_output` begin stderr lines
@@ -123,11 +123,11 @@ def mask_token(text: list[str]) -> list[str]: ...
123
123
 
124
124
 
125
125
  def mask_token(text: Union[str, list[str]]) -> Union[str, list[str]]:
126
- """ hide most parts of any Codeberg/GitHub/GitHub tokens found in the specified text/-lines.
126
+ """ hide most parts of any Codeberg/GitHub/GitHub URL tokens found in the specified text/-lines.
127
127
 
128
- :param text: text block, specified either as str object or as a list of str objects (lines),
129
- to detect tokens within, to hide/mask the most part of them.
130
- :return: text block with without the complete tokens.
128
+ :param text: text, specified either as str object or as a list of str objects (lines),
129
+ each str/line get searched for URL tokens, to hide/mask the most part of them.
130
+ :return: text with masked URL tokens (only leaving the first/last 3 token characters unmasked).
131
131
 
132
132
  .. note:: see also :func:`ae.base.mask_url` of a more generic way to hide passwords and tokens in URLs.
133
133
  """
@@ -136,14 +136,15 @@ def mask_token(text: Union[str, list[str]]) -> Union[str, list[str]]:
136
136
  else:
137
137
  lines = list(text) # copy to not change text list content
138
138
 
139
+ url_beg = 'https://' # PDV_REPO_HOST_PROTOCOL
140
+ url_beg_len = len(url_beg)
139
141
  for tok_beg, tok_end in ((':', '@codeberg.org'), ('glpat-', '@gitlab.com'), ('ghp_', '@github.com')):
140
142
  for idx, line in enumerate(lines):
141
- while tok_beg in line: # hide the GitLab/GitHub private token, e.g. from git-push-urls with authentication
142
- start = line.index(tok_beg)
143
- end = line.find(tok_end, start)
144
- if end == -1:
145
- break
146
- line = line[:start + 3] + "***-masked-token-***" + line[end - 3:]
143
+ beg = -1
144
+ while ((beg := line.find(url_beg, beg + 1)) != -1 and
145
+ (beg := line.find(tok_beg, beg + url_beg_len)) != -1 and
146
+ (end := line.find(tok_end, beg)) != -1):
147
+ line = line[:beg + 3] + "***-masked-token-***" + line[end - 3:]
147
148
  lines[idx] = line
148
149
 
149
150
  return lines[0] if is_str_arg else lines
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ae_shell
3
- Version: 0.3.11
3
+ Version: 0.3.12
4
4
  Summary: ae namespace module portion shell: shell execution and environment helpers
5
5
  Home-page: https://gitlab.com/ae-group/ae_shell
6
6
  Author: AndiEcker
@@ -67,13 +67,13 @@ Dynamic: summary
67
67
 
68
68
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project ae.ae v0.3.101 -->
69
69
  <!-- THIS FILE IS EXCLUSIVELY MAINTAINED by the project aedev.namespace_root_tpls v0.3.22 -->
70
- # shell 0.3.11
70
+ # shell 0.3.12
71
71
 
72
72
  [![GitLab develop](https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/develop?logo=python)](
73
73
  https://gitlab.com/ae-group/ae_shell)
74
74
  [![LatestPyPIrelease](
75
- https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.11?logo=python)](
76
- https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.11)
75
+ https://img.shields.io/gitlab/pipeline/ae-group/ae_shell/release0.3.12?logo=python)](
76
+ https://gitlab.com/ae-group/ae_shell/-/tree/release0.3.12)
77
77
  [![PyPIVersions](https://img.shields.io/pypi/v/ae_shell)](
78
78
  https://pypi.org/project/ae-shell/#history)
79
79
 
@@ -81,7 +81,7 @@ setup_kwargs = {
81
81
  },
82
82
  'python_requires': '>=3.12',
83
83
  'url': 'https://gitlab.com/ae-group/ae_shell',
84
- 'version': '0.3.11',
84
+ 'version': '0.3.12',
85
85
  'zip_safe': True,
86
86
  }
87
87
 
@@ -210,19 +210,33 @@ class TestHelpers:
210
210
  assert os.environ == os_env
211
211
 
212
212
  def test_mask_token(self):
213
+ url_prefix_str = "https://" # PDV_REPO_HOST_PROTOCOL
214
+
215
+ token = "codeberg token does not have a prefix and only contains hex-digits followed by @ and codeberg.org"
216
+ text = f"a text block containing a codeberg URL with a token: {url_prefix_str}UsaNäm:{token}@codeberg.org"
217
+
218
+ assert token not in mask_token(text)
219
+ assert token not in mask_token([text])[0]
220
+ assert mask_token(text).count('codeberg.org') == 1
221
+ assert mask_token(text).count(':') == 3
222
+
213
223
  token = "glpat-gitlab token format ending at the @/ampersand directly followed by the gitlab.com domain"
214
- text = "a text block containing a gitlab URL with a token: https://UsaNäm:" + token + "@gitlab.com"
224
+ text = "a text block containing a gitlab URL with a glpat-token: https://UsaNäm:" + token + "@gitlab.com"
215
225
 
216
226
  assert token not in mask_token(text)
217
227
  assert token not in mask_token([text])[0]
228
+ assert mask_token(text).count('gitlab.com') == 1
229
+ assert mask_token(text).count('glpat-') == 1
218
230
 
219
231
  token = "ghp_-github token format ending at the @/ampersand directly followed by the github.com domain"
220
- text = "a text block containing a github URL with a token: https://YouSaNem:" + token + "@github.com"
232
+ text = "a text block containing a github URL with a ghp_-token: https://YouSaNem:" + token + "@github.com"
221
233
 
222
234
  assert token not in mask_token(text)
223
235
  assert token not in mask_token([text])[0]
236
+ assert mask_token(text).count('github.com') == 1
237
+ assert mask_token(text).count('ghp_') == 1
224
238
 
225
- text = "skip masking of text blocks with a start token like ghp_ or glpat- but missing end token"
239
+ text = "NO masking if @codeberg.org/@github.com/@gitlab.com domains before token start str ':', ghp_ or glpat-:"
226
240
 
227
241
  assert mask_token(text) == text # neither throws str.index()-ValueError nor stuck in endless-loop
228
242
 
File without changes
File without changes
File without changes