Fix ZIP dependency and allow imports into owned multisite workspaces
DC CMS qualification / qualify (push) Successful in 1m54s
DC CMS qualification / qualify (push) Successful in 1m54s
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ Workflow `.gitea/workflows/ci.yml` квалифицирует точный commi
|
|||||||
|
|
||||||
Отдельный исходящий контроллер NAS читает успешные Actions-запуски только репозитория SILVER/DC_CMS (33), проверяет предков и неизменность артефакта. Канонический root-runner обновляет только cms-app, сохраняет остальные контейнеры и данные и при ошибке восстанавливает прежний образ без сборки. Первый запуск требует отдельной регистрации серверного компонента; наличие workflow в Git само по себе не означает включённый автоматический деплой.
|
Отдельный исходящий контроллер NAS читает успешные Actions-запуски только репозитория SILVER/DC_CMS (33), проверяет предков и неизменность артефакта. Канонический root-runner обновляет только cms-app, сохраняет остальные контейнеры и данные и при ошибке восстанавливает прежний образ без сборки. Первый запуск требует отдельной регистрации серверного компонента; наличие workflow в Git само по себе не означает включённый автоматический деплой.
|
||||||
|
|
||||||
Обычный релиз содержит только файлы admin/server и дескриптор. Изменения Dockerfile, зависимостей и Compose требуют отдельного пересмотра серверного контракта. Сборочный контекст содержит пустой projects: настройки, пароли и содержимое сайтов не попадают в образ.
|
Обычный релиз содержит файлы admin/server, дескриптор и два файла зависимостей с заранее зарегистрированными SHA-256. Первый переход обновляет adm-zip с уязвимой версии 0.5.x до 0.6.1; дальнейшие релизы обязаны сохранять этот lockfile. Изменения Dockerfile, зависимостей и Compose требуют отдельного пересмотра серверного контракта. Сборочный контекст содержит пустой projects: настройки, пароли и содержимое сайтов не попадают в образ.
|
||||||
|
|
||||||
## Проверка
|
## Проверка
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -17,11 +17,11 @@ STEPS = ['frozen-install', 'syntax', 'multisite-tests']
|
|||||||
def digest(data): return hashlib.sha256(data).hexdigest()
|
def digest(data): return hashlib.sha256(data).hexdigest()
|
||||||
def run(args): subprocess.run(args, cwd=ROOT, check=True)
|
def run(args): subprocess.run(args, cwd=ROOT, check=True)
|
||||||
def tracked_payload():
|
def tracked_payload():
|
||||||
names = subprocess.check_output(['git','ls-files','-z','admin','server'], cwd=ROOT).decode().split('\0')
|
names = subprocess.check_output(['git','ls-files','-z','admin','server','package.json','package-lock.json'], cwd=ROOT).decode().split('\0')
|
||||||
files = {}
|
files = {}
|
||||||
for name in sorted(filter(None,names)):
|
for name in sorted(filter(None,names)):
|
||||||
path=ROOT/name
|
path=ROOT/name
|
||||||
if path.is_symlink() or not path.is_file() or path.suffix not in ('.js','.mjs','.html','.css','.svg'):
|
if path.is_symlink() or not path.is_file() or (name not in ('package.json','package-lock.json') and path.suffix not in ('.js','.mjs','.html','.css','.svg')):
|
||||||
raise ValueError('unsupported runtime path: '+name)
|
raise ValueError('unsupported runtime path: '+name)
|
||||||
files[name]=path.read_bytes()
|
files[name]=path.read_bytes()
|
||||||
if not {'admin/index.html','admin/admin.js','admin/admin.css','server/admin-server.mjs'} <= set(files):
|
if not {'admin/index.html','admin/admin.js','admin/admin.css','server/admin-server.mjs'} <= set(files):
|
||||||
@@ -32,7 +32,7 @@ def bundle(files, commit, run_id, run_number, foundation):
|
|||||||
if not re.fullmatch('[a-f0-9]{40}',commit) or any(type(n) is not int or n<=0 for n in (run_id,run_number)):
|
if not re.fullmatch('[a-f0-9]{40}',commit) or any(type(n) is not int or n<=0 for n in (run_id,run_number)):
|
||||||
raise ValueError('full source and positive run identity required')
|
raise ValueError('full source and positive run identity required')
|
||||||
for name, data in files.items():
|
for name, data in files.items():
|
||||||
if not re.fullmatch(r'(?:admin|server)/[a-zA-Z0-9_-]+\.(?:mjs|js|css|html|svg)', name) or not isinstance(data, bytes):
|
if (name not in ('package.json','package-lock.json') and not re.fullmatch(r'(?:admin|server)/[a-zA-Z0-9_-]+\.(?:mjs|js|css|html|svg)', name)) or not isinstance(data, bytes):
|
||||||
raise ValueError('unsupported application payload: '+name)
|
raise ValueError('unsupported application payload: '+name)
|
||||||
if not files:
|
if not files:
|
||||||
raise ValueError('empty application payload')
|
raise ValueError('empty application payload')
|
||||||
|
|||||||
Generated
+5
-5
@@ -8,18 +8,18 @@
|
|||||||
"name": "dc-cms",
|
"name": "dc-cms",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"adm-zip": "^0.5.18",
|
"adm-zip": "0.6.1",
|
||||||
"jose": "^6.2.3",
|
"jose": "^6.2.3",
|
||||||
"ssh2-sftp-client": "^12.1.1"
|
"ssh2-sftp-client": "^12.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/adm-zip": {
|
"node_modules/adm-zip": {
|
||||||
"version": "0.5.18",
|
"version": "0.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.18.tgz",
|
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.6.1.tgz",
|
||||||
"integrity": "sha512-ufJnssQGbxzLNS1Ho9bCtX4rQKCCvoVuDLHoJyc3F9dOGDB4BkWs2Ci0kv53lqocAEQ/Cbi+I2XCsNYGqVYqng==",
|
"integrity": "sha512-Xwrja8nx9e5o2N1my4DsKCeKpdrnACyr1wtbPxBDgGzKzKyE9kRtBFA8mWldI+RVlD7CBZNWY/wQ2+ydwOR6kQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.0"
|
"node": ">=14.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/asn1": {
|
"node_modules/asn1": {
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
"start": "node server/admin-server.mjs"
|
"start": "node server/admin-server.mjs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"adm-zip": "^0.5.18",
|
"adm-zip": "0.6.1",
|
||||||
"jose": "^6.2.3",
|
"jose": "^6.2.3",
|
||||||
"ssh2-sftp-client": "^12.1.1"
|
"ssh2-sftp-client": "^12.1.1"
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1647,7 +1647,8 @@ function zipCommonRoot(entries) {
|
|||||||
|
|
||||||
async function clearSiteWorkspace() {
|
async function clearSiteWorkspace() {
|
||||||
const resolvedRoot = resolve(repoRoot);
|
const resolvedRoot = resolve(repoRoot);
|
||||||
if (resolvedRoot === "/" || resolvedRoot === cmsRoot || resolvedRoot.startsWith(`${cmsRoot}/`)) {
|
const ownedProjectRoot = resolve(projectsRoot, "sites", activeProjectId);
|
||||||
|
if (resolvedRoot === "/" || resolvedRoot === cmsRoot || (resolvedRoot.startsWith(`${cmsRoot}/`) && resolvedRoot !== ownedProjectRoot)) {
|
||||||
throw new Error("Опасный путь workspace сайта, очистка запрещена");
|
throw new Error("Опасный путь workspace сайта, очистка запрещена");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { tmpdir } from 'node:os';
|
|||||||
import { join, resolve } from 'node:path';
|
import { join, resolve } from 'node:path';
|
||||||
import { spawn } from 'node:child_process';
|
import { spawn } from 'node:child_process';
|
||||||
import { once } from 'node:events';
|
import { once } from 'node:events';
|
||||||
|
import AdmZip from 'adm-zip';
|
||||||
|
|
||||||
test('independent sites, rendering, secrets and publication ownership', async t => {
|
test('independent sites, rendering, secrets and publication ownership', async t => {
|
||||||
const root = await mkdtemp(join(tmpdir(), 'dc-cms-test-'));
|
const root = await mkdtemp(join(tmpdir(), 'dc-cms-test-'));
|
||||||
@@ -81,6 +82,18 @@ test('independent sites, rendering, secrets and publication ownership', async t
|
|||||||
assert.equal((await fetch(base+'/s/missing/assets/proof.txt')).status,404);
|
assert.equal((await fetch(base+'/s/missing/assets/proof.txt')).status,404);
|
||||||
assert.equal((await fetch(base+'/s/nodedc/.git/private')).status,403);
|
assert.equal((await fetch(base+'/s/nodedc/.git/private')).status,403);
|
||||||
});
|
});
|
||||||
|
await t.test('ZIP replacement stays inside the selected site',async()=>{
|
||||||
|
const zip=new AdmZip();
|
||||||
|
for(const [path,content] of Object.entries(fixture)) if(!path.startsWith('.')) zip.addFile(path,Buffer.from(content));
|
||||||
|
zip.updateFile('content/pages/home.json',Buffer.from(JSON.stringify({title:'Mission edited',regions:[]})));
|
||||||
|
const form=new FormData();form.append('file',new Blob([zip.toBuffer()],{type:'application/zip'}),'mission.zip');
|
||||||
|
const response=await fetch(base+'/s/mission-core/api/project/upload-site',{method:'POST',body:form});
|
||||||
|
const result=await response.json();assert.equal(response.status,200,JSON.stringify(result));assert.equal(result.site.ready,true);
|
||||||
|
assert.equal((await api('/s/nodedc/api/page/home')).title,'Agent edited');
|
||||||
|
const invalid=new FormData();invalid.append('file',new Blob([Buffer.from('not a ZIP')]),'bad.zip');
|
||||||
|
assert.equal((await fetch(base+'/s/mission-core/api/project/upload-site',{method:'POST',body:invalid})).status,500);
|
||||||
|
assert.equal((await api('/s/mission-core/api/page/home')).title,'Mission edited');
|
||||||
|
});
|
||||||
await t.test('encrypted credentials transfer with source disabled',async()=>{
|
await t.test('encrypted credentials transfer with source disabled',async()=>{
|
||||||
const config=await api('/s/nodedc/api/project/config');
|
const config=await api('/s/nodedc/api/project/config');
|
||||||
await api('/s/nodedc/api/project/config','PUT',{...config,deploy:{...config.deploy,enabled:true}});
|
await api('/s/nodedc/api/project/config','PUT',{...config,deploy:{...config.deploy,enabled:true}});
|
||||||
|
|||||||
Reference in New Issue
Block a user