Conversation
- Replace eval() with new Function() in new-test.js to prevent code injection - Strengthen path traversal protection with fs.realpathSync() in editor.js and get-file.js - Fix infinite recursion bug: retry-- (post-decrement) to retry-1 in reporter-utils.js - Add bounded snapshot store (max 500 entries) to prevent memory leaks - Store chokidar watcher reference and export cleanup function in scenario-repository.js - Add stream cleanup on errors after headers sent in get-file.js - Add try-catch and encoding for testrun-repository.js JSON parsing - Sanitize grep parameter in run-scenario.js to prevent regex injection - Add settings key allowlist in settings-repository.js - Add try-catch error handling for config path in init.js Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
…est cleanup Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
|
@copilot adapt the codeceptUI to work with new codeceptjs 4.x (https://github.com/codeceptjs/CodeceptJS/tree/4.x) it's moving to ESM from CommonJS. |
- Add ESM-CJS interop helper (lib/codeceptjs/codeceptjs-imports.js) using dynamic import()
- Convert all `require('codeceptjs')` to use cached async codeceptjsModules()
- Convert all `require('codeceptjs/lib/...')` subpath imports to async importSubpath()
- Replace `codecept_helper` global with factory pattern receiving Helper base class
- Update helpers (realtime-reporter, network-recorder, console-recorder, single-session)
to use factory functions that receive the Helper class parameter
- Make codeceptjs-factory.create() fully async (config.load, initGlobals, container.create)
- Make reloadConfig() async for CodeceptJS 4.x async config loading
- Update all API handlers to use async codeceptjs module loading
- Update package.json peer/dev dependency to codeceptjs ^4.0.0-rc.1
- Update tests for new factory pattern (browser-cleanup, stop)
Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
… path construction, deprecate script.js Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
Adapted the CodeceptUI to work with CodeceptJS 4.x ESM in commit Key changes:
All 172 tests pass, 0 CodeQL alerts. |
|
@copilot move codeceptui to esm like codeceptjs 4.x esm. |
Renamed vue.config.js, babel.config.js, postcss.config.js, tailwind.js,
and codecept.conf.js to .cjs extensions since they use module.exports
and the project is converting to ESM ("type": "module").
Updated postcss.config.cjs to reference tailwind.cjs instead of tailwind.js.
Made vue.config.cjs self-contained by inlining port logic to avoid
CJS/ESM interop issues with lib/config/env.js.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace require()/module.exports with import/export default in all lib/utils/ source and test files. Replace __dirname with import.meta.dirname in mkdir.spec.js. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- env.js: Replace require/module.exports with import/export - url.js: Replace require/module.exports with import/export - env.spec.js: Use import with namespace import for named exports - url.spec.js: Use import with namespace import for named exports Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace all require() calls with import statements - Replace all module.exports with export default or named exports - Add .js extensions to all local imports - Use createRequire for dynamic require in profile-repository.js and codeceptjs-factory.js - Use dynamic import for socket.io-client in ws-events.js - Use dynamic import for worker_threads in codeceptjs-run-workers - Rewrite profile-repository.spec.js to work without require.cache - Export both named 'events' and default object from ws-events.js Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace require()/module.exports with import/export in all files - Add .js extensions to all local imports - Simplify codeceptjs-imports.js to use top-level import - Convert socket.io-client to dynamic import in brk.js - Rename chalk variable from 'colors' to 'chalk' in brk.js Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Convert all require() to import statements with .js extensions - Convert module.exports to export default / named exports - Convert editor.js from module.exports.X pattern to named exports - Add default export to profile-repository.js for test mockability - Convert list-actions.js to use createRequire for require.resolve - Convert list-steps.js socket.io-client usage to dynamic import - Update test files (list-profiles.spec.js, stop.spec.js) imports Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…on.js, lib/app.js from CommonJS to ESM
- Replace require() with import statements
- Replace module.exports with export default
- Replace __dirname with import.meta.dirname
- Use dynamic import() for conditional/deferred requires
- Use Server constructor for socket.io instead of require('socket.io')(...)
- Use createRequire for CJS-only resolution in electron.js
- Import screen at top level in app.js instead of inside function
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Replace require() with import statements in all 14 test files
- Add .js extensions to all local imports (../lib/...)
- Replace __dirname with import.meta.dirname
- Convert require('fs').promises to import from 'fs/promises'
- Move inline require() calls to top-level imports
- Use import * as editorApi for named exports module
- Import fsSync from 'fs' for createReadStream monkey-patching
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tput_dir fallbacks, missed spec files - Fix cheerio import to use namespace import (no default export) - Add default export to settings-repository.js for test compatibility - Add output_dir fallback to scenario-status-repository.js and testrun-repository.js - Convert remaining spec files (port-validator.spec.js, absolutize-paths.spec.js) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Migrated CodeceptUI to ESM in commits Changes:
All 171 tests pass. |
Comprehensive review of CodeceptUI surfaced critical security issues, a stack-overflow bug, and several resource leaks. Additionally migrated the entire codebase from CommonJS to native ESM to match CodeceptJS 4.x.
Critical
lib/api/new-test.js: Replaceeval(req.body.code)withnew Function('return ' + req.body.code)()— eliminates local scope access from user inputlib/api/editor.js,lib/api/get-file.js: Path traversal via symlinks — addedfs.realpathSync()validation. Extracted sharedresolveSecurePath()helper in editor.jslib/codeceptjs/reporter-utils.js:retry--(post-decrement) passes original value to recursive call → infinite recursion → stack overflow. Fixed toretry - 1Resource leaks / memory
lib/model/snapshot-store/index.js: Unbounded in-memory snapshot accumulation. Added FIFO eviction at 500 entrieslib/model/scenario-repository.js: Chokidar watcher created but never stored. Saved reference and exportedcloseWatcher()Hardening
lib/model/testrun-repository.js:JSON.parseof file content without try-catch; missing'utf8'encoding onreadFileSynclib/api/get-file.js: Stream error afterheadersSentsilently ignored — now callsdestroy()+end()lib/model/settings-repository.js:Object.assign(settings, newSettings)accepts arbitrary keys. Added allowlistlib/commands/init.js: Unguardedfs.lstatSyncthrows on missing config path. Wrapped in try-catch withprocess.exit(1)Full ESM Migration
Migrated the entire CodeceptUI codebase from CommonJS to native ESM (
import/export), matching CodeceptJS 4.x which also uses ESM.package.json: Added"type": "module". Updatedcodeceptjspeer and dev dependency to^4.0.0-rc.1.cjs(vue.config.cjs,babel.config.cjs,postcss.config.cjs,tailwind.cjs,codecept.conf.cjs) since they use CommonJS syntax consumed by toolinglib/files (55+ files): Convertedrequire()/module.exportstoimport/exportbin/codecept-ui.js: Converted entry point to ESMlib/codeceptjs/codeceptjs-imports.js: Simplified from dynamicimport()CJS-ESM bridge to directimport codeceptjs from 'codeceptjs'— no interop layer needed since CodeceptUI is now ESMlib/model/codeceptjs-factory.js: Uses direct ESM imports.create(),reloadConfig(), andreloadConfigIfNecessary()are fully async to support CodeceptJS 4.x async APIsrealtime-reporter,network-recorder,console-recorder,single-session) export factory functions that receive theHelperbase class as a parameter (replacing the removedcodecept_helperglobal)__dirname/__filename: Replaced withimport.meta.dirname/import.meta.filenamethroughoutrequire.resolve()/require.cache: Replaced withcreateRequire(import.meta.url)where dynamic require is still needed (e.g., module cache invalidation, loading user config files)Key ESM conversion patterns
Tests
All test files (14 + 9 co-located specs) converted to ESM. 11 new tests in
test/security-fixes.spec.js. All 171 tests pass.CodeQL note
Pre-existing
js/missing-rate-limitingalert on file-access routes inlib/api/index.js— not introduced here, would require architectural change (e.g.express-rate-limit).🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.