MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / schemaPathFor

Function schemaPathFor

src/core/structured-output-schema.ts:80–97  ·  view source on GitHub ↗
(ref: StructuredOutputSchemaRef)

Source from the content-addressed store, hash-verified

78}
79
80function schemaPathFor(ref: StructuredOutputSchemaRef): string {
81 const schemasDir = getStructuredOutputSchemasDir();
82 const schemaPath = path.join(schemasDir, ref.schema, `${ref.version}.schema.json`);
83 const resolvedPath = path.resolve(schemaPath);
84 const resolvedSchemasDir = path.resolve(schemasDir);
85
86 // Prevent path traversal attacks by ensuring the resolved path is within the schemas directory
87 if (
88 !resolvedPath.startsWith(resolvedSchemasDir + path.sep) &&
89 resolvedPath !== resolvedSchemasDir
90 ) {
91 throw new Error(
92 `Invalid schema path: attempted path traversal detected for ${ref.schema}@${ref.version}`,
93 );
94 }
95
96 return schemaPath;
97}
98
99function collectAndRewriteCommonRefs(value: unknown, pendingDefs: Set<string>): unknown {
100 if (Array.isArray(value)) {

Callers 1

getMcpOutputSchemaFunction · 0.85

Calls 2

resolveMethod · 0.80

Tested by

no test coverage detected