فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

test(security): exercise hostile expense category/date/reference/ID in real installed WebView2

davoodmehraban89 committed Oct 31, 2026 at 00:20 UTC 2dfe96da5983ee6bdf96473f91d3ae2d5752d50f
1 file changed +43
tests/windows-vm-ui-interaction-audit-browser.js
+43
@@ -336,7 +336,50 @@
336 namedField.labels[0].click(); await wait(15);
337 if (document.activeElement!==namedField) throw Error('Linked modal field label did not focus its field');
338 FINORA.Modal.close();
339 + // Read-only synthetic XSS exercise: no customer records are persisted.
340 + const expenseController=window.ExpenseController;
341 + const expenseView=window.ExpensesView;
342 + const origGetAll=expenseController.getAll;
343 + const origGetCategories=expenseController.getCategories;
344 + const origGetStats=expenseController.getStats;
345 + const origEditExpense=expenseView.editExpense;
346 + const hostileCategory='"><\/option><\/select><img src=x onerror="window.Q01_EXPENSE_HTML_ATTACK=true">';
347 + const hostileId="exp-test');window.Q01_EXPENSE_ID_ATTACK=true;//";
348 + const hostileCell='<img src=x onerror="window.Q01_EXPENSE_HTML_ATTACK=true">';
349 + let clickedExpenseId=null;
350 + try {
351 + expenseController.getAll=async()=>[{id:hostileId,kind:'expense',
352 + category:hostileCategory,description:hostileCell,
353 + date:hostileCell,refNumber:hostileCell,method:hostileCell,amount:100}];
354 + expenseController.getCategories=async()=>[hostileCategory];
355 + expenseController.getStats=async()=>({totalIncome:0,totalExpense:100,balance:-100,count:1});
356 + await expenseView.reload();
357 + const scratch=document.createElement('div');
358 + scratch.innerHTML=expenseView.renderContent();
359 + if(scratch.querySelector('img') || scratch.querySelector('script') ||
360 + scratch.querySelector('option')?.value!==hostileCategory ||
361 + !scratch.textContent.includes(hostileCell)) {
362 + throw Error('Untrusted expense list fields created executable markup or corrupted category value');
363 + }
364 + expenseView.editExpense=(id)=>{clickedExpenseId=id;};
365 + const edit=scratch.querySelector('button[title="ویرایش"]');
366 + if(!edit) throw Error('Synthetic expense action missing');
367 + edit.click();
368 + if(clickedExpenseId!==hostileId || window.Q01_EXPENSE_ID_ATTACK ||
369 + window.Q01_EXPENSE_HTML_ATTACK) {
370 + throw Error('Expense row identifier escaped the safe JS argument or executed markup');
371 + }
372 + } finally {
373 + expenseController.getAll=origGetAll;
374 + expenseController.getCategories=origGetCategories;
375 + expenseController.getStats=origGetStats;
376 + expenseView.editExpense=origEditExpense;
377 + await expenseView.reload();
378 + delete window.Q01_EXPENSE_ID_ATTACK;
379 + delete window.Q01_EXPENSE_HTML_ATTACK;
380 + }
381 const modalKeyboard={roleAndLabel:true,nestedDialogIsolation:true,
382 + expenseUnsafeHtmlEscaped:true,
383 modalFormLabelsLinked:true,
384 confirmationTextEscaped:true,visibleInputAutoFocused:true,
385 escapeClosesWithoutConfirm:true,focusReturnsToTrigger:true,