Skip to content

FOUR-34328: [EPIC] PM4 MCP - #9160

Open
caleeli wants to merge 152 commits into
developfrom
feature/FOUR-34328
Open

caleeli wants to merge 152 commits into
developfrom
feature/FOUR-34328

Conversation

@caleeli

@caleeli caleeli commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

MCP Server

Related Tickets & Packages

PR's Related

ProcessMaker/modeler#1970
ProcessMaker/nayra#241

ci:nayra:FOUR-34376
ci:modeler:feature/FOUR-34380
ci:k8s-branch:FOUR-34294b
ci:package-testing:adjust_dependency

ci:deploy

marcoAntonioNina and others added 30 commits July 21, 2026 15:47
…ce and WorkflowManagerInterface

- Introduced ScriptModuleInterface for module exposure in PHP scripts.
- Updated ServiceTaskImplementationInterface to allow an optional timeout parameter in the run method.
- Modified WorkflowManagerInterface to include a timeout parameter in the runServiceImplementation method.
…-process

- Introduced ScriptRuntime facade for managing script execution context and module registration.
- Added InProcessPhpRunner to run PHP scripts directly within the Laravel process.
- Updated ScriptRunner to support in-process execution based on script properties.
- Enhanced WorkflowManager and Script models to accommodate new functionality, including allow_in_process property.
- Implemented bootstrap for in-process execution and improved error handling for script execution.
- Introduced ScriptExecutionContext to encapsulate per-run context for script modules.
- The class includes properties for data, configuration, user, token ID, timeout, script ID, and source.
- This addition supports the in-process execution of PHP scripts by providing necessary context information.
- Introduced CoreServiceTask class to handle the execution of allowlisted PHP scripts without Docker or the script microservice.
- Implemented validation for script configuration, including script ID and user requirements.
- Added support for both module-based and bare execution modes.
- Enhanced error handling for various execution scenarios, ensuring robust configuration checks.
- Utilized ScriptRuntime and InProcessPhpRunner for executing scripts based on the defined context.
- Enhanced ScriptController to support a new `run_in_process` property for script previews, allowing execution via an in-process PHP runner when enabled.
- Updated TestScript job to handle the new `runInProcess` parameter, enabling direct script execution without Docker.
- Introduced `shouldPreviewInProcess` method to determine if in-process execution is applicable based on script properties and request flags.
- Added comprehensive unit tests to validate in-process execution scenarios and ensure proper handling of configuration and execution context.
- Implemented new test cases for CoreServiceTask to verify in-process script execution and error handling for various conditions.
commit b84543b
Author: AugustoLopezProcess <augusto.lopez+github@processmaker.com>
Date:   Tue Apr 21 08:27:15 2026 -0400

    Adding plugin admin ui

commit ca8a863
Author: Nolan Ehrstrom <github@nolanpro.com>
Date:   Mon Mar 9 11:01:46 2026 -0700

    Add controllers and routes for plugin UI

    Copied from feature/plugins-poc-vite-ui (just without the vite/Vue3 integration)

commit 3cc89bc
Merge: 9e9b4aa 5da27ce
Author: Nolan Ehrstrom <github@nolanpro.com>
Date:   Mon Mar 9 10:58:27 2026 -0700

    Merge branch 'task/FOUR-28803' into feature/plugins-poc

commit 9e9b4aa
Author: Nolan Ehrstrom <github@nolanpro.com>
Date:   Mon Jan 19 12:30:54 2026 -0800

    Add install command and cached routes

commit 4a5df14
Author: Nolan Ehrstrom <github@nolanpro.com>
Date:   Wed Dec 10 09:29:20 2025 -0800

    Start on plugins
Updating feature/plugins-poc-4 with last changes in develop
FOUR-32722 Some adjustments in plugins installation
FOUR-32760 After install/enable/disable a plugin, should be executed the command: php artisan horizon:terminate
…ink, add load screen-builder-form.js files from plugin
…ink, add load screen-builder-form.js files from plugin
…ink, add load screen-builder-form.js files from plugin
…ink, add load screen-builder-form.js files from plugin
@pmPaulis pmPaulis changed the title FOUR-34328: [EPIC] MCP FOUR-34328: [EPIC] PM4 MCP Nov 25, 2026

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

$pluginName,
$userId
);
$this->publishRuntimeReload($pluginName, $userId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local recycle skips other pods

High Severity

When recycleLocalRuntime succeeds, plugin install/toggle/uninstall returns without publishing the Redis reload. Other pods never restart their Octane workers, so they keep serving stale in-memory plugin code after a change on this replica.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7279e57. Configure here.

Comment thread ProcessMaker/Managers/PluginManager.php Resolved
customModalButtons.value[2].disabled = false;
customModalButtons.value[0].hidden = true;
customModalButtons.value[1].hidden = true;
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Install close button stays hidden

Medium Severity

showInstallCloseButton requires serverRestartReady unless allowFailure is set. onPluginJobError never passes that flag, so after a failed install the Close button stays hidden and the user cannot dismiss the create-plugin modal from the footer.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7279e57. Configure here.

serverRestartReady.value = false;
serverRestartMessage.value = $t("Waiting for server restart...");
serverRestartTimer = setInterval(checkServerRestart, 3000);
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Health poll beats restart delay

Medium Severity

Restart polling treats the first /health/live 200 as proof the new process is up. The listener delays supervisor restart by 5 seconds and the first poll is at 3 seconds, so the still-running old process can mark the UI ready and enable Close before Octane actually recycles.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7279e57. Configure here.

updateBranch.value = item.branch || "";
updateTag.value = item.tag || "";
initUpdateModalButtons();
showUpdatePluginModal();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update modal sends tag as branch

Medium Severity

The update modal writes item.branch into the Branch field and item.tag into Tag, but the plugins list only returns branch as getReference() (tag preferred). A plugin on a tag pre-fills Branch with that tag. Continue then reinstalls with branch set, so checkout plus git pull origin &lt;tag&gt; runs on detached HEAD and fails.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7279e57. Configure here.

$lines[] = ' header_up Host {http.request.host}';
$lines[] = ' header_up X-Forwarded-Proto {http.request.header.X-Forwarded-Proto}';
$lines[] = ' header_up X-Forwarded-For {http.request.remote.host}';
$lines[] = ' flush_interval -1';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edge proxy drops client IP

Medium Severity

The generated edge Caddyfile sets X-Forwarded-For to {http.request.remote.host}. Nginx already fronts this proxy on localhost, so tenant Octane sees 127.0.0.1 instead of the original client IP for logs, rate limits, and IP-based checks.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7279e57. Configure here.

Comment thread routes/api.php
@@ -133,6 +144,26 @@
Route::get('scripts/execution/{key}', [ScriptController::class, 'execution'])->name('scripts.execution');
Route::post('scripts/microservice/execution', [ScriptController::class, 'microserviceExecution']);

// Deploy / sync helpers (core). Canonical paths + package-skeleton aliases for BC.
Route::post('deploy-script', [DeployScript::class, 'deployScript'])->name('deploy-script');
Route::get('script-php', [DeployScript::class, 'getScriptPhp'])->name('script-php');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review

Severity: MEDIUM

Description: The new deploy sync GETs return stored process BPMN and published script PHP by name to any API token. They do not apply the view-processes or view-scripts permission that gates the canonical process BPMN download and script show routes. getProcessBpmn and getScriptPhp never call authorize().

Impact: A non-designer user who can create a personal access token (any user, for their own account) can read another user's process definition and the PHP source of scripts referenced by it. Process BPMN is hidden on the process model and is only downloaded through a view-processes route. Script source is only returned by scripts.show behind view-scripts. Restored BPMN rewrites screen and script ids back to titles, so one known process name yields the script titles needed for the script read. That exposes workflow design and any credentials or queries embedded in script source to participants who were not granted designer view permissions.

Remediation: Put the same view gates used by the canonical routes on both the core and package-skeleton GET aliases: can:view-processes before returning BPMN and can:view-scripts before returning script source (authorize the loaded model, not only a global flag). Return the same not-found response when the caller lacks view permission as when the name does not exist.

Comment thread routes/ai.php

Mcp::local('flow-genies', FlowGenieServer::class);

Mcp::oauthRoutes();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review

Severity: HIGH

Description: MCP OAuth issues a normal Passport user bearer (public client, advertised scope mcp:use) and both /mcp/* and /api/1.0 accept it with auth:api only. Nothing binds the token to the MCP resource or enforces mcp:use, so the IDE client, or anyone holding that bearer, can call the rest of the API as the consenting user.

Impact: The OAuth client is a lower-trust desktop agent (dynamic public registration, token_endpoint_auth_method none), and the product treats MCP OAuth as distinct from a ProcessMaker API token. After the user approves the Passport consent screen, the bearer is a general API credential. It can call every /api/1.0 route that user can call, including admin-only plugin install when the user is an administrator (Gate::before). It can also hit the new deploy-script, deploy-screen, and deploy-process routes, which persist PHP, screen config, and BPMN with no can:* check and no controller authorization. ScriptPolicy::execute allows any non-anonymous user, so that bearer can run the PHP it just wrote. That is application control and code execution beyond the MCP tools shown for processes, screens, connectors, and flow genies.

Remediation: Register mcp:use with Passport::tokensCan and audience-restrict MCP access tokens to the MCP resource (RFC 8707 resource indicator stored on the token). Reject tokens whose audience or scope is MCP on non-MCP /api/* routes, and require mcp:use plus that audience on /mcp/. Keep deploy-script, deploy-screen, and deploy-process behind the same can: checks as the matching script, screen, and process create/edit routes.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

}

return $this->saveDeployedProcess($request);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy APIs skip permission checks

High Severity

The new deploy endpoints upsert processes, screens, and scripts by name and return their BPMN/YAML/PHP, but they never authorize create-/edit-/view- abilities. Unlike the existing CRUD routes, any authenticated API user can overwrite designer assets they cannot otherwise change.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit df04a71. Configure here.

throw new AuthorizationException();
}

return redirect()->route($route);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

view-plugins redirect hits 403

Medium Severity

Admin home now treats view-plugins as a valid landing permission and sends those users to plugins.index, but that route is gated by manage-plugins. Users who only have view-plugins (and none of the earlier admin abilities) are redirected into a 403.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit df04a71. Configure here.

public function failed(Throwable $exception): void
{
event(new PluginLog(
'Plugin reinstall failed: ' . $exception->getMessage(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review

Severity: HIGH

Description: ReinstallPlugin::failed broadcasts the raw exception message on PluginLog. updateExistingRepository runs git remote set-url origin with a URL that prepareGitUrl has already filled with env GITHUB_TOKEN (when the request omits git credentials and the remote is https://github.com/) or with the caller-supplied git token. That set-url call sits before the try/finally that restores the clean origin and has no ProcessTimedOutException handler. InstallPlugin treats this exact failure as secret-bearing: its comment says a process timeout can embed the command line, and publicErrorMessage runs PluginManager::redactHttpUserInfoFromString before the same broadcast. Symfony's timeout exception message is the full command line, so a 60s set-url stall sends the token to the initiating user's private PluginLog channel and into the queue failure record.

Impact: A manage-plugins operator on the authenticated API can learn the instance GITHUB_TOKEN, which the server embeds and which that permission is not supposed to receive. The same unredacted command line is what the install job already strips before PluginLog. The stall is an environmental git hang (for example a stuck config lock), so it is not scriptable at scale, but when it happens the disclosed value is the full credential. Because set-url throws before the restore finally, a timeout also skips stripping the authenticated origin from .git/config if the write landed; the plugin list API still strips userinfo, so the proven disclosure sink is the exception text.

Remediation: Wrap the authenticated git remote set-url in the same try/finally as fetch so a timeout still restores the credential-free origin, and catch ProcessTimedOutException around that command with a message that does not include argv. In ReinstallPlugin::failed, pass the exception message through PluginManager::redactHttpUserInfoFromString the same way InstallPlugin::publicErrorMessage does.

@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-ef28357a3a.engk8s.processmaker.net

@nolanpro

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://tenant-1.ci-ef28357a3a.engk8s.processmaker.net

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

There are 33 total unresolved issues (including 31 from previous reviews).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0557af4. Configure here.

$process->alternative = 'B';

try {
$version = $publish ? $process->saveVersion() : $process->saveDraft('B');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alt B deploy keeps A's derived fields

High Severity

Alternative B deploy assigns the new bpmn on the live Process and calls saveVersion() or saveDraft('B') without saving the process. Derived fields such as start_events, signal_events, self_service_tasks, and timer metadata stay as Alternative A's values and are copied onto the B version, so B can run or list the wrong start events and assignments.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0557af4. Configure here.

private const NON_FIELD_COMPONENTS = [
'FormButton', 'FormText', 'FormHtmlViewer', 'FormHtmlEditor', 'FormImage', 'FormNestedScreen',
'FormCollectionViewControl', 'PageNavigation', 'FormMultiColumn', 'FormLoop',
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nested screens omitted from inventory fields

Medium Severity

ProcessInventory treats FormNestedScreen as a non-field control and never loads the nested screen's config. Gateway variables that are only written in a nested screen are reported as missing, producing false warnings that an undefined condition will put the request in ERROR.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0557af4. Configure here.

@decisions-sonarqube

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
30 New issues
27 New Maintainability Issues (required ≤ 0)
B Security Rating on New Code (required ≥ A)

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants