From ae2b3064b29eae2778dfa1bf061a17be6991d8f8 Mon Sep 17 00:00:00 2001 From: PiQuark6046 Date: Wed, 11 Mar 2026 20:14:29 +0900 Subject: [PATCH 1/2] Potential fix for code scanning alert no. 10: Uncontrolled data used in path expression Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- builder/source/cache.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/builder/source/cache.ts b/builder/source/cache.ts index 766572a..e9e295c 100644 --- a/builder/source/cache.ts +++ b/builder/source/cache.ts @@ -1,10 +1,14 @@ import * as Zod from 'zod' import * as Fs from 'node:fs' import * as Process from 'node:process' +import * as Path from 'node:path' import { FetchAdShieldDomains } from './references/index.js' -const CachePath = (Process.env.INIT_CWD ? Process.env.INIT_CWD : Process.cwd()) + '/.buildcache' -const CacheDomainsPath = CachePath + '/domains.json' +const BaseCacheDir = (Process.env.INIT_CWD && Path.isAbsolute(Process.env.INIT_CWD)) + ? Process.env.INIT_CWD + : Process.cwd() +const CachePath = Path.join(Path.resolve(BaseCacheDir), '.buildcache') +const CacheDomainsPath = Path.join(CachePath, 'domains.json') export function CreateCache(Domains: Set) { if (!Fs.existsSync(CachePath)) { From a2b96be8b7cb5d4c62b168209dfa6a906afe432d Mon Sep 17 00:00:00 2001 From: PiQuark6046 Date: Wed, 11 Mar 2026 20:17:03 +0900 Subject: [PATCH 2/2] Potential fix for code scanning alert no. 11: Uncontrolled data used in path expression Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- builder/source/cache.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/builder/source/cache.ts b/builder/source/cache.ts index e9e295c..396e2d1 100644 --- a/builder/source/cache.ts +++ b/builder/source/cache.ts @@ -4,10 +4,14 @@ import * as Process from 'node:process' import * as Path from 'node:path' import { FetchAdShieldDomains } from './references/index.js' -const BaseCacheDir = (Process.env.INIT_CWD && Path.isAbsolute(Process.env.INIT_CWD)) - ? Process.env.INIT_CWD - : Process.cwd() -const CachePath = Path.join(Path.resolve(BaseCacheDir), '.buildcache') +const ProjectRoot = Path.resolve(Process.cwd()) +const EnvInitCwd = Process.env.INIT_CWD && Path.isAbsolute(Process.env.INIT_CWD) + ? Path.resolve(Process.env.INIT_CWD) + : null +const BaseCacheDir = (EnvInitCwd && (EnvInitCwd === ProjectRoot || EnvInitCwd.startsWith(ProjectRoot + Path.sep))) + ? EnvInitCwd + : ProjectRoot +const CachePath = Path.join(BaseCacheDir, '.buildcache') const CacheDomainsPath = Path.join(CachePath, 'domains.json') export function CreateCache(Domains: Set) {