From d461969945198a969384a6ff4d78d568acf7ca73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20R=C5=AF=C5=BEi=C4=8Dka?= Date: Fri, 4 Dec 2026 13:53:12 +0100 Subject: [PATCH] feat(scenarios): validate a blueprint for plain-text secrets (BAR-4584) Co-authored-by: Cursor --- README.md | 2 +- package-lock.json | 4 +- package.json | 2 +- src/endpoints/scenarios.tools.ts | 75 +++++++++++++++++- src/endpoints/scenarios.ts | 83 ++++++++++++++++++++ src/index.ts | 4 + test/mocks/scenarios/validate-blueprint.json | 16 ++++ test/scenarios-tools.spec.ts | 43 ++++++++++ test/scenarios.spec.ts | 42 ++++++++++ 9 files changed, 266 insertions(+), 5 deletions(-) create mode 100644 test/mocks/scenarios/validate-blueprint.json diff --git a/README.md b/README.md index 402e55b..1b3e198 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Use `make.functionsV2` for versioned authoring, Endpoint discovery and durable R - **Private Spaces** - Per-user private workspaces within an organization (list, get, update) - **Roles** - Built-in and custom roles and their permissions (list, get, permissions) - **Custom Roles** - User-defined organization or team roles (create, update, delete) -- **Scenarios** - Scenario management +- **Scenarios** - Scenario management, including scanning a blueprint for plain-text secrets - **Teams** - Team management and collaboration - **Public Templates** - Public template discovery and blueprint export (read-only) - **Templates** - A team's own saved templates (create, update, delete, blueprint export) diff --git a/package-lock.json b/package-lock.json index 3cc7a8d..811300e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@makehq/sdk", - "version": "1.21.0", + "version": "1.22.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@makehq/sdk", - "version": "1.21.0", + "version": "1.22.0", "license": "MIT", "devDependencies": { "@eslint/js": "^9.22.0", diff --git a/package.json b/package.json index 4eed603..50852de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@makehq/sdk", - "version": "1.21.0", + "version": "1.22.0", "description": "Make TypeScript SDK", "license": "MIT", "author": "Make", diff --git a/src/endpoints/scenarios.tools.ts b/src/endpoints/scenarios.tools.ts index 55f84fc..35a06de 100644 --- a/src/endpoints/scenarios.tools.ts +++ b/src/endpoints/scenarios.tools.ts @@ -70,7 +70,7 @@ const schedulingInputSchema: JSONSchema = { const blueprintInputSchema: JSONSchema = { type: 'object', description: - "Blueprint containing the scenario configuration. Every `module` value must be an existing module identifier verified via app-modules_list — never invent module names.", + 'Blueprint containing the scenario configuration. Every `module` value must be an existing module identifier verified via app-modules_list — never invent module names.', properties: { name: { type: 'string', description: 'Name of the scenario' }, flow: { @@ -584,4 +584,77 @@ export const tools: MakeTool[] = [ return await make.scenarios.setInterface(args.scenarioId, { interface: args.interface }); }, }, + { + name: 'scenarios_validate-blueprint', + title: 'Validate scenario blueprint for secrets', + description: + "Scan a blueprint for plain-text secrets typed straight into module settings: credentials in headers, query parameters and fields, user:password@ in URLs, and values in known token formats. Mappings ({{...}}) are not findings. Send the blueprint you are about to save in `blueprint`; when omitted, the scenario's stored blueprint is scanned. Each finding gives a JSON Pointer, the module and field, and what to use instead (a connection or a key). Findings never contain the secret itself. This is a secrets check only, not a structural check of the blueprint. For a scenario that was never saved use scenarios_validate-new-blueprint.", + category: 'scenarios', + scope: 'scenarios:write', + scopeId: 'scenarioId', + identifier: 'scenarioId', + resourceId: 'scenarioId', + annotations: { + readOnlyHint: true, + destructiveHint: false, + idempotentHint: true, + openWorldHint: false, + }, + inputSchema: { + type: 'object', + properties: { + scenarioId: { type: 'number', description: 'The scenario ID' }, + blueprint: { + type: 'object', + description: + "The blueprint to scan, as a JSON object (not a string). Omit to scan the scenario's stored blueprint.", + }, + }, + required: ['scenarioId'], + }, + examples: [{ scenarioId: 925 }], + execute: async (make: Make, args: { scenarioId: number; blueprint?: Record }) => { + return await make.scenarios.validateBlueprint(args.scenarioId, args.blueprint); + }, + }, + { + name: 'scenarios_validate-new-blueprint', + title: 'Validate new scenario blueprint for secrets', + description: + 'Scan the blueprint of a scenario that was never saved for plain-text secrets (credentials in headers, query parameters and fields, user:password@ in URLs, values in known token formats). Use it before scenarios_create. Mappings ({{...}}) are not findings. Findings never contain the secret itself. This is a secrets check only, not a structural check of the blueprint.', + category: 'scenarios', + scope: 'scenarios:write', + scopeId: 'teamId', + identifier: 'teamId', + annotations: { + readOnlyHint: true, + destructiveHint: false, + idempotentHint: true, + openWorldHint: false, + }, + inputSchema: { + type: 'object', + properties: { + teamId: { type: 'number', description: 'The team the scenario will be saved in' }, + blueprint: { + type: 'object', + description: 'The blueprint to scan, as a JSON object (not a string)', + }, + }, + required: ['teamId', 'blueprint'], + }, + examples: [ + { + teamId: 18, + blueprint: { + flow: [ + { id: 1, module: 'http:ActionSendData', version: 3, mapper: { url: 'https://example.com' } }, + ], + }, + }, + ], + execute: async (make: Make, args: { teamId: number; blueprint: Record }) => { + return await make.scenarios.validateNewBlueprint(args.teamId, args.blueprint); + }, + }, ]; diff --git a/src/endpoints/scenarios.ts b/src/endpoints/scenarios.ts index dab1c22..ca7a6ae 100644 --- a/src/endpoints/scenarios.ts +++ b/src/endpoints/scenarios.ts @@ -353,6 +353,56 @@ type DeactivateScenarioResponse = { scenario: Pick; }; +/** + * How serious a blueprint validation finding is. + */ +export type BlueprintFindingSeverity = 'high' | 'medium' | 'low' | 'info'; + +/** + * The rule that produced a blueprint validation finding. + */ +export type BlueprintFindingRuleId = + | 'secret-in-header' + | 'secret-in-query-parameter' + | 'secret-in-field' + | 'credentials-in-url' + | 'known-token-format'; + +/** + * A problem found in a blueprint. A finding names the place and what to do instead, + * it never contains the secret value itself. + */ +export type BlueprintFinding = { + /** The rule that produced the finding */ + ruleId: BlueprintFindingRuleId; + /** How serious the finding is */ + severity: BlueprintFindingSeverity; + /** RFC 6901 JSON Pointer from the blueprint root to the string that holds the secret */ + pointer: string; + /** The module the string sits in. Absent for a string outside any module */ + moduleId?: number; + /** The type of the module the string sits in (e.g. 'http:ActionSendData') */ + moduleType?: string; + /** The header, parameter or field to look for. Never the secret */ + fieldName?: string; + /** What is wrong and why it matters */ + message: string; + /** What to do instead */ + remediation: string; + /** Documentation link */ + docsUrl?: string; +}; + +/** + * Result of validating a blueprint for plain-text secrets. + */ +export type ValidateBlueprintResult = { + /** `valid` unless the blueprint itself is structurally broken. Secret findings never change it */ + status: 'valid' | 'invalid'; + /** Most serious first, then in blueprint order. At most 500 are returned */ + findings: BlueprintFinding[]; +}; + /** * Class providing methods for working with Make scenarios. * Scenarios allow you to create and run automation tasks consisting of a series of modules @@ -599,4 +649,37 @@ export class Scenarios { }) ).interface; } + + /** + * Validate a scenario blueprint for plain-text secrets (credentials typed straight into module settings). + * @param scenarioId The scenario ID. Used to read the stored blueprint when none is sent + * @param blueprint The blueprint to scan, as a parsed object (for example the one about to be saved). + * When omitted, the scenario's stored blueprint is scanned. + * @returns Promise with the validation result + */ + async validateBlueprint( + scenarioId: number, + blueprint?: Record, + ): Promise { + return await this.#fetch(`/scenarios/v1/scenarios/${scenarioId}/blueprint/validate`, { + method: 'POST', + body: blueprint ? { blueprint } : {}, + }); + } + + /** + * Validate the blueprint of a scenario that was never saved for plain-text secrets. + * @param teamId The team the scenario will be saved in + * @param blueprint The blueprint to scan, as a parsed object + * @returns Promise with the validation result + */ + async validateNewBlueprint(teamId: number, blueprint: Record): Promise { + return await this.#fetch( + `/scenarios/v1/scenarios/teams/${teamId}/blueprint/validate`, + { + method: 'POST', + body: { blueprint }, + }, + ); + } } diff --git a/src/index.ts b/src/index.ts index 993f758..06bc172 100644 --- a/src/index.ts +++ b/src/index.ts @@ -240,6 +240,10 @@ export type { RunScenarioOptions, ReplayScenarioResponse, Scheduling, + BlueprintFinding, + BlueprintFindingRuleId, + BlueprintFindingSeverity, + ValidateBlueprintResult, } from './endpoints/scenarios.js'; export type { SDKApp, diff --git a/test/mocks/scenarios/validate-blueprint.json b/test/mocks/scenarios/validate-blueprint.json new file mode 100644 index 0000000..acc1da6 --- /dev/null +++ b/test/mocks/scenarios/validate-blueprint.json @@ -0,0 +1,16 @@ +{ + "status": "valid", + "findings": [ + { + "ruleId": "secret-in-header", + "severity": "high", + "pointer": "/flow/0/mapper/headers/0/value", + "moduleId": 7, + "moduleType": "http:ActionSendData", + "fieldName": "Authorization", + "message": "The Authorization header holds a plain-text credential.", + "remediation": "Store the credential in a connection or a keychain entry and map it.", + "docsUrl": "https://help.make.com/" + } + ] +} diff --git a/test/scenarios-tools.spec.ts b/test/scenarios-tools.spec.ts index fcf4d26..5d4e76a 100644 --- a/test/scenarios-tools.spec.ts +++ b/test/scenarios-tools.spec.ts @@ -4,6 +4,7 @@ import { MakeTools } from '../src/tools.js'; import { mockFetch } from './test.utils.js'; import * as scenariosMock from './mocks/scenarios/list.json'; +import * as validateBlueprintMock from './mocks/scenarios/validate-blueprint.json'; const MAKE_API_KEY = 'api-key'; const MAKE_ZONE = 'make.local'; @@ -58,4 +59,46 @@ describe('MCP tools: scenarios', () => { ]); expect(tool.inputSchema.properties?.labelIds?.items?.type).toBe('number'); }); + + it('Should execute scenarios_validate-blueprint against the public validate route', async () => { + const blueprint = { flow: [{ id: 7, module: 'http:ActionSendData' }] }; + mockFetch( + 'POST https://make.local/api/v2/scenarios/v1/scenarios/18/blueprint/validate', + validateBlueprintMock, + req => { + expect(req.body).toStrictEqual({ blueprint }); + }, + ); + + const tool = getTool('scenarios_validate-blueprint'); + const result = await tool.execute(make, { scenarioId: 18, blueprint }); + + expect(result).toStrictEqual(validateBlueprintMock); + }); + + it('Should execute scenarios_validate-new-blueprint for a team', async () => { + const blueprint = { flow: [] }; + mockFetch( + 'POST https://make.local/api/v2/scenarios/v1/scenarios/teams/5/blueprint/validate', + validateBlueprintMock, + req => { + expect(req.body).toStrictEqual({ blueprint }); + }, + ); + + const tool = getTool('scenarios_validate-new-blueprint'); + const result = await tool.execute(make, { teamId: 5, blueprint }); + + expect(result).toStrictEqual(validateBlueprintMock); + }); + + it('Should declare the blueprint validation tools as read-only and scenarios:write scoped', () => { + for (const name of ['scenarios_validate-blueprint', 'scenarios_validate-new-blueprint']) { + const tool = getTool(name); + expect(tool.scope).toBe('scenarios:write'); + expect(tool.annotations?.readOnlyHint).toBe(true); + } + expect(getTool('scenarios_validate-blueprint').inputSchema.required).toStrictEqual(['scenarioId']); + expect(getTool('scenarios_validate-new-blueprint').inputSchema.required).toStrictEqual(['teamId', 'blueprint']); + }); }); diff --git a/test/scenarios.spec.ts b/test/scenarios.spec.ts index ca5cc8c..be1825e 100644 --- a/test/scenarios.spec.ts +++ b/test/scenarios.spec.ts @@ -12,6 +12,7 @@ import * as scenarioCreateMock from './mocks/scenarios/create.json'; import * as scenarioGetMock from './mocks/scenarios/get.json'; import * as scenarioUpdateMock from './mocks/scenarios/update.json'; import * as scenarioDeactivateMock from './mocks/scenarios/deactivate.json'; +import * as scenarioValidateBlueprintMock from './mocks/scenarios/validate-blueprint.json'; const MAKE_API_KEY = 'api-key'; const MAKE_ZONE = 'make.local'; @@ -282,5 +283,46 @@ describe('Endpoints: Scenarios', () => { const result = await make.scenarios.deactivate(5); expect(result).toBe(true); }); + + it('Should validate the sent blueprint of a scenario', async () => { + const blueprint = { flow: [{ id: 7, module: 'http:ActionSendData' }] }; + mockFetch( + 'POST https://make.local/api/v2/scenarios/v1/scenarios/18/blueprint/validate', + scenarioValidateBlueprintMock, + req => { + expect(req.body).toStrictEqual({ blueprint }); + }, + ); + + const result = await make.scenarios.validateBlueprint(18, blueprint); + expect(result).toStrictEqual(scenarioValidateBlueprintMock); + }); + + it('Should validate the stored blueprint of a scenario when none is sent', async () => { + mockFetch( + 'POST https://make.local/api/v2/scenarios/v1/scenarios/18/blueprint/validate', + scenarioValidateBlueprintMock, + req => { + expect(req.body).toStrictEqual({}); + }, + ); + + const result = await make.scenarios.validateBlueprint(18); + expect(result.findings).toHaveLength(1); + }); + + it('Should validate the blueprint of a scenario that was never saved', async () => { + const blueprint = { flow: [] }; + mockFetch( + 'POST https://make.local/api/v2/scenarios/v1/scenarios/teams/5/blueprint/validate', + scenarioValidateBlueprintMock, + req => { + expect(req.body).toStrictEqual({ blueprint }); + }, + ); + + const result = await make.scenarios.validateNewBlueprint(5, blueprint); + expect(result).toStrictEqual(scenarioValidateBlueprintMock); + }); }); });