forked from unimatrix/web
Allow bounded CP expansion beyond fifty published assets
This commit is contained in:
parent
2833fe6b3d
commit
e6c8cfacd4
2 changed files with 4 additions and 1 deletions
|
|
@ -20,7 +20,7 @@ export async function publishPreview({ciRoot='/home/dunedeploy/ci-deploy',previe
|
|||
const revision=await marker('built-commit');if(!markerPattern.test(revision)||revision!==await marker('pending-commit'))throw Error('No matching CI-approved build');
|
||||
const source=path.join(ciRoot,'artifacts',revision,'website','control-panel','public','cp-v2');
|
||||
if(await realpath(source)!==source)throw Error('Symlinked artifact paths are refused');
|
||||
const entries=await readdir(source,{withFileTypes:true});if(entries.length>50)throw Error('Too many preview assets');
|
||||
const entries=await readdir(source,{withFileTypes:true});if(entries.length>80)throw Error('Too many preview assets');
|
||||
const files=new Map();let total=0;
|
||||
for(const entry of entries){
|
||||
if(!entry.isFile()||!assetPattern.test(entry.name)||/git/i.test(entry.name)||entry.name==='revision.json')throw Error('Unsupported preview asset: '+entry.name);
|
||||
|
|
|
|||
|
|
@ -22,3 +22,6 @@ test('missing required assets fail closed',()=>fixture(async options=>{const sou
|
|||
test('symlinked assets are refused',{skip:process.platform==='win32'},()=>fixture(async options=>{const source=await artifact(options);await writeFile(path.join(options.ciRoot,'private'),'private');await symlink(path.join(options.ciRoot,'private'),path.join(source,'extra.mjs'));await assert.rejects(publishPreview(options),/Unsupported preview asset/);}));
|
||||
test('changed files cannot overwrite an immutable published release',{skip:process.platform==='win32'},()=>fixture(async options=>{const source=await artifact(options);await publishPreview(options);await writeFile(path.join(source,'v2.js'),'changed');await assert.rejects(publishPreview(options),/Immutable preview release differs/);}));
|
||||
test('preview publication contains no service restart or database operation',async()=>{const source=await readFile(new URL('../ops/publish-cp-v2-preview.mjs',import.meta.url),'utf8');assert.doesNotMatch(source,/child_process|execFile|spawn\(|systemctl|pm2 |mysql|openDatabase/);const config=await readFile(new URL('../ops/cp-v2-preview.nginx.conf',import.meta.url),'utf8');assert.match(config,/auth_request \/_cp_v2_owner_check/);assert.match(config,/location = \/_cp_v2_owner_check \{\s+internal;/);assert.match(config,/proxy_pass http:\/\/127\.0\.0\.1:3003\/v2\/v2.css/);assert.match(config,/text\/javascript js mjs/);});
|
||||
|
||||
test('larger CP releases retain a strict eighty-file bound',()=>fixture(async options=>{const source=await artifact(options);for(let i=0;i<76;i++)await writeFile(path.join(source,'page-'+i+'.mjs'),'export {};');await assert.rejects(publishPreview(options),/Too many preview assets/);}));
|
||||
test('bank expansion above the previous fifty-file bound publishes intact',{skip:process.platform==='win32'},()=>fixture(async options=>{const source=await artifact(options);for(let i=0;i<47;i++)await writeFile(path.join(source,'page-'+i+'.mjs'),'export {};');assert.equal((await publishPreview(options)).files,52);}));
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff