mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
Decided on 2026-10-14. On the import page each of the six asks for what its service needs - a self-hosted Planka its address, username and password; the others an access token (Basecamp also its account id) - lists what that account can import, and fetches the chosen board, list or project. The credentials go with each call and are used for that call's requests only; they are never stored or logged, and the page clears secret fields once a fetch has used them. The fetched JSON fills the import text box and the import goes on as for a pasted export: the service's parser (models/lib/<key>ApiFormat.js) into the generalized importer, with the members step and the loss report. The same JSON can be pasted, or posted to POST /api/boards/import/<key>. - server/apiImport.js: apiImportList and apiImportFetch, signed in only, off with the Admin Panel's import switch, not in Sandstorm, rate limited; credentials checked against the service's own fields (models/lib/apiImportServices.js). - server/lib/apiImportRequest.js: every request through the SSRF guard - pinned address, no redirects, bounded in time and size - so a Planka address cannot point the server at its own network; an administrator can allow such a host with API_IMPORT_ALLOWED_PRIVATE_HOSTS. An error names only the origin and the status. - models/lib/apiImport/<key>.js: each service's client, plain Node with the request injected, paging bounded and the token only in a header. - Each has a docs page under docs/Features/ImportExport/, listed in the coverage index and External-Tools.md. Tests: tests/<key>ApiImport.test.cjs (client with a fake request, every parsed field, wrong shapes), tests/apiImport.test.cjs (credentials, the gate, the wiring, the shapes refused), api-import.e2e.js (the form for every service, fetched JSON imported through the page, refusals incl. a private address). Live tests, read only, run from build.sh / build.bat -> Tests -> Live tests with your own accounts (releases/live-tests/README.md); they were not run here. New strings translated in all locales. Also: the release risk baseline allows the services' API addresses, and the guards that count import creators, list the import sources and pin the platform fetch() calls know the new ones. Thanks to xet7 !
64 lines
3.9 KiB
JavaScript
64 lines
3.9 KiB
JavaScript
'use strict';
|
|
|
|
// Import loss reporting (models/lib/importLossReport.js).
|
|
// Run: node tests/importLossReport.test.cjs
|
|
//
|
|
// Every external parser and the shared planner return `unsupported` and
|
|
// `warnings` entries, but nothing stored them, so an import that dropped a
|
|
// board's sharing rules or a parent outside the file looked exactly like a
|
|
// complete one. The creators now record one bounded Recovery row per import
|
|
// with losses, and none for a complete import.
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
async function main() {
|
|
const { importLossReport, IMPORT_WARNINGS_EVENT } = await import('../models/lib/importLossReport.js');
|
|
|
|
const report = importLossReport({
|
|
source: 'deck',
|
|
warnings: [{ path: '/stacks/0/cards', reason: '1 deleted card(s) skipped' }],
|
|
unsupported: [{ path: '/acl', reason: '1 sharing rule(s)' }, { path: '/x/attachments', reason: '2 attachment(s)' }],
|
|
});
|
|
assert.equal(report.type, IMPORT_WARNINGS_EVENT);
|
|
assert.equal(report.type, 'import-completed-with-warnings');
|
|
assert.equal(report.severity, 'warning');
|
|
assert.equal(report.count, 3);
|
|
assert.equal(report.detail,
|
|
'deck: 2 not imported, 1 warning(s). /acl 1 sharing rule(s); /x/attachments 2 attachment(s); /stacks/0/cards 1 deleted card(s) skipped');
|
|
|
|
// Negative: a complete import records nothing.
|
|
for (const none of [undefined, {}, { source: 'x', warnings: [], unsupported: [] }, { unsupported: [null, {}] }, { unsupported: 'x' }]) {
|
|
assert.equal(importLossReport(none), null);
|
|
}
|
|
|
|
// Bounded: a huge source cannot grow one row without limit.
|
|
const many = importLossReport({ source: 'zenkit', unsupported: Array.from({ length: 500 }, (_, i) => ({ path: `/items/${i}`, reason: 'r'.repeat(1000) })) });
|
|
assert.equal(many.count, 500);
|
|
assert.match(many.detail, /; and 480 more$/);
|
|
assert.ok(many.detail.length < 20 * 420, `detail is bounded (${many.detail.length})`);
|
|
|
|
// Both external-import creators record it after the board exists.
|
|
const read = file => fs.readFileSync(path.join(__dirname, '..', file), 'utf8');
|
|
const kanboard = read('models/kanboardCreator.js');
|
|
// The Scrum planning stage (GitLab, OpenProject, Asana) runs between, so
|
|
// the report also carries what it could not keep.
|
|
assert.match(kanboard, /await this\.createCards\(board, boardId\);\s*await this\.createScrumPlanning\(board, boardId\);\s*await recordImportLosses\(\{/);
|
|
assert.match(kanboard, /this\.losses\.push\(\.\.\.customFieldPlan\.unsupported\)/);
|
|
assert.match(kanboard, /this\.losses\.push\(\.\.\.unsupported\)/);
|
|
const jira = read('models/jiraCreator.js');
|
|
assert.match(jira, /await recordImportLosses\(\{\s*source: 'jira',\s*warnings: jiraPageWarnings\(board\)/);
|
|
const importJs = read('models/import.js');
|
|
// kanboard, markdown, todotxt, taskwarrior, focalboard, todoist, planner (Microsoft Planner), meistertask, obsidian, linear, ticktick, clickup, nullboard, kanri, pivotal, redmine, tasksorg, monday, superproductivity, taiga, vikunja, wrike, teamwork, businessmap, quire, notion, plane, orgmode, leo (the Leo outline), opml, the shared default branch, the parts of "One board per project" (models/lib/importSplit.js), and the six fetched from a service's API (planka ... googlekeep, one branch passing importSource).
|
|
assert.equal((importJs.match(/new KanboardCreator\(data, /g) || []).length, 33, 'every KanboardCreator knows its source');
|
|
assert.doesNotMatch(importJs, /new KanboardCreator\(data\)/);
|
|
const children = read('models/lib/importedCardChildren.js');
|
|
assert.match(children, /RecoveryEvents\.record\(report\.type/);
|
|
assert.match(read('models/recoveryEvents.js'), /IMPORT_COMPLETED_WITH_WARNINGS: 'import-completed-with-warnings'/);
|
|
|
|
console.log(' ok - imports with losses record one bounded Recovery row; complete imports record none');
|
|
}
|
|
|
|
main().catch(error => { console.error(error); process.exitCode = 1; });
|