chatenv 0.2.12__tar.gz → 0.2.13__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 (31) hide show
  1. {chatenv-0.2.12/src/chatenv.egg-info → chatenv-0.2.13}/PKG-INFO +2 -2
  2. {chatenv-0.2.12 → chatenv-0.2.13}/README.md +1 -1
  3. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/__init__.py +1 -1
  4. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/utils.py +3 -2
  5. {chatenv-0.2.12 → chatenv-0.2.13/src/chatenv.egg-info}/PKG-INFO +2 -2
  6. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv.egg-info/SOURCES.txt +1 -0
  7. {chatenv-0.2.12 → chatenv-0.2.13}/tests/test_chatenv_core.py +6 -3
  8. chatenv-0.2.13/tests/test_secret_display.py +66 -0
  9. {chatenv-0.2.12 → chatenv-0.2.13}/tests/test_version.py +12 -1
  10. {chatenv-0.2.12 → chatenv-0.2.13}/LICENSE +0 -0
  11. {chatenv-0.2.12 → chatenv-0.2.13}/pyproject.toml +0 -0
  12. {chatenv-0.2.12 → chatenv-0.2.13}/setup.cfg +0 -0
  13. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/cli.py +0 -0
  14. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/configs.py +0 -0
  15. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/discovery.py +0 -0
  16. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/fields.py +0 -0
  17. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/paste.py +0 -0
  18. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/paths.py +0 -0
  19. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/policy.py +0 -0
  20. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/presets/__init__.py +0 -0
  21. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/registry.py +0 -0
  22. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/source_chain.py +0 -0
  23. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/store.py +0 -0
  24. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/token_refreshers.py +0 -0
  25. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv/tokens.py +0 -0
  26. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv.egg-info/dependency_links.txt +0 -0
  27. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv.egg-info/entry_points.txt +0 -0
  28. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv.egg-info/requires.txt +0 -0
  29. {chatenv-0.2.12 → chatenv-0.2.13}/src/chatenv.egg-info/top_level.txt +0 -0
  30. {chatenv-0.2.12 → chatenv-0.2.13}/tests/test_docs_contract.py +0 -0
  31. {chatenv-0.2.12 → chatenv-0.2.13}/tests/test_workflow_contract.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chatenv
3
- Version: 0.2.12
3
+ Version: 0.2.13
4
4
  Summary: ChatArch typed environment profile manager
5
5
  Author-email: rexwzh <1073853456@qq.com>
6
6
  License-Expression: MIT
@@ -134,7 +134,7 @@ chatenv token refresh PyPI RexWzh
134
134
  chatenv token status PyPI RexWzh
135
135
  ```
136
136
 
137
- 敏感值默认 mask;`token status/list/clear` 只输出 safe metadata,不输出 raw token/cookie/CSRF values。
137
+ 敏感值默认完整遮罩:`init` 的已有值提示、默认 `cat` 和 `status --detail` 不展示密码/密钥的首尾片段;明确使用 `cat --no-mask` 才主动取原值。遮罩仅影响显示,不把星号写回 profile;`token status/list/clear` 只输出 safe metadata,不输出 raw token/cookie/CSRF values。
138
138
 
139
139
  ## Python API
140
140
 
@@ -103,7 +103,7 @@ chatenv token refresh PyPI RexWzh
103
103
  chatenv token status PyPI RexWzh
104
104
  ```
105
105
 
106
- 敏感值默认 mask;`token status/list/clear` 只输出 safe metadata,不输出 raw token/cookie/CSRF values。
106
+ 敏感值默认完整遮罩:`init` 的已有值提示、默认 `cat` 和 `status --detail` 不展示密码/密钥的首尾片段;明确使用 `cat --no-mask` 才主动取原值。遮罩仅影响显示,不把星号写回 profile;`token status/list/clear` 只输出 safe metadata,不输出 raw token/cookie/CSRF values。
107
107
 
108
108
  ## Python API
109
109
 
@@ -39,4 +39,4 @@ __all__ = [
39
39
  "__version__",
40
40
  ]
41
41
 
42
- __version__ = "0.2.12"
42
+ __version__ = "0.2.13"
@@ -1,10 +1,11 @@
1
1
  from __future__ import annotations
2
2
 
3
3
 
4
- def mask_secret(value: object, *, visible: int = 8) -> str:
4
+ def mask_secret(value: object, *, visible: int = 0) -> str:
5
+ """Fully hide values by default; fingerprints require explicit opt-in."""
5
6
  text = "" if value is None else str(value)
6
7
  if not text:
7
8
  return ""
8
- if len(text) <= visible * 2:
9
+ if visible <= 0 or len(text) <= visible * 2:
9
10
  return "*" * len(text)
10
11
  return f"{text[:visible]}{'*' * (len(text) - visible * 2)}{text[-visible:]}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chatenv
3
- Version: 0.2.12
3
+ Version: 0.2.13
4
4
  Summary: ChatArch typed environment profile manager
5
5
  Author-email: rexwzh <1073853456@qq.com>
6
6
  License-Expression: MIT
@@ -134,7 +134,7 @@ chatenv token refresh PyPI RexWzh
134
134
  chatenv token status PyPI RexWzh
135
135
  ```
136
136
 
137
- 敏感值默认 mask;`token status/list/clear` 只输出 safe metadata,不输出 raw token/cookie/CSRF values。
137
+ 敏感值默认完整遮罩:`init` 的已有值提示、默认 `cat` 和 `status --detail` 不展示密码/密钥的首尾片段;明确使用 `cat --no-mask` 才主动取原值。遮罩仅影响显示,不把星号写回 profile;`token status/list/clear` 只输出 safe metadata,不输出 raw token/cookie/CSRF values。
138
138
 
139
139
  ## Python API
140
140
 
@@ -24,5 +24,6 @@ src/chatenv.egg-info/top_level.txt
24
24
  src/chatenv/presets/__init__.py
25
25
  tests/test_chatenv_core.py
26
26
  tests/test_docs_contract.py
27
+ tests/test_secret_display.py
27
28
  tests/test_version.py
28
29
  tests/test_workflow_contract.py
@@ -573,9 +573,12 @@ def test_cli_paste_active_and_cat(tmp_path):
573
573
  cat = runner.invoke(cli, ["--home", str(home), "cat", "-t", "unit"])
574
574
  assert cat.exit_code == 0, cat.output
575
575
  assert "UNIT_VALUE='from-cli'" in cat.output
576
- assert "sk-abcde" in cat.output
577
- assert "123456" in cat.output
578
- assert "abcdefghijklmnopqrstuvwxyz" not in cat.output
576
+ saved = EnvStore(home / "envs").load_active(UnitConfig)["UNIT_KEY"]
577
+ assert saved not in cat.output
578
+ assert "UNIT_KEY='" + "*" * len(saved) + "'" in cat.output
579
+ raw = runner.invoke(cli, ["--home", str(home), "cat", "-t", "unit", "--no-mask"])
580
+ assert raw.exit_code == 0
581
+ assert "UNIT_KEY='" + saved + "'" in raw.output
579
582
 
580
583
 
581
584
  def test_cli_cat_output_with_blank_lines_can_be_pasted_to_profile(tmp_path):
@@ -0,0 +1,66 @@
1
+ from types import SimpleNamespace
2
+ import stat
3
+
4
+ import click
5
+ import pytest
6
+ from click.testing import CliRunner
7
+
8
+ import chatenv.cli as cli_module
9
+ from chatenv.cli import cli
10
+ from chatenv.fields import BaseEnvConfig, EnvField
11
+ from chatenv.store import EnvStore
12
+ from chatenv.utils import mask_secret
13
+
14
+ CANARY = 'DUMMY_CANARY_SECRET_VALUE_LONG_123456789'
15
+
16
+ class SecretDisplayConfig(BaseEnvConfig):
17
+ _title = 'Secret Display Regression'
18
+ _aliases = ['secret-display-regression']
19
+ _storage_dir = 'SecretDisplayRegression'
20
+ DISPLAY_PASSWORD = EnvField('DISPLAY_PASSWORD', is_sensitive=True)
21
+
22
+ @pytest.mark.parametrize('value', ['dummy', CANARY, '假密码仅测试01234567890123456789'])
23
+ def test_default_mask_is_complete(value):
24
+ assert mask_secret(value) == '*' * len(value)
25
+
26
+ def test_zero_visibility_never_appends_original():
27
+ assert mask_secret(CANARY, visible=0) == '*' * len(CANARY)
28
+
29
+ def test_explicit_fingerprint_remains_opt_in():
30
+ assert mask_secret(CANARY, visible=3) == CANARY[:3] + '*' * (len(CANARY)-6) + CANARY[-3:]
31
+
32
+ def test_init_masks_existing_fragments_and_retains_on_enter(monkeypatch, tmp_path):
33
+ home = tmp_path/'arch'
34
+ store = EnvStore(home/'envs')
35
+ store.save_active(SecretDisplayConfig, {'DISPLAY_PASSWORD': CANARY})
36
+ prompts = []
37
+ def ask(prompt, **kwargs):
38
+ prompts.append(kwargs)
39
+ click.echo(prompt)
40
+ return ''
41
+ monkeypatch.setattr(cli_module,'load_config_providers',lambda:None)
42
+ monkeypatch.setattr(cli_module,'resolve_interactive_mode',lambda *a,**k:SimpleNamespace(force_interactive=False,can_prompt=True,need_prompt=True))
43
+ monkeypatch.setattr(cli_module,'ask_text',ask)
44
+ result = CliRunner().invoke(cli,['--home',str(home),'init','-t','secret-display-regression','-i'])
45
+ assert result.exit_code == 0, result.output
46
+ assert CANARY[:8] not in result.output and CANARY[-8:] not in result.output
47
+ assert prompts[0]['password'] is True and prompts[0]['default'] == ''
48
+ assert store.load_active(SecretDisplayConfig)['DISPLAY_PASSWORD'] == CANARY
49
+ assert stat.S_IMODE(store.active_path(SecretDisplayConfig).stat().st_mode) == 0o600
50
+
51
+ def test_cat_masks_fragments_by_default(monkeypatch,tmp_path):
52
+ home=tmp_path/'arch'
53
+ EnvStore(home/'envs').save_active(SecretDisplayConfig,{'DISPLAY_PASSWORD':CANARY})
54
+ monkeypatch.setattr(cli_module,'load_config_providers',lambda:None)
55
+ result=CliRunner().invoke(cli,['--home',str(home),'cat','-t','secret-display-regression'])
56
+ assert result.exit_code==0,result.output
57
+ assert CANARY[:8] not in result.output and CANARY[-8:] not in result.output
58
+ assert "DISPLAY_PASSWORD='"+'*'*len(CANARY)+"'" in result.output
59
+
60
+ def test_status_masks_sensitive_default(monkeypatch,tmp_path):
61
+ monkeypatch.setattr(SecretDisplayConfig.DISPLAY_PASSWORD,'default',CANARY)
62
+ monkeypatch.setattr(cli_module,'load_config_providers',lambda:None)
63
+ result=CliRunner().invoke(cli,['--home',str(tmp_path/'arch'),'status','-t','secret-display-regression','--detail'])
64
+ assert result.exit_code==0,result.output
65
+ assert CANARY[:8] not in result.output and CANARY[-8:] not in result.output
66
+ assert 'sensitive=yes' in result.output
@@ -3,8 +3,19 @@ from chatenv.cli import cli
3
3
  from click.testing import CliRunner
4
4
 
5
5
 
6
+ def test_release_workflow_cannot_publish_from_a_branch_dispatch():
7
+ from pathlib import Path
8
+
9
+ workflow = Path('.github/workflows/publish.yml').read_text(encoding='utf-8')
10
+ assert 'test "${GITHUB_REF_TYPE}" = "tag"' in workflow
11
+ assert "if: github.event_name == 'push'" not in workflow
12
+ assert workflow.index('Require release tag reference') < workflow.index('Publish to PyPI (OIDC)')
13
+ assert workflow.index('Check tag matches package version') < workflow.index('Publish to PyPI (OIDC)')
14
+ assert workflow.index('Check release commit is on default branch') < workflow.index('Publish to PyPI (OIDC)')
15
+
16
+
6
17
  def test_version_present():
7
- assert __version__ == "0.2.12"
18
+ assert __version__ == "0.2.13"
8
19
 
9
20
 
10
21
  def test_cli_version_option():
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