Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@makehq/sdk",
"version": "1.21.0",
"version": "1.22.0",
"description": "Make TypeScript SDK",
"license": "MIT",
"author": "Make",
Expand Down
75 changes: 74 additions & 1 deletion src/endpoints/scenarios.tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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<string, JSONValue> }) => {
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<string, JSONValue> }) => {
return await make.scenarios.validateNewBlueprint(args.teamId, args.blueprint);
},
},
];
83 changes: 83 additions & 0 deletions src/endpoints/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,56 @@ type DeactivateScenarioResponse = {
scenario: Pick<Scenario, 'id' | 'isActive'>;
};

/**
* 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
Expand Down Expand Up @@ -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<string, JSONValue>,
): Promise<ValidateBlueprintResult> {
return await this.#fetch<ValidateBlueprintResult>(`/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<string, JSONValue>): Promise<ValidateBlueprintResult> {
return await this.#fetch<ValidateBlueprintResult>(
`/scenarios/v1/scenarios/teams/${teamId}/blueprint/validate`,
{
method: 'POST',
body: { blueprint },
},
);
}
}
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ export type {
RunScenarioOptions,
ReplayScenarioResponse,
Scheduling,
BlueprintFinding,
BlueprintFindingRuleId,
BlueprintFindingSeverity,
ValidateBlueprintResult,
} from './endpoints/scenarios.js';
export type {
SDKApp,
Expand Down
16 changes: 16 additions & 0 deletions test/mocks/scenarios/validate-blueprint.json
Original file line number Diff line number Diff line change
@@ -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/"
}
]
}
43 changes: 43 additions & 0 deletions test/scenarios-tools.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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']);
});
});
42 changes: 42 additions & 0 deletions test/scenarios.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
});
});
});