fix(mcp): reject unknown MCP tool inputs (#975)
* fix(mcp): reject unknown official tool inputs * fix(mcp): reject unknown native tool inputs * test(mcp): follow native contract module move * fix(mcp): reject unknown remaining tool inputs * fix(mcp): satisfy strict unknown and browser input schemas Remove obsolete approval fields from residual-unknown fixtures, project update inputs explicitly, and stop passing target_id to list-targets parsing. --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
@@ -94,7 +94,7 @@ const browserInput = {
|
||||
};
|
||||
|
||||
/** Public input for complete discovery, optionally filtered by exact origin. */
|
||||
export const listBrowserTargetsInputSchema = z.object({
|
||||
export const listBrowserTargetsInputSchema = z.strictObject({
|
||||
...browserInput,
|
||||
});
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ export const parseCallPathAddress = (input: unknown): string =>
|
||||
inputAddressSchema.parse(input);
|
||||
|
||||
/** Strict input for explicit call-path reconstruction from complete dossiers. */
|
||||
export const callPathInputSchema = z.object({
|
||||
export const callPathInputSchema = z.strictObject({
|
||||
functions: z.array(evidenceSchema).min(1),
|
||||
start: z.object({ address: inputAddressSchema }).strict(),
|
||||
goal: z.object({ address: inputAddressSchema }).strict(),
|
||||
|
||||
@@ -19,7 +19,7 @@ import { prefixedDigestSchema } from "./../domain/digests.js";
|
||||
const evidenceIdSchema = prefixedDigestSchema("ev");
|
||||
|
||||
/** Input for aggregating existing comparison Evidence. */
|
||||
export const changedBehaviorInputSchema = z.object({
|
||||
export const changedBehaviorInputSchema = z.strictObject({
|
||||
comparisons: z.array(evidenceSchema).default([]),
|
||||
});
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ const makeUnknown = (
|
||||
dependency?: string,
|
||||
) => {
|
||||
const input = recordUnknownInputSchema.parse({
|
||||
approved: true,
|
||||
question,
|
||||
severity: "medium",
|
||||
domain: "bundle-projection",
|
||||
@@ -95,7 +94,6 @@ describe("evidenceBundleForTarget", () => {
|
||||
const unknowns = [foreignRoot.unknown, middle.unknown];
|
||||
for (let index = 0; index < 125_000; index += 1) {
|
||||
const input = recordUnknownInputSchema.parse({
|
||||
approved: true,
|
||||
question: `Target child ${index}`,
|
||||
severity: "medium",
|
||||
domain: "bundle-projection",
|
||||
|
||||
@@ -167,12 +167,13 @@ export const recordUnknownInputSchema = residualUnknownObjectSchema
|
||||
.extend({
|
||||
supporting_evidence_ids: z.array(evidenceIdSchema).default([]),
|
||||
contradicting_evidence_ids: z.array(evidenceIdSchema).default([]),
|
||||
});
|
||||
})
|
||||
.strict();
|
||||
|
||||
export type RecordUnknownInput = z.infer<typeof recordUnknownInputSchema>;
|
||||
|
||||
/** Explicit optimistic-concurrency update command for one unknown. */
|
||||
export const updateUnknownInputSchema = z.object({
|
||||
export const updateUnknownInputSchema = z.strictObject({
|
||||
unknown_id: unknownIdSchema,
|
||||
expected_revision: z.number().int().min(1),
|
||||
status: residualUnknownObjectSchema.shape.status,
|
||||
|
||||
Reference in New Issue
Block a user