jjb-cmd 2.5.2 → 2.5.4
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.
- package/SECURITY.md +71 -0
- package/bin/command.js +15 -11
- package/build.js +20 -0
- package/obf.config.json +3 -0
- package/package.json +11 -8
- package/src/ai-pull.js +675 -0
- package/src/auth.js +71 -1
- package/src/code-optimization.js +46 -1
- package/src/config.js +122 -1
- package/src/crypto-utils.js +183 -1
- package/src/password-input.js +79 -1
- package/src/publish.js +307 -1
- package/src/push.js +417 -1
- package/src/rm-rf.js +49 -1
- package/src/utils.js +228 -1
package/SECURITY.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# 安全优化说明
|
|
2
|
+
|
|
3
|
+
## 认证安全优化
|
|
4
|
+
|
|
5
|
+
本项目已对认证系统进行了安全优化,主要改进包括:
|
|
6
|
+
|
|
7
|
+
### 🔐 加密存储
|
|
8
|
+
- **之前**: 用户名和密码以明文形式存储在 `.auth` 文件中
|
|
9
|
+
- **现在**: 使用 AES-256-CBC 加密算法对认证信息进行加密存储
|
|
10
|
+
|
|
11
|
+
### 🔒 密码输入安全
|
|
12
|
+
- **之前**: 命令行输入密码时明文显示,存在安全风险
|
|
13
|
+
- **现在**: 支持多种安全的密码输入方式
|
|
14
|
+
- 交互式隐藏输入:密码输入时显示 `*` 字符
|
|
15
|
+
- 支持只提供用户名,密码安全输入
|
|
16
|
+
- 支持完全交互式登录
|
|
17
|
+
|
|
18
|
+
### 🛡️ 安全特性
|
|
19
|
+
1. **设备绑定**: 基于系统信息生成唯一设备密钥,确保认证信息只能在当前设备上解密
|
|
20
|
+
2. **文件权限**: 认证文件权限设置为 `0o600`,仅文件所有者可读写
|
|
21
|
+
3. **盐值随机化**: 每次加密都使用随机盐值,防止彩虹表攻击
|
|
22
|
+
4. **密钥派生**: 使用 PBKDF2 算法派生加密密钥,增强安全性
|
|
23
|
+
|
|
24
|
+
### 🔧 技术实现
|
|
25
|
+
- 使用 Node.js 内置 `crypto` 模块
|
|
26
|
+
- AES-256-CBC 加密算法
|
|
27
|
+
- PBKDF2 密钥派生函数(100,000 次迭代)
|
|
28
|
+
-
|
|
29
|
+
|
|
30
|
+
### 📁 文件变更
|
|
31
|
+
- `src/crypto-utils.js` - 新增加密工具模块
|
|
32
|
+
- `src/password-input.js` - 新增安全密码输入模块
|
|
33
|
+
- `src/auth.js` - 更新为使用加密存储和安全密码输入
|
|
34
|
+
- `src/push.js` - 更新为使用解密读取
|
|
35
|
+
- `src/publish.js` - 更新为使用解密读取
|
|
36
|
+
- `bin/command.js` - 更新为支持异步认证
|
|
37
|
+
|
|
38
|
+
### ⚠️ 注意事项
|
|
39
|
+
1. 认证信息与设备绑定,更换设备需要重新登录
|
|
40
|
+
2. 如果系统信息发生变化,可能需要重新登录
|
|
41
|
+
3. 建议定期更新密码以增强安全性
|
|
42
|
+
|
|
43
|
+
### 🔄 向后兼容
|
|
44
|
+
- 新版本会自动处理旧的明文认证文件
|
|
45
|
+
- 首次使用时会自动迁移到加密存储
|
|
46
|
+
|
|
47
|
+
### 📖 使用说明
|
|
48
|
+
|
|
49
|
+
#### 安全登录方式
|
|
50
|
+
1. **完全交互式登录**(推荐):
|
|
51
|
+
```bash
|
|
52
|
+
jjb-cmd auth
|
|
53
|
+
# 系统会提示输入用户名和密码,密码输入时显示 * 字符
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
2. **只提供用户名**:
|
|
57
|
+
```bash
|
|
58
|
+
jjb-cmd auth myusername
|
|
59
|
+
# 系统会提示输入密码,密码输入时显示 * 字符
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
3. **传统命令行方式**(不推荐,密码会明文显示):
|
|
63
|
+
```bash
|
|
64
|
+
jjb-cmd auth myusername mypassword
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### 安全特性
|
|
68
|
+
- 密码输入时自动隐藏显示
|
|
69
|
+
- 支持 Ctrl+C 取消输入
|
|
70
|
+
- 支持 Backspace 删除输入
|
|
71
|
+
- 认证信息加密存储,与设备绑定
|
package/bin/command.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const commander = require('commander');
|
|
4
|
-
// const readline = require('readline');
|
|
5
4
|
const path = require('path');
|
|
6
5
|
const fs = require('fs');
|
|
7
|
-
// const child_process = require('child_process');
|
|
8
6
|
|
|
9
7
|
commander.command('v').description('-- 查看版本').action(() => {
|
|
10
8
|
const package_json_file = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json')).toString());
|
|
11
9
|
const {
|
|
12
10
|
version
|
|
13
11
|
} = package_json_file;
|
|
14
|
-
console.log(
|
|
12
|
+
console.log(`当前版本: v${version}`);
|
|
15
13
|
});
|
|
16
14
|
|
|
17
15
|
commander.command('help').description('-- 帮助').action(() => {
|
|
@@ -24,7 +22,8 @@ commander.command('help').description('-- 帮助').action(() => {
|
|
|
24
22
|
console.log('jjb-cmd v 查看版本');
|
|
25
23
|
console.log('jjb-cmd publish <version> 发布云组件\n\targ1 <version> 发布版本,可设置为latest');
|
|
26
24
|
console.log('jjb-cmd auth 登录授权(交互式输入用户名和密码)');
|
|
27
|
-
console.log('jjb-cmd push java
|
|
25
|
+
console.log('jjb-cmd push java 推送微应用到服务器');
|
|
26
|
+
console.log('jjb-cmd ai-pull 拉取 AI 配置文件和规则');
|
|
28
27
|
});
|
|
29
28
|
|
|
30
29
|
// 命令
|
|
@@ -33,8 +32,8 @@ commander.command('auth').description('-- 授权').action(async () => {
|
|
|
33
32
|
});
|
|
34
33
|
|
|
35
34
|
// 优化
|
|
36
|
-
commander.command('opti').description('-- 代码优化').action(args => {
|
|
37
|
-
require('../src/code-optimization')();
|
|
35
|
+
commander.command('opti').description('-- 代码优化').action(async args => {
|
|
36
|
+
await require('../src/code-optimization')();
|
|
38
37
|
});
|
|
39
38
|
|
|
40
39
|
// 发包
|
|
@@ -46,20 +45,25 @@ commander.command('publish [args]').description('-- 发布包').action(args => {
|
|
|
46
45
|
commander.command('push [args]').description('-- 发布包').action(args => {
|
|
47
46
|
if (args) {
|
|
48
47
|
if ([ 'java' ].includes(args)) {
|
|
49
|
-
require('../src/push.js')(
|
|
48
|
+
require('../src/push.js')([]);
|
|
50
49
|
} else {
|
|
51
|
-
console.log(
|
|
50
|
+
console.log(`无效的选项: ${args}`);
|
|
52
51
|
process.exit(0);
|
|
53
52
|
}
|
|
54
53
|
} else {
|
|
55
|
-
console.log(
|
|
54
|
+
console.log(`缺少必要参数,请使用 'jjb-cmd push java'`);
|
|
56
55
|
process.exit(0);
|
|
57
56
|
}
|
|
58
57
|
});
|
|
59
58
|
|
|
60
59
|
// rm-rf 命令
|
|
61
|
-
commander.command('rm-rf').description('-- 删除全部').action(() => {
|
|
62
|
-
require('../src/rm-rf.js')();
|
|
60
|
+
commander.command('rm-rf').description('-- 删除全部').action(async () => {
|
|
61
|
+
await require('../src/rm-rf.js')();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// ai-pull 命令
|
|
65
|
+
commander.command('ai-pull').description('-- 拉取 AI 配置文件和规则').action(() => {
|
|
66
|
+
require('../src/ai-pull.js')();
|
|
63
67
|
});
|
|
64
68
|
|
|
65
69
|
commander.parse(process.argv);
|
package/build.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const child_process = require('child_process');
|
|
2
|
+
const utils = require('./src/utils');
|
|
3
|
+
|
|
4
|
+
// 执行代码混淆
|
|
5
|
+
child_process.execSync(`npx javascript-obfuscator src --output publish/src --config obf.config.json`);
|
|
6
|
+
console.log('obf Done!');
|
|
7
|
+
|
|
8
|
+
// 复制bin目录
|
|
9
|
+
utils.CopyFolder('./bin', './publish/bin', () => {
|
|
10
|
+
console.log('bin Folder Done!');
|
|
11
|
+
|
|
12
|
+
// 复制其他文件
|
|
13
|
+
utils.CopyFile('./package.json', './publish/package.json', () => {
|
|
14
|
+
utils.CopyFile('./README.md', './publish/README.md', () => {
|
|
15
|
+
utils.CopyFile('./LICENSE', './publish/LICENSE', () => {
|
|
16
|
+
console.log('ALL Done !');
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
});
|
package/obf.config.json
ADDED
package/package.json
CHANGED
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
"env": "prod",
|
|
5
5
|
"httpMethod": "http",
|
|
6
6
|
"pushMessage": "yes",
|
|
7
|
-
"version": "2.5.
|
|
7
|
+
"version": "2.5.4",
|
|
8
8
|
"description": "jjb-cmd命令行工具",
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "node bin/command.js help",
|
|
12
|
-
"install:package": "npm i"
|
|
12
|
+
"install:package": "npm i",
|
|
13
|
+
"test:ai-pull": "node bin/command.js ai-pull"
|
|
13
14
|
},
|
|
14
15
|
"bin": {
|
|
15
16
|
"jjb-cmd": "bin/command.js"
|
|
@@ -17,20 +18,22 @@
|
|
|
17
18
|
"author": "jiaoxiwei",
|
|
18
19
|
"license": "MIT",
|
|
19
20
|
"dependencies": {
|
|
20
|
-
"@
|
|
21
|
-
"chalk": "2.4.0",
|
|
22
|
-
"prettier": "^3.3.3",
|
|
23
|
-
"@babel/traverse": "^7.25.9",
|
|
21
|
+
"@babel/core": "^7.19.3",
|
|
24
22
|
"@babel/generator": "^7.26.0",
|
|
25
23
|
"@babel/parser": "^7.26.1",
|
|
26
24
|
"@babel/preset-env": "^7.23.2",
|
|
27
|
-
"@babel/preset-typescript": "^7.23.2",
|
|
28
|
-
"@babel/core": "^7.19.3",
|
|
29
25
|
"@babel/preset-react": "^7.18.6",
|
|
26
|
+
"@babel/preset-typescript": "^7.23.2",
|
|
27
|
+
"@babel/traverse": "^7.25.9",
|
|
28
|
+
"@cqsjjb/react-code-optimization": "^0.0.2",
|
|
30
29
|
"axios": "^1.1.3",
|
|
30
|
+
"better-sqlite3": "^12.6.2",
|
|
31
|
+
"chalk": "2.4.0",
|
|
31
32
|
"commander": "^1.3.2",
|
|
32
33
|
"compressing": "^1.5.1",
|
|
34
|
+
"inquirer": "^8.2.7",
|
|
33
35
|
"jenkins": "^1.0.2",
|
|
36
|
+
"prettier": "^3.3.3",
|
|
34
37
|
"request": "2.88.2",
|
|
35
38
|
"single-line-log": "1.1.2"
|
|
36
39
|
}
|