bcmd 0.5.13__tar.gz → 0.5.15__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.

Potentially problematic release.


This version of bcmd might be problematic. Click here for more details.

Files changed (39) hide show
  1. {bcmd-0.5.13 → bcmd-0.5.15}/PKG-INFO +2 -2
  2. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/wasabi.py +33 -24
  3. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd.egg-info/PKG-INFO +2 -2
  4. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd.egg-info/requires.txt +1 -1
  5. {bcmd-0.5.13 → bcmd-0.5.15}/pyproject.toml +2 -2
  6. {bcmd-0.5.13 → bcmd-0.5.15}/MANIFEST.in +0 -0
  7. {bcmd-0.5.13 → bcmd-0.5.15}/README.md +0 -0
  8. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/__init__.py +0 -0
  9. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/common/__init__.py +0 -0
  10. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/common/func.py +0 -0
  11. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/common/password.py +0 -0
  12. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/main.py +0 -0
  13. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/resources/project/.gitignore +0 -0
  14. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/resources/project/.vscode/launch.json +0 -0
  15. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/resources/project/.vscode/settings.json +0 -0
  16. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/resources/project/.vscode/tasks.json +0 -0
  17. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/resources/project/main.py +0 -0
  18. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/__init__.py +0 -0
  19. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/bin.py +0 -0
  20. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/code.py +0 -0
  21. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/crypto.py +0 -0
  22. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/debian.py +0 -0
  23. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/download.py +0 -0
  24. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/image.py +0 -0
  25. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/json.py +0 -0
  26. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/lib.py +0 -0
  27. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/math.py +0 -0
  28. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/mirror.py +0 -0
  29. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/pdf.py +0 -0
  30. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/project.py +0 -0
  31. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/proxy.py +0 -0
  32. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/time.py +0 -0
  33. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/upgrade.py +0 -0
  34. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd/tasks/venv.py +0 -0
  35. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd.egg-info/SOURCES.txt +0 -0
  36. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd.egg-info/dependency_links.txt +0 -0
  37. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd.egg-info/entry_points.txt +0 -0
  38. {bcmd-0.5.13 → bcmd-0.5.15}/bcmd.egg-info/top_level.txt +0 -0
  39. {bcmd-0.5.13 → bcmd-0.5.15}/setup.cfg +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: bcmd
3
- Version: 0.5.13
3
+ Version: 0.5.15
4
4
  Summary: Commands for Beni
5
5
  Author-email: Beni Mang <benimang@126.com>
6
6
  Maintainer-email: Beni Mang <benimang@126.com>
7
7
  Keywords: benimang,beni,bcmd
8
8
  Requires-Python: >=3.10
9
- Requires-Dist: benimang==0.7.13
9
+ Requires-Dist: benimang==0.7.14
10
10
  Requires-Dist: build
11
11
  Requires-Dist: cryptography
12
12
  Requires-Dist: pathspec
@@ -1,4 +1,5 @@
1
1
  import getpass
2
+ import stat
2
3
  from pathlib import Path
3
4
  from typing import Final
4
5
 
@@ -16,16 +17,14 @@ MAX_ENCRYPT_SIZE = 199 * 1024
16
17
  @app.command()
17
18
  @syncCall
18
19
  async def unzip(
19
- file: Path = typer.Argument(Path.cwd(), help='加密文件'),
20
+ target: Path = typer.Argument(Path.cwd(), help='加密文件'),
20
21
  password: str = typer.Option('', '--password', '-p', help='密码'),
21
22
  ):
22
23
  '解压缩加密文件成目录'
23
- assert file.is_file(), f'不是文件 {file}'
24
- workspace = file.with_suffix('')
25
- assert not workspace.exists(), f'目录已存在 {workspace}'
24
+ assert target.is_file(), f'不是文件 {target}'
26
25
  password = password or getpass.getpass('请输入密码: ')
27
26
  with bpath.useTempFile() as tempFile:
28
- data = await bfile.readBytes(file)
27
+ data = await bfile.readBytes(target)
29
28
  if SEP not in data:
30
29
  data = bcrypto.decrypt(data, password)
31
30
  else:
@@ -34,28 +33,31 @@ async def unzip(
34
33
  data = partA + partB
35
34
  data = shuffleSequence(data)
36
35
  await bfile.writeBytes(tempFile, data)
37
- await bzip.sevenUnzip(tempFile, workspace)
38
- await bpath.removeSecure(file)
39
- bcolor.printGreen(workspace)
36
+ tempPath = target.with_suffix('.tmp')
37
+ await bzip.sevenUnzip(tempFile, tempPath)
38
+
39
+ # 调整文件权限,完全擦除
40
+ target.chmod(stat.S_IWRITE)
41
+ await bpath.removeSecure(target)
42
+
43
+ bpath.move(tempPath, target)
40
44
  bcolor.printGreen('OK')
41
45
 
42
46
 
43
47
  @app.command()
44
48
  @syncCall
45
49
  async def zip(
46
- workspace: Path = typer.Argument(Path.cwd(), help='输出目录'),
50
+ target: Path = typer.Argument(Path.cwd(), help='输出目录'),
47
51
  password: str = typer.Option('', '--password', '-p', help='密码'),
48
52
  ):
49
53
  '将目录压缩成加密文件'
50
- workspace = workspace.absolute()
51
- assert workspace.is_dir(), f'不是目录 {workspace}'
52
- zipFile = workspace.with_suffix('.dat')
53
- assert not zipFile.exists(), f'文件已存在 {zipFile}'
54
+ target = target.absolute()
55
+ assert target.is_dir(), f'不是目录 {target}'
54
56
  password = password or genPassword()
55
57
  with bpath.useTempFile() as tempFile:
56
- await bzip.sevenZipFolder(tempFile, workspace)
58
+ await bzip.sevenZipFolder(tempFile, target)
57
59
  data = await bfile.readBytes(tempFile)
58
- bpath.remove(tempFile)
60
+ bpath.remove(tempFile) # 为了安全所以立即删除
59
61
  data = shuffleSequence(data)
60
62
  if len(data) < MAX_ENCRYPT_SIZE:
61
63
  data = bcrypto.encrypt(data, password)
@@ -63,9 +65,17 @@ async def zip(
63
65
  partA, partB = data[:MAX_ENCRYPT_SIZE], data[MAX_ENCRYPT_SIZE:]
64
66
  partA = bcrypto.encrypt(partA, password)
65
67
  data = partA + SEP + partB
66
- await bfile.writeBytes(zipFile, data)
67
- await bpath.removeSecure(workspace)
68
- bcolor.printGreen(zipFile)
68
+ tempZipFile = target.with_suffix('.tmp')
69
+ await bfile.writeBytes(tempZipFile, data)
70
+
71
+ # 调整目录权限,完全擦除
72
+ target.chmod(stat.S_IWRITE)
73
+ for file in target.glob('**/*'):
74
+ file.chmod(stat.S_IWRITE)
75
+ await bpath.removeSecure(target)
76
+
77
+ bpath.move(tempZipFile, target)
78
+
69
79
  bcolor.printGreen('OK')
70
80
 
71
81
 
@@ -77,9 +87,8 @@ async def change_pass(
77
87
  new_password: str = typer.Option('', '--new-password', '-n', help='新密码'),
78
88
  ):
79
89
  with bpath.useTempPath() as tempPath:
80
- tempFile = tempPath / file.name
81
- bpath.copy(file, tempFile)
82
- unzip(tempFile, password)
83
- workspace = tempFile.with_suffix('')
84
- zip(workspace, new_password)
85
- bpath.copy(tempFile, file)
90
+ target = tempPath / file.name
91
+ bpath.copy(file, target)
92
+ unzip(target, password)
93
+ zip(target, new_password)
94
+ bpath.copy(target, file)
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: bcmd
3
- Version: 0.5.13
3
+ Version: 0.5.15
4
4
  Summary: Commands for Beni
5
5
  Author-email: Beni Mang <benimang@126.com>
6
6
  Maintainer-email: Beni Mang <benimang@126.com>
7
7
  Keywords: benimang,beni,bcmd
8
8
  Requires-Python: >=3.10
9
- Requires-Dist: benimang==0.7.13
9
+ Requires-Dist: benimang==0.7.14
10
10
  Requires-Dist: build
11
11
  Requires-Dist: cryptography
12
12
  Requires-Dist: pathspec
@@ -1,4 +1,4 @@
1
- benimang==0.7.13
1
+ benimang==0.7.14
2
2
  build
3
3
  cryptography
4
4
  pathspec
@@ -3,7 +3,7 @@
3
3
 
4
4
  [project]
5
5
  name = 'bcmd'
6
- version = '0.5.13'
6
+ version = '0.5.15'
7
7
  description = 'Commands for Beni'
8
8
  requires-python = '>=3.10'
9
9
  keywords = ['benimang', 'beni', 'bcmd']
@@ -12,7 +12,7 @@ maintainers = [{ name = 'Beni Mang', email = 'benimang@126.com' }]
12
12
 
13
13
 
14
14
  dependencies = [
15
- 'benimang==0.7.13',
15
+ 'benimang==0.7.14',
16
16
  'build',
17
17
  'cryptography',
18
18
  'pathspec',
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