MCPcopy Create free account
hub / github.com/Noumena-Network/code / isNcodeSettingsPath

Function isNcodeSettingsPath

src/utils/permissions/filesystem.ts:213–238  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

211}
212
213export function isNcodeSettingsPath(filePath: string): boolean {
214 // SECURITY: Normalize path structure first to prevent bypass via redundant ./
215 // sequences like `./.ncode/./settings.json` or `./.claude/./settings.json`
216 // which would evade the endsWith() check
217 const expandedPath = expandPath(filePath)
218
219 // Normalize for case-insensitive comparison to prevent bypassing security
220 // with paths like .cLauDe/Settings.locaL.json
221 const normalizedPath = normalizeCaseForComparison(expandedPath)
222
223 // Use platform separator so endsWith checks work on both Unix (/) and Windows (\)
224 if (
225 normalizedPath.endsWith(`${sep}.ncode${sep}settings.json`) ||
226 normalizedPath.endsWith(`${sep}.ncode${sep}settings.local.json`) ||
227 normalizedPath.endsWith(`${sep}.claude${sep}settings.json`) ||
228 normalizedPath.endsWith(`${sep}.claude${sep}settings.local.json`)
229 ) {
230 // Include managed project settings paths even for other projects
231 return true
232 }
233 // Check for current project's settings files (including managed settings and CLI args)
234 // Both paths are now absolute and normalized for consistent comparison
235 return getSettingsPaths().some(
236 settingsPath => normalizeCaseForComparison(settingsPath) === normalizedPath,
237 )
238}
239
240// Always ask when NCode tries to edit its own config files
241function isNcodeConfigFilePath(filePath: string): boolean {

Callers 3

isNcodeConfigFilePathFunction · 0.85

Calls 3

expandPathFunction · 0.85
getSettingsPathsFunction · 0.85

Tested by

no test coverage detected