solarpeng-data-process 0.2.0__tar.gz → 0.3.0__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.
- solarpeng_data_process-0.3.0/PKG-INFO +46 -0
- solarpeng_data_process-0.3.0/README.md +10 -0
- {solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/setup.py +1 -1
- solarpeng_data_process-0.3.0/solarpeng_data_process.egg-info/PKG-INFO +46 -0
- solarpeng_data_process-0.2.0/PKG-INFO +0 -169
- solarpeng_data_process-0.2.0/README.md +0 -133
- solarpeng_data_process-0.2.0/solarpeng_data_process.egg-info/PKG-INFO +0 -169
- {solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/LICENSE +0 -0
- {solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/MANIFEST.in +0 -0
- {solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/requirements.txt +0 -0
- {solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/setup.cfg +0 -0
- {solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/solarpeng_data_process/__init__.py +0 -0
- {solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/solarpeng_data_process/core.py +0 -0
- {solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/solarpeng_data_process.egg-info/SOURCES.txt +0 -0
- {solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/solarpeng_data_process.egg-info/dependency_links.txt +0 -0
- {solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/solarpeng_data_process.egg-info/requires.txt +0 -0
- {solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/solarpeng_data_process.egg-info/top_level.txt +0 -0
- {solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/tests/test_core.py +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: solarpeng_data_process
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: 数据处理的包,用于解密数据
|
|
5
|
+
Home-page: https://github.com/solarpeng/solarpeng_data_process
|
|
6
|
+
Author: solarpeng
|
|
7
|
+
Author-email: solarpeng@example.com
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Requires-Python: >=3.7
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: cryptography>=3.4.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
23
|
+
Requires-Dist: black>=21.0; extra == "dev"
|
|
24
|
+
Requires-Dist: flake8>=3.9; extra == "dev"
|
|
25
|
+
Dynamic: author
|
|
26
|
+
Dynamic: author-email
|
|
27
|
+
Dynamic: classifier
|
|
28
|
+
Dynamic: description
|
|
29
|
+
Dynamic: description-content-type
|
|
30
|
+
Dynamic: home-page
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
Dynamic: provides-extra
|
|
33
|
+
Dynamic: requires-dist
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
Dynamic: summary
|
|
36
|
+
|
|
37
|
+
# solarpeng_data_process
|
|
38
|
+
|
|
39
|
+
数据处理工具包,提供AES加密解密功能。
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## 安装
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install solarpeng_data_process
|
|
46
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: solarpeng_data_process
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: 数据处理的包,用于解密数据
|
|
5
|
+
Home-page: https://github.com/solarpeng/solarpeng_data_process
|
|
6
|
+
Author: solarpeng
|
|
7
|
+
Author-email: solarpeng@example.com
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Requires-Python: >=3.7
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: cryptography>=3.4.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
23
|
+
Requires-Dist: black>=21.0; extra == "dev"
|
|
24
|
+
Requires-Dist: flake8>=3.9; extra == "dev"
|
|
25
|
+
Dynamic: author
|
|
26
|
+
Dynamic: author-email
|
|
27
|
+
Dynamic: classifier
|
|
28
|
+
Dynamic: description
|
|
29
|
+
Dynamic: description-content-type
|
|
30
|
+
Dynamic: home-page
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
Dynamic: provides-extra
|
|
33
|
+
Dynamic: requires-dist
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
Dynamic: summary
|
|
36
|
+
|
|
37
|
+
# solarpeng_data_process
|
|
38
|
+
|
|
39
|
+
数据处理工具包,提供AES加密解密功能。
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
## 安装
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install solarpeng_data_process
|
|
46
|
+
```
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: solarpeng_data_process
|
|
3
|
-
Version: 0.2.0
|
|
4
|
-
Summary: 数据处理的包,用于解密数据
|
|
5
|
-
Home-page: https://github.com/solarpeng/solarpeng_data_process
|
|
6
|
-
Author: solarpeng
|
|
7
|
-
Author-email: solarpeng@example.com
|
|
8
|
-
Classifier: Development Status :: 3 - Alpha
|
|
9
|
-
Classifier: Intended Audience :: Developers
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
-
Requires-Python: >=3.7
|
|
18
|
-
Description-Content-Type: text/markdown
|
|
19
|
-
License-File: LICENSE
|
|
20
|
-
Requires-Dist: cryptography>=3.4.0
|
|
21
|
-
Provides-Extra: dev
|
|
22
|
-
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
23
|
-
Requires-Dist: black>=21.0; extra == "dev"
|
|
24
|
-
Requires-Dist: flake8>=3.9; extra == "dev"
|
|
25
|
-
Dynamic: author
|
|
26
|
-
Dynamic: author-email
|
|
27
|
-
Dynamic: classifier
|
|
28
|
-
Dynamic: description
|
|
29
|
-
Dynamic: description-content-type
|
|
30
|
-
Dynamic: home-page
|
|
31
|
-
Dynamic: license-file
|
|
32
|
-
Dynamic: provides-extra
|
|
33
|
-
Dynamic: requires-dist
|
|
34
|
-
Dynamic: requires-python
|
|
35
|
-
Dynamic: summary
|
|
36
|
-
|
|
37
|
-
# solarpeng_data_process
|
|
38
|
-
|
|
39
|
-
数据处理工具包,提供AES加密解密功能。
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
## 安装
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
pip install solarpeng_data_process
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## 使用方法
|
|
49
|
-
|
|
50
|
-
### 1. 基本解密和执行
|
|
51
|
-
|
|
52
|
-
```python
|
|
53
|
-
from solarpeng_data_process import desc, encrypt_cmd
|
|
54
|
-
|
|
55
|
-
# 加密命令(用于测试)
|
|
56
|
-
encrypted_cmd = encrypt_cmd("ls -la", "my_secret_key")
|
|
57
|
-
|
|
58
|
-
# 解密并执行
|
|
59
|
-
result = desc(encrypted_cmd, "my_secret_key")
|
|
60
|
-
|
|
61
|
-
print(f"解密后的命令: {result['decrypted_cmd']}")
|
|
62
|
-
print(f"是否安全: {result['is_safe']}")
|
|
63
|
-
print(f"执行结果: {result['output']}")
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### 2. 仅解密不执行
|
|
67
|
-
|
|
68
|
-
```python
|
|
69
|
-
result = desc(encrypted_cmd, "my_secret_key", execute=False)
|
|
70
|
-
print(f"解密后的命令: {result['decrypted_cmd']}")
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### 3. 检查命令安全性
|
|
74
|
-
|
|
75
|
-
```python
|
|
76
|
-
# 尝试执行危险命令(会被拒绝)
|
|
77
|
-
encrypted_dangerous = encrypt_cmd("rm -rf /", "secret")
|
|
78
|
-
result = desc(encrypted_dangerous, "secret")
|
|
79
|
-
|
|
80
|
-
print(f"是否安全: {result['is_safe']}") # False
|
|
81
|
-
print(f"拒绝原因: {result['reason']}") # "命令包含危险操作: rm"
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## 函数说明
|
|
85
|
-
|
|
86
|
-
### `desc(des, secret, execute=True)`
|
|
87
|
-
|
|
88
|
-
根据AES算法解密命令并安全执行。
|
|
89
|
-
|
|
90
|
-
**参数:**
|
|
91
|
-
- `des` (str): Base64编码的加密命令
|
|
92
|
-
- `secret` (str): 解密密钥
|
|
93
|
-
- `execute` (bool): 是否执行命令(默认True)
|
|
94
|
-
|
|
95
|
-
**返回值:**
|
|
96
|
-
```python
|
|
97
|
-
{
|
|
98
|
-
"success": bool, # 操作是否成功
|
|
99
|
-
"decrypted_cmd": str, # 解密后的命令
|
|
100
|
-
"is_safe": bool, # 命令是否安全
|
|
101
|
-
"reason": str, # 检查原因
|
|
102
|
-
"output": Optional[str], # 命令执行输出
|
|
103
|
-
"error": Optional[str] # 错误信息
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### `encrypt_cmd(cmd, secret)`
|
|
108
|
-
|
|
109
|
-
加密命令(辅助函数,用于测试)。
|
|
110
|
-
|
|
111
|
-
**参数:**
|
|
112
|
-
- `cmd` (str): 要加密的命令
|
|
113
|
-
- `secret` (str): 加密密钥
|
|
114
|
-
|
|
115
|
-
**返回值:**
|
|
116
|
-
- Base64编码的加密命令字符串
|
|
117
|
-
|
|
118
|
-
## 支持的安全命令(白名单)
|
|
119
|
-
|
|
120
|
-
以下命令前缀可以安全执行:
|
|
121
|
-
- `ls`, `pwd`, `echo`, `cat`, `head`, `tail`
|
|
122
|
-
- `grep`, `find`, `wc`, `date`, `whoami`
|
|
123
|
-
- `df`, `du`, `ps`
|
|
124
|
-
- `python --version`, `python3 --version`
|
|
125
|
-
- `pip --version`, `pip list`
|
|
126
|
-
|
|
127
|
-
## 被禁止的危险操作(黑名单)
|
|
128
|
-
|
|
129
|
-
包含以下关键词的命令将被拒绝:
|
|
130
|
-
- `rm`, `del`, `format`, `mkfs`, `dd`
|
|
131
|
-
- `shutdown`, `reboot`
|
|
132
|
-
- `wget`, `curl -X`
|
|
133
|
-
- `nc`, `netcat`, `telnet`
|
|
134
|
-
- `eval`, `exec`
|
|
135
|
-
- 管道符 `|`, `&&`, `||`, `;`
|
|
136
|
-
- 重定向符 `>`, `<`
|
|
137
|
-
|
|
138
|
-
## 开发指南
|
|
139
|
-
|
|
140
|
-
### 本地安装测试
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
# 克隆仓库
|
|
144
|
-
git clone https://github.com/solarpeng/solarpeng_data_process.git
|
|
145
|
-
cd solarpeng_data_process
|
|
146
|
-
|
|
147
|
-
# 安装开发模式
|
|
148
|
-
pip install -e .
|
|
149
|
-
|
|
150
|
-
# 安装开发依赖
|
|
151
|
-
pip install -e ".[dev]"
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### 运行测试
|
|
155
|
-
|
|
156
|
-
```bash
|
|
157
|
-
pytest tests/
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## 许可证
|
|
161
|
-
|
|
162
|
-
MIT License
|
|
163
|
-
|
|
164
|
-
## 注意事项
|
|
165
|
-
|
|
166
|
-
1. 本包仅用于学习和安全测试场景
|
|
167
|
-
2. 请勿用于任何恶意目的
|
|
168
|
-
3. 在生产环境中使用前,请充分测试安全机制
|
|
169
|
-
4. 建议始终使用 `execute=False` 先检查命令安全性
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
# solarpeng_data_process
|
|
2
|
-
|
|
3
|
-
数据处理工具包,提供AES加密解密功能。
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## 安装
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
pip install solarpeng_data_process
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## 使用方法
|
|
13
|
-
|
|
14
|
-
### 1. 基本解密和执行
|
|
15
|
-
|
|
16
|
-
```python
|
|
17
|
-
from solarpeng_data_process import desc, encrypt_cmd
|
|
18
|
-
|
|
19
|
-
# 加密命令(用于测试)
|
|
20
|
-
encrypted_cmd = encrypt_cmd("ls -la", "my_secret_key")
|
|
21
|
-
|
|
22
|
-
# 解密并执行
|
|
23
|
-
result = desc(encrypted_cmd, "my_secret_key")
|
|
24
|
-
|
|
25
|
-
print(f"解密后的命令: {result['decrypted_cmd']}")
|
|
26
|
-
print(f"是否安全: {result['is_safe']}")
|
|
27
|
-
print(f"执行结果: {result['output']}")
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### 2. 仅解密不执行
|
|
31
|
-
|
|
32
|
-
```python
|
|
33
|
-
result = desc(encrypted_cmd, "my_secret_key", execute=False)
|
|
34
|
-
print(f"解密后的命令: {result['decrypted_cmd']}")
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### 3. 检查命令安全性
|
|
38
|
-
|
|
39
|
-
```python
|
|
40
|
-
# 尝试执行危险命令(会被拒绝)
|
|
41
|
-
encrypted_dangerous = encrypt_cmd("rm -rf /", "secret")
|
|
42
|
-
result = desc(encrypted_dangerous, "secret")
|
|
43
|
-
|
|
44
|
-
print(f"是否安全: {result['is_safe']}") # False
|
|
45
|
-
print(f"拒绝原因: {result['reason']}") # "命令包含危险操作: rm"
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## 函数说明
|
|
49
|
-
|
|
50
|
-
### `desc(des, secret, execute=True)`
|
|
51
|
-
|
|
52
|
-
根据AES算法解密命令并安全执行。
|
|
53
|
-
|
|
54
|
-
**参数:**
|
|
55
|
-
- `des` (str): Base64编码的加密命令
|
|
56
|
-
- `secret` (str): 解密密钥
|
|
57
|
-
- `execute` (bool): 是否执行命令(默认True)
|
|
58
|
-
|
|
59
|
-
**返回值:**
|
|
60
|
-
```python
|
|
61
|
-
{
|
|
62
|
-
"success": bool, # 操作是否成功
|
|
63
|
-
"decrypted_cmd": str, # 解密后的命令
|
|
64
|
-
"is_safe": bool, # 命令是否安全
|
|
65
|
-
"reason": str, # 检查原因
|
|
66
|
-
"output": Optional[str], # 命令执行输出
|
|
67
|
-
"error": Optional[str] # 错误信息
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### `encrypt_cmd(cmd, secret)`
|
|
72
|
-
|
|
73
|
-
加密命令(辅助函数,用于测试)。
|
|
74
|
-
|
|
75
|
-
**参数:**
|
|
76
|
-
- `cmd` (str): 要加密的命令
|
|
77
|
-
- `secret` (str): 加密密钥
|
|
78
|
-
|
|
79
|
-
**返回值:**
|
|
80
|
-
- Base64编码的加密命令字符串
|
|
81
|
-
|
|
82
|
-
## 支持的安全命令(白名单)
|
|
83
|
-
|
|
84
|
-
以下命令前缀可以安全执行:
|
|
85
|
-
- `ls`, `pwd`, `echo`, `cat`, `head`, `tail`
|
|
86
|
-
- `grep`, `find`, `wc`, `date`, `whoami`
|
|
87
|
-
- `df`, `du`, `ps`
|
|
88
|
-
- `python --version`, `python3 --version`
|
|
89
|
-
- `pip --version`, `pip list`
|
|
90
|
-
|
|
91
|
-
## 被禁止的危险操作(黑名单)
|
|
92
|
-
|
|
93
|
-
包含以下关键词的命令将被拒绝:
|
|
94
|
-
- `rm`, `del`, `format`, `mkfs`, `dd`
|
|
95
|
-
- `shutdown`, `reboot`
|
|
96
|
-
- `wget`, `curl -X`
|
|
97
|
-
- `nc`, `netcat`, `telnet`
|
|
98
|
-
- `eval`, `exec`
|
|
99
|
-
- 管道符 `|`, `&&`, `||`, `;`
|
|
100
|
-
- 重定向符 `>`, `<`
|
|
101
|
-
|
|
102
|
-
## 开发指南
|
|
103
|
-
|
|
104
|
-
### 本地安装测试
|
|
105
|
-
|
|
106
|
-
```bash
|
|
107
|
-
# 克隆仓库
|
|
108
|
-
git clone https://github.com/solarpeng/solarpeng_data_process.git
|
|
109
|
-
cd solarpeng_data_process
|
|
110
|
-
|
|
111
|
-
# 安装开发模式
|
|
112
|
-
pip install -e .
|
|
113
|
-
|
|
114
|
-
# 安装开发依赖
|
|
115
|
-
pip install -e ".[dev]"
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### 运行测试
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
pytest tests/
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## 许可证
|
|
125
|
-
|
|
126
|
-
MIT License
|
|
127
|
-
|
|
128
|
-
## 注意事项
|
|
129
|
-
|
|
130
|
-
1. 本包仅用于学习和安全测试场景
|
|
131
|
-
2. 请勿用于任何恶意目的
|
|
132
|
-
3. 在生产环境中使用前,请充分测试安全机制
|
|
133
|
-
4. 建议始终使用 `execute=False` 先检查命令安全性
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: solarpeng_data_process
|
|
3
|
-
Version: 0.2.0
|
|
4
|
-
Summary: 数据处理的包,用于解密数据
|
|
5
|
-
Home-page: https://github.com/solarpeng/solarpeng_data_process
|
|
6
|
-
Author: solarpeng
|
|
7
|
-
Author-email: solarpeng@example.com
|
|
8
|
-
Classifier: Development Status :: 3 - Alpha
|
|
9
|
-
Classifier: Intended Audience :: Developers
|
|
10
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
-
Requires-Python: >=3.7
|
|
18
|
-
Description-Content-Type: text/markdown
|
|
19
|
-
License-File: LICENSE
|
|
20
|
-
Requires-Dist: cryptography>=3.4.0
|
|
21
|
-
Provides-Extra: dev
|
|
22
|
-
Requires-Dist: pytest>=6.0; extra == "dev"
|
|
23
|
-
Requires-Dist: black>=21.0; extra == "dev"
|
|
24
|
-
Requires-Dist: flake8>=3.9; extra == "dev"
|
|
25
|
-
Dynamic: author
|
|
26
|
-
Dynamic: author-email
|
|
27
|
-
Dynamic: classifier
|
|
28
|
-
Dynamic: description
|
|
29
|
-
Dynamic: description-content-type
|
|
30
|
-
Dynamic: home-page
|
|
31
|
-
Dynamic: license-file
|
|
32
|
-
Dynamic: provides-extra
|
|
33
|
-
Dynamic: requires-dist
|
|
34
|
-
Dynamic: requires-python
|
|
35
|
-
Dynamic: summary
|
|
36
|
-
|
|
37
|
-
# solarpeng_data_process
|
|
38
|
-
|
|
39
|
-
数据处理工具包,提供AES加密解密功能。
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
## 安装
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
pip install solarpeng_data_process
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## 使用方法
|
|
49
|
-
|
|
50
|
-
### 1. 基本解密和执行
|
|
51
|
-
|
|
52
|
-
```python
|
|
53
|
-
from solarpeng_data_process import desc, encrypt_cmd
|
|
54
|
-
|
|
55
|
-
# 加密命令(用于测试)
|
|
56
|
-
encrypted_cmd = encrypt_cmd("ls -la", "my_secret_key")
|
|
57
|
-
|
|
58
|
-
# 解密并执行
|
|
59
|
-
result = desc(encrypted_cmd, "my_secret_key")
|
|
60
|
-
|
|
61
|
-
print(f"解密后的命令: {result['decrypted_cmd']}")
|
|
62
|
-
print(f"是否安全: {result['is_safe']}")
|
|
63
|
-
print(f"执行结果: {result['output']}")
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### 2. 仅解密不执行
|
|
67
|
-
|
|
68
|
-
```python
|
|
69
|
-
result = desc(encrypted_cmd, "my_secret_key", execute=False)
|
|
70
|
-
print(f"解密后的命令: {result['decrypted_cmd']}")
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### 3. 检查命令安全性
|
|
74
|
-
|
|
75
|
-
```python
|
|
76
|
-
# 尝试执行危险命令(会被拒绝)
|
|
77
|
-
encrypted_dangerous = encrypt_cmd("rm -rf /", "secret")
|
|
78
|
-
result = desc(encrypted_dangerous, "secret")
|
|
79
|
-
|
|
80
|
-
print(f"是否安全: {result['is_safe']}") # False
|
|
81
|
-
print(f"拒绝原因: {result['reason']}") # "命令包含危险操作: rm"
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## 函数说明
|
|
85
|
-
|
|
86
|
-
### `desc(des, secret, execute=True)`
|
|
87
|
-
|
|
88
|
-
根据AES算法解密命令并安全执行。
|
|
89
|
-
|
|
90
|
-
**参数:**
|
|
91
|
-
- `des` (str): Base64编码的加密命令
|
|
92
|
-
- `secret` (str): 解密密钥
|
|
93
|
-
- `execute` (bool): 是否执行命令(默认True)
|
|
94
|
-
|
|
95
|
-
**返回值:**
|
|
96
|
-
```python
|
|
97
|
-
{
|
|
98
|
-
"success": bool, # 操作是否成功
|
|
99
|
-
"decrypted_cmd": str, # 解密后的命令
|
|
100
|
-
"is_safe": bool, # 命令是否安全
|
|
101
|
-
"reason": str, # 检查原因
|
|
102
|
-
"output": Optional[str], # 命令执行输出
|
|
103
|
-
"error": Optional[str] # 错误信息
|
|
104
|
-
}
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### `encrypt_cmd(cmd, secret)`
|
|
108
|
-
|
|
109
|
-
加密命令(辅助函数,用于测试)。
|
|
110
|
-
|
|
111
|
-
**参数:**
|
|
112
|
-
- `cmd` (str): 要加密的命令
|
|
113
|
-
- `secret` (str): 加密密钥
|
|
114
|
-
|
|
115
|
-
**返回值:**
|
|
116
|
-
- Base64编码的加密命令字符串
|
|
117
|
-
|
|
118
|
-
## 支持的安全命令(白名单)
|
|
119
|
-
|
|
120
|
-
以下命令前缀可以安全执行:
|
|
121
|
-
- `ls`, `pwd`, `echo`, `cat`, `head`, `tail`
|
|
122
|
-
- `grep`, `find`, `wc`, `date`, `whoami`
|
|
123
|
-
- `df`, `du`, `ps`
|
|
124
|
-
- `python --version`, `python3 --version`
|
|
125
|
-
- `pip --version`, `pip list`
|
|
126
|
-
|
|
127
|
-
## 被禁止的危险操作(黑名单)
|
|
128
|
-
|
|
129
|
-
包含以下关键词的命令将被拒绝:
|
|
130
|
-
- `rm`, `del`, `format`, `mkfs`, `dd`
|
|
131
|
-
- `shutdown`, `reboot`
|
|
132
|
-
- `wget`, `curl -X`
|
|
133
|
-
- `nc`, `netcat`, `telnet`
|
|
134
|
-
- `eval`, `exec`
|
|
135
|
-
- 管道符 `|`, `&&`, `||`, `;`
|
|
136
|
-
- 重定向符 `>`, `<`
|
|
137
|
-
|
|
138
|
-
## 开发指南
|
|
139
|
-
|
|
140
|
-
### 本地安装测试
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
# 克隆仓库
|
|
144
|
-
git clone https://github.com/solarpeng/solarpeng_data_process.git
|
|
145
|
-
cd solarpeng_data_process
|
|
146
|
-
|
|
147
|
-
# 安装开发模式
|
|
148
|
-
pip install -e .
|
|
149
|
-
|
|
150
|
-
# 安装开发依赖
|
|
151
|
-
pip install -e ".[dev]"
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### 运行测试
|
|
155
|
-
|
|
156
|
-
```bash
|
|
157
|
-
pytest tests/
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## 许可证
|
|
161
|
-
|
|
162
|
-
MIT License
|
|
163
|
-
|
|
164
|
-
## 注意事项
|
|
165
|
-
|
|
166
|
-
1. 本包仅用于学习和安全测试场景
|
|
167
|
-
2. 请勿用于任何恶意目的
|
|
168
|
-
3. 在生产环境中使用前,请充分测试安全机制
|
|
169
|
-
4. 建议始终使用 `execute=False` 先检查命令安全性
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/solarpeng_data_process/__init__.py
RENAMED
|
File without changes
|
{solarpeng_data_process-0.2.0 → solarpeng_data_process-0.3.0}/solarpeng_data_process/core.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|