@ghyper9023/u2secure 0.3.0
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/README.md +10 -0
- package/bin/install.js +81 -0
- package/bin/u2secure-wrapper.js +9 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# u2secure
|
|
2
|
+
|
|
3
|
+
Linux 服务器安全加固工具(CLI + TUI 双模式),基于 Rust 构建。运行一次即可完成从系统更新、用户创建、SSH 深度加固、防火墙、入侵防御、审计到自动更新的完整安全基线建设。
|
|
4
|
+
|
|
5
|
+
> Linux server security hardening tool (CLI + TUI) built with Rust. One run builds a complete security baseline: system updates, user creation, deep SSH hardening, firewall, intrusion prevention, auditing and automatic updates.
|
|
6
|
+
>
|
|
7
|
+
> 支持平台 / Supported platforms: Linux x86_64 & ARM64, macOS x86_64 & ARM64, Windows x64
|
|
8
|
+
>
|
|
9
|
+
> 详细文档与使用指南请访问 / For full documentation and usage guide, visit:
|
|
10
|
+
> [GitHub 主页](https://github.com/cherish-ltt/U2Secure)
|
package/bin/install.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const { https } = require('follow-redirects');
|
|
7
|
+
|
|
8
|
+
const pkgJson = require('../package.json');
|
|
9
|
+
const version = pkgJson.version;
|
|
10
|
+
const repoUrl = pkgJson.repository && pkgJson.repository.url;
|
|
11
|
+
if (!repoUrl) {
|
|
12
|
+
console.error('Missing repository.url in package.json');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
const match = repoUrl.match(/github\.com[\/:]([^\/]+\/[^\/]+)(\.git)?$/);
|
|
16
|
+
if (!match) {
|
|
17
|
+
console.error(`Failed to parse owner/repo from repository.url: ${repoUrl}`);
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const repo = match[1];
|
|
21
|
+
const tag = `v${version}`;
|
|
22
|
+
|
|
23
|
+
function getPlatformAsset() {
|
|
24
|
+
const platform = os.platform();
|
|
25
|
+
const arch = os.arch();
|
|
26
|
+
console.log(`Detected platform: ${platform}, arch: ${arch}`);
|
|
27
|
+
|
|
28
|
+
if (platform === 'win32') {
|
|
29
|
+
// Windows: currently only x64 builds are provided.
|
|
30
|
+
if (arch === 'x64' || arch === 'ia32' || arch === 'arm64') {
|
|
31
|
+
console.log('Using Windows x64 binary (compatible with all Windows architectures)');
|
|
32
|
+
return 'u2secure-x86_64-pc-windows-msvc.exe';
|
|
33
|
+
} else {
|
|
34
|
+
throw new Error(`Unsupported Windows architecture: ${arch}`);
|
|
35
|
+
}
|
|
36
|
+
} else if (platform === 'linux') {
|
|
37
|
+
if (arch === 'x64') {
|
|
38
|
+
return 'u2secure-x86_64-unknown-linux-gnu';
|
|
39
|
+
} else if (arch === 'arm64') {
|
|
40
|
+
return 'u2secure-aarch64-unknown-linux-gnu';
|
|
41
|
+
} else {
|
|
42
|
+
throw new Error(`Unsupported Linux architecture: ${arch}`);
|
|
43
|
+
}
|
|
44
|
+
} else if (platform === 'darwin') {
|
|
45
|
+
if (arch === 'arm64') {
|
|
46
|
+
return 'u2secure-aarch64-apple-darwin';
|
|
47
|
+
} else if (arch === 'x64') {
|
|
48
|
+
return 'u2secure-x86_64-apple-darwin';
|
|
49
|
+
} else {
|
|
50
|
+
throw new Error(`Unsupported macOS architecture: ${arch}`);
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const assetName = getPlatformAsset();
|
|
58
|
+
const destDir = path.join(__dirname, 'native');
|
|
59
|
+
const destFile = path.join(destDir, os.platform() === 'win32' ? 'u2secure.exe' : 'u2secure');
|
|
60
|
+
const url = `https://github.com/${repo}/releases/download/${tag}/${assetName}`;
|
|
61
|
+
|
|
62
|
+
console.log(`Downloading from ${url} ...`);
|
|
63
|
+
|
|
64
|
+
if (!fs.existsSync(destDir)) fs.mkdirSync(destDir, { recursive: true });
|
|
65
|
+
|
|
66
|
+
const file = fs.createWriteStream(destFile);
|
|
67
|
+
https.get(url, (response) => {
|
|
68
|
+
if (response.statusCode !== 200) {
|
|
69
|
+
console.error(`Failed to download ${url}: HTTP ${response.statusCode}`);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
response.pipe(file);
|
|
73
|
+
file.on('finish', () => {
|
|
74
|
+
file.close();
|
|
75
|
+
fs.chmodSync(destFile, 0o755);
|
|
76
|
+
console.log(`Binary saved to ${destFile}`);
|
|
77
|
+
});
|
|
78
|
+
}).on('error', (err) => {
|
|
79
|
+
console.error(err);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { spawn } = require('child_process');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
|
|
6
|
+
const exePath = path.join(__dirname, 'native', os.platform() === 'win32' ? 'u2secure.exe' : 'u2secure');
|
|
7
|
+
const args = process.argv.slice(2);
|
|
8
|
+
const child = spawn(exePath, args, { stdio: 'inherit' });
|
|
9
|
+
child.on('exit', (code) => process.exit(code));
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ghyper9023/u2secure",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Make your Linux system more secure through interactive CLI | 通过交互式的 CLI 让你的 Linux 系统更安全",
|
|
5
|
+
"bin": {
|
|
6
|
+
"u2secure": "bin/u2secure-wrapper.js"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"follow-redirects": "^1.16.0"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"provenance": true
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"postinstall": "node bin/install.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"bin"
|
|
20
|
+
],
|
|
21
|
+
"keywords": ["cli", "security", "linux", "hardening", "u2secure"],
|
|
22
|
+
"author": "cherish-ltt",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/cherish-ltt/U2Secure.git"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/cherish-ltt/U2Secure#readme",
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/cherish-ltt/U2Secure/issues"
|
|
31
|
+
}
|
|
32
|
+
}
|