From 6e382c851519f046ed4a5123ad4d7d106836ad98 Mon Sep 17 00:00:00 2001 From: "ankitatripathi.mp@gmail.com" Date: Thu, 21 May 2026 16:10:46 +0530 Subject: [PATCH 1/2] feat: add deprecation warnings for external file path references in config handlers --- src/context/directory/handlers/actionModules.ts | 5 +++++ src/context/directory/handlers/actions.ts | 5 +++++ src/context/directory/handlers/databases.ts | 17 ++++++++++++----- src/context/directory/index.ts | 5 +++++ src/context/yaml/index.ts | 5 +++++ 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/context/directory/handlers/actionModules.ts b/src/context/directory/handlers/actionModules.ts index 09c06c9ad..08e516243 100644 --- a/src/context/directory/handlers/actionModules.ts +++ b/src/context/directory/handlers/actionModules.ts @@ -31,6 +31,11 @@ function parse(context: DirectoryContext): ParsedActionModules { // It can be a relative path, so we need to handle both cases. const unixPath = module.code.replace(/[\\/]+/g, '/').replace(/^([a-zA-Z]+:|\.\/)/, ''); if (fs.existsSync(unixPath)) { + log.warn( + `Deprecation notice: action module code path "${module.code}" is resolved as an absolute or external path. ` + + `Support for absolute paths and paths outside the config root will be removed in a future major version. ` + + `Please update your configuration to use paths relative to the config directory.` + ); module.code = context.loadFile(unixPath, moduleFolder); } else { module.code = context.loadFile(path.join(context.filePath, module.code), moduleFolder); diff --git a/src/context/directory/handlers/actions.ts b/src/context/directory/handlers/actions.ts index 3396cbba0..c4a6c5a76 100644 --- a/src/context/directory/handlers/actions.ts +++ b/src/context/directory/handlers/actions.ts @@ -32,6 +32,11 @@ function parse(context: DirectoryContext): ParsedActions { const unixPath = action.code.replace(/[\\/]+/g, '/').replace(/^([a-zA-Z]+:|\.\/)/, ''); if (fs.existsSync(unixPath)) { // If the Unix-style path exists, load the file from that path + log.warn( + `Deprecation notice: action code path "${action.code}" is resolved as an absolute or external path. ` + + `Support for absolute paths and paths outside the config root will be removed in a future major version. ` + + `Please update your configuration to use paths relative to the config directory.` + ); action.code = context.loadFile(unixPath, actionFolder); } else { // Otherwise, load the file from the context's file path diff --git a/src/context/directory/handlers/databases.ts b/src/context/directory/handlers/databases.ts index 69d611a75..edb172d1c 100644 --- a/src/context/directory/handlers/databases.ts +++ b/src/context/directory/handlers/databases.ts @@ -33,6 +33,7 @@ type DatabaseMetadata = { function getDatabase( folder: string, + configRoot: string, mappingOpts: { mappings: KeywordMappings; disableKeywordReplacement: boolean } ): {} { const metaFile = path.join(folder, 'database.json'); @@ -68,10 +69,16 @@ function getDatabase( // skip invalid keys in customScripts object log.warn('Skipping invalid database configuration: ' + name); } else { - database.options.customScripts[name] = loadFileAndReplaceKeywords( - path.join(folder, script), - mappingOpts - ); + const resolvedBase = path.resolve(configRoot); + const toLoad = path.resolve(folder, script); + if (!toLoad.startsWith(resolvedBase + path.sep)) { + log.warn( + `Deprecation notice: database custom script "${name}" references file "${script}" which resolves outside the config directory. ` + + `Support for absolute paths and paths outside the config root will be removed in a future major version. ` + + `Please update your configuration to use paths relative to the config directory.` + ); + } + database.options.customScripts[name] = loadFileAndReplaceKeywords(toLoad, mappingOpts); } }); } @@ -90,7 +97,7 @@ function parse(context: DirectoryContext): ParsedDatabases { const databases = folders .map((f) => - getDatabase(f, { + getDatabase(f, context.filePath, { mappings: context.mappings, disableKeywordReplacement: context.disableKeywordReplacement, }) diff --git a/src/context/directory/index.ts b/src/context/directory/index.ts index 71eff04df..f9c643734 100644 --- a/src/context/directory/index.ts +++ b/src/context/directory/index.ts @@ -52,6 +52,11 @@ export default class DirectoryContext { if (!isFile(toLoad)) { // try load not relative to yaml file toLoad = f; + log.warn( + `Deprecation notice: file reference "${f}" could not be resolved relative to the config directory and fell back to an absolute or external path. ` + + `Support for absolute paths and paths outside the config root will be removed in a future major version. ` + + `Please update your configuration to use paths relative to the config directory.` + ); } return loadFileAndReplaceKeywords(toLoad, { mappings: this.mappings, diff --git a/src/context/yaml/index.ts b/src/context/yaml/index.ts index 24dc683bf..321629c4a 100644 --- a/src/context/yaml/index.ts +++ b/src/context/yaml/index.ts @@ -62,6 +62,11 @@ export default class YAMLContext { if (!isFile(toLoad)) { // try load not relative to yaml file toLoad = f; + log.warn( + `Deprecation notice: file reference "${f}" could not be resolved relative to the config directory and fell back to an absolute or external path. ` + + `Support for absolute paths and paths outside the config root will be removed in a future major version. ` + + `Please update your configuration to use paths relative to the config directory.` + ); } return loadFileAndReplaceKeywords(path.resolve(toLoad), { mappings: this.mappings, From 94dedb8108c3e2c672d01ad5e035be8c7cd06273 Mon Sep 17 00:00:00 2001 From: "ankitatripathi.mp@gmail.com" Date: Fri, 22 May 2026 12:42:13 +0530 Subject: [PATCH 2/2] fix: simplify deprecation warning messages and include offending path --- src/context/directory/handlers/actionModules.ts | 6 +++--- src/context/directory/handlers/actions.ts | 6 +++--- src/context/directory/handlers/databases.ts | 6 +++--- src/context/directory/index.ts | 6 +++--- src/context/yaml/index.ts | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/context/directory/handlers/actionModules.ts b/src/context/directory/handlers/actionModules.ts index 08e516243..eb90d69a1 100644 --- a/src/context/directory/handlers/actionModules.ts +++ b/src/context/directory/handlers/actionModules.ts @@ -32,9 +32,9 @@ function parse(context: DirectoryContext): ParsedActionModules { const unixPath = module.code.replace(/[\\/]+/g, '/').replace(/^([a-zA-Z]+:|\.\/)/, ''); if (fs.existsSync(unixPath)) { log.warn( - `Deprecation notice: action module code path "${module.code}" is resolved as an absolute or external path. ` + - `Support for absolute paths and paths outside the config root will be removed in a future major version. ` + - `Please update your configuration to use paths relative to the config directory.` + `Support for absolute paths and paths outside the config root will be deprecated in a future version to improve the security of the tool. ` + + `Please update your configuration to use paths relative to the config directory. ` + + `Current absolute path used: ["${module.code}"]` ); module.code = context.loadFile(unixPath, moduleFolder); } else { diff --git a/src/context/directory/handlers/actions.ts b/src/context/directory/handlers/actions.ts index c4a6c5a76..25df66cec 100644 --- a/src/context/directory/handlers/actions.ts +++ b/src/context/directory/handlers/actions.ts @@ -33,9 +33,9 @@ function parse(context: DirectoryContext): ParsedActions { if (fs.existsSync(unixPath)) { // If the Unix-style path exists, load the file from that path log.warn( - `Deprecation notice: action code path "${action.code}" is resolved as an absolute or external path. ` + - `Support for absolute paths and paths outside the config root will be removed in a future major version. ` + - `Please update your configuration to use paths relative to the config directory.` + `Support for absolute paths and paths outside the config root will be deprecated in a future version to improve the security of the tool. ` + + `Please update your configuration to use paths relative to the config directory. ` + + `Current absolute path used: ["${action.code}"]` ); action.code = context.loadFile(unixPath, actionFolder); } else { diff --git a/src/context/directory/handlers/databases.ts b/src/context/directory/handlers/databases.ts index edb172d1c..99ffbb1ee 100644 --- a/src/context/directory/handlers/databases.ts +++ b/src/context/directory/handlers/databases.ts @@ -73,9 +73,9 @@ function getDatabase( const toLoad = path.resolve(folder, script); if (!toLoad.startsWith(resolvedBase + path.sep)) { log.warn( - `Deprecation notice: database custom script "${name}" references file "${script}" which resolves outside the config directory. ` + - `Support for absolute paths and paths outside the config root will be removed in a future major version. ` + - `Please update your configuration to use paths relative to the config directory.` + `Support for absolute paths and paths outside the config root will be deprecated in a future version to improve the security of the tool. ` + + `Please update your configuration to use paths relative to the config directory. ` + + `Current absolute path used: ["${script}"]` ); } database.options.customScripts[name] = loadFileAndReplaceKeywords(toLoad, mappingOpts); diff --git a/src/context/directory/index.ts b/src/context/directory/index.ts index f9c643734..891e696ce 100644 --- a/src/context/directory/index.ts +++ b/src/context/directory/index.ts @@ -53,9 +53,9 @@ export default class DirectoryContext { // try load not relative to yaml file toLoad = f; log.warn( - `Deprecation notice: file reference "${f}" could not be resolved relative to the config directory and fell back to an absolute or external path. ` + - `Support for absolute paths and paths outside the config root will be removed in a future major version. ` + - `Please update your configuration to use paths relative to the config directory.` + `Support for absolute paths and paths outside the config root will be deprecated in a future version to improve the security of the tool. ` + + `Please update your configuration to use paths relative to the config directory. ` + + `Current absolute path used: ["${f}"]` ); } return loadFileAndReplaceKeywords(toLoad, { diff --git a/src/context/yaml/index.ts b/src/context/yaml/index.ts index 321629c4a..5a965cd9f 100644 --- a/src/context/yaml/index.ts +++ b/src/context/yaml/index.ts @@ -63,9 +63,9 @@ export default class YAMLContext { // try load not relative to yaml file toLoad = f; log.warn( - `Deprecation notice: file reference "${f}" could not be resolved relative to the config directory and fell back to an absolute or external path. ` + - `Support for absolute paths and paths outside the config root will be removed in a future major version. ` + - `Please update your configuration to use paths relative to the config directory.` + `Support for absolute paths and paths outside the config root will be deprecated in a future version to improve the security of the tool. ` + + `Please update your configuration to use paths relative to the config directory. ` + + `Current absolute path used: ["${f}"]` ); } return loadFileAndReplaceKeywords(path.resolve(toLoad), {