🔒 修复token安全问题:使用环境变量传递而非字符串拼接
Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> Agent-Logs-Url: https://github.com/qinfendebingshuo/guanghulab/sessions/26567be5-dda9-4678-ae0d-e8a021dbde78
This commit is contained in:
parent
72efac6a23
commit
8ce067c62d
|
|
@ -79,8 +79,9 @@ const hubToken = process.env.HUB_TOKEN;
|
||||||
if (hubToken) {
|
if (hubToken) {
|
||||||
try {
|
try {
|
||||||
const start = Date.now();
|
const start = Date.now();
|
||||||
execSync('curl -sf -H "Authorization: token ' + hubToken + '" https://api.github.com/repos/qinfendebingshuo/guanghulab -o /dev/null', {
|
execSync('curl -sf -H "Authorization: token $HUB_TOKEN" https://api.github.com/repos/qinfendebingshuo/guanghulab -o /dev/null', {
|
||||||
timeout: 15000
|
timeout: 15000,
|
||||||
|
env: Object.assign({}, process.env, { HUB_TOKEN: hubToken })
|
||||||
});
|
});
|
||||||
const latency = Date.now() - start;
|
const latency = Date.now() - start;
|
||||||
results.checks.push({
|
results.checks.push({
|
||||||
|
|
@ -97,18 +98,25 @@ if (hubToken) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ⑥ 铸渊连接状态(副控专属)
|
// ⑥ 铸渊连接状态(副控专属)
|
||||||
try {
|
if (hubToken) {
|
||||||
const start = Date.now();
|
try {
|
||||||
execSync(`curl -sf -H "Authorization: token ${hubToken}" https://api.github.com/repos/qinfendebingshuo/guanghulab/dispatches -X POST -d '{"event_type":"ping"}' -o /dev/null 2>/dev/null || true`);
|
const start = Date.now();
|
||||||
const latency = Date.now() - start;
|
execSync('curl -sf -H "Authorization: token $HUB_TOKEN" https://api.github.com/repos/qinfendebingshuo/guanghulab/dispatches -X POST -d \'{"event_type":"ping"}\' -o /dev/null 2>/dev/null || true', {
|
||||||
results.checks.push({
|
timeout: 15000,
|
||||||
name: '铸渊连接',
|
env: Object.assign({}, process.env, { HUB_TOKEN: hubToken })
|
||||||
icon: '⚒️',
|
});
|
||||||
status: latency < 5000 ? 'ok' : 'warn',
|
const latency = Date.now() - start;
|
||||||
detail: `指令通道可达 · 延迟 ${latency}ms`
|
results.checks.push({
|
||||||
});
|
name: '铸渊连接',
|
||||||
} catch {
|
icon: '⚒️',
|
||||||
results.checks.push({ name: '铸渊连接', icon: '⚒️', status: 'error', detail: '指令通道不可达 → 检查Token' });
|
status: latency < 5000 ? 'ok' : 'warn',
|
||||||
|
detail: '指令通道可达 · 延迟 ' + latency + 'ms'
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
results.checks.push({ name: '铸渊连接', icon: '⚒️', status: 'error', detail: '指令通道不可达 → 检查Token' });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
results.checks.push({ name: '铸渊连接', icon: '⚒️', status: 'error', detail: 'HUB_TOKEN 未配置 → 铸渊连接不可用' });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写入签到结果
|
// 写入签到结果
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue