mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 09:45:36 +08:00
fix(security): protect first-run notifications and server errors (#3126)
* fix(security): close anonymous notification setup and mask server errors * fix: hide internal errors in default deployment * fix: route HTTP errors through application logger * test: mock logger in API fallback regression * fix: avoid sensitive SQL details in HTTP error logs
This commit is contained in:
1 parent
cae580e02f
commit
1cfc0c8e2e
11 files changed
+104
-146
No files matched your search
@@ -52,6 +52,19 @@ test('health uses actual readiness and returns HTTP 503 until recovery',async(t)
|
||||
assert.equal(r.status,expected);assert.equal(b.code,expected);assert.equal(b.data.services.grpc,ready);
|
||||
}
|
||||
});
|
||||
test('health failure does not reveal internal error details',async(t)=>{
|
||||
const express=require('express');
|
||||
const HealthService=class{};
|
||||
const app=express();load('back/api/health.ts',{
|
||||
typedi:{get:()=>({check:async()=>{throw Error('sensitive health detail');}})},
|
||||
'../services/health':{HealthService},'../loaders/logger':{error(){}},
|
||||
}).default(app);
|
||||
const server=app.listen(0,'127.0.0.1');await new Promise(r=>server.once('listening',r));
|
||||
t.after(()=>new Promise(r=>{server.close(r);server.closeAllConnections();}));
|
||||
const response=await fetch(`http://127.0.0.1:${server.address().port}/health`);
|
||||
assert.equal(response.status,500);
|
||||
assert.deepEqual(await response.json(),{code:500,message:'Health check failed'});
|
||||
});
|
||||
test('recovery registration errors propagate while ordinary autosave retains file synchronization',async()=>{
|
||||
const source=fs.readFileSync('back/services/cron.ts','utf8');const a=source.indexOf(' public async autosave_crontab('),z=source.indexOf(' public async bootTask',a);
|
||||
const js=ts.transpileModule('class Fixture {\n'+source.slice(a,z)+'}\nmodule.exports=Fixture;', {compilerOptions:{target:ts.ScriptTarget.ES2020}}).outputText;
|
||||
|
||||
Reference in new issue
Block a user