Skip to content

Commit ae2b306

Browse files
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>
1 parent a25e92c commit ae2b306

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

builder/source/cache.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import * as Zod from 'zod'
22
import * as Fs from 'node:fs'
33
import * as Process from 'node:process'
4+
import * as Path from 'node:path'
45
import { FetchAdShieldDomains } from './references/index.js'
56

6-
const CachePath = (Process.env.INIT_CWD ? Process.env.INIT_CWD : Process.cwd()) + '/.buildcache'
7-
const CacheDomainsPath = CachePath + '/domains.json'
7+
const BaseCacheDir = (Process.env.INIT_CWD && Path.isAbsolute(Process.env.INIT_CWD))
8+
? Process.env.INIT_CWD
9+
: Process.cwd()
10+
const CachePath = Path.join(Path.resolve(BaseCacheDir), '.buildcache')
11+
const CacheDomainsPath = Path.join(CachePath, 'domains.json')
812

913
export function CreateCache(Domains: Set<string>) {
1014
if (!Fs.existsSync(CachePath)) {

0 commit comments

Comments
 (0)