Skip to content
Merged
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: 0 additions & 2 deletions .github/actions/build-docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ runs:
swc_arch='arm64'
fi

find /tmp/build/bundle/programs/server/npm/node_modules/meteor/babel-compiler/node_modules/@meteorjs/swc-core/.swc/node_modules/@swc -type d -name 'core-*' -not -name "*linux-${swc_arch}-gnu*" -exec rm -rf {} +

find /tmp/build/bundle/programs/server/npm/node_modules/@img -type d -name 'sharp-*' -not -name "*-linuxmusl-${swc_arch}" -exec rm -rf {} +

find /tmp/build/bundle/programs/server/npm/node_modules/@napi-rs -type d -name 'pinyin-linux-*' -not -name "*-linux-${swc_arch}-*" -exec rm -rf {} +
Comment on lines 85 to 87

@cubic-dev-ai cubic-dev-ai Bot Apr 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: Guard these find cleanup commands against missing directories; otherwise optional package layout differences can break Docker builds.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/actions/build-docker/action.yml, line 85:

<comment>Guard these `find` cleanup commands against missing directories; otherwise optional package layout differences can break Docker builds.</comment>

<file context>
@@ -82,13 +82,13 @@ runs:
           fi
 
-          # find /tmp/build/bundle/programs/server/npm/node_modules/@img -type d -name 'sharp-*' -not -name "*-linuxmusl-${swc_arch}" -exec rm -rf {} +
+          find /tmp/build/bundle/programs/server/npm/node_modules/@img -type d -name 'sharp-*' -not -name "*-linuxmusl-${swc_arch}" -exec rm -rf {} +
 
-          # find /tmp/build/bundle/programs/server/npm/node_modules/@napi-rs -type d -name 'pinyin-linux-*' -not -name "*-linux-${swc_arch}-*" -exec rm -rf {} +
</file context>
Fix with Cubic

Expand Down
19 changes: 9 additions & 10 deletions apps/meteor/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ rocketchat:mongo-config
rocketchat:livechat
rocketchat:version

accounts-base@3.1.2
accounts-base@3.2.0
accounts-facebook@1.3.4
accounts-google@1.4.1
accounts-meteor-developer@1.5.1
accounts-oauth@1.4.6
accounts-password@3.2.1
accounts-password@3.2.2
accounts-twitter@1.5.2

google-oauth@1.4.5
oauth@3.0.2
oauth2@1.3.3

check@1.4.4
check@1.5.0
ddp-rate-limiter@1.2.2
rate-limit@1.1.2
email@3.1.2

meteor-base@1.5.2
ddp-common@1.4.4
webapp@2.0.7
webapp@2.1.0

mongo@2.1.4
mongo@2.2.0

reload@1.3.2
service-configuration@1.3.5
session@1.2.2
shell-server@0.6.2
shell-server@0.7.0

dispatch:run-as-user
ostrio:cookies
Expand All @@ -50,11 +50,10 @@ tracker@1.3.4
reactive-dict@1.3.2
reactive-var@1.0.13

babel-compiler@7.12.2
standard-minifier-css@1.9.3
standard-minifier-css@1.10.0
dynamic-import@0.7.4
ecmascript@0.16.13
typescript@5.6.6
ecmascript@0.17.0
typescript@5.9.3

autoupdate@2.0.1

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/.meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
METEOR@3.3.2
METEOR@3.4
28 changes: 14 additions & 14 deletions apps/meteor/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
accounts-base@3.1.2
accounts-base@3.2.0
accounts-facebook@1.3.4
accounts-google@1.4.1
accounts-meteor-developer@1.5.1
accounts-oauth@1.4.6
accounts-password@3.2.1
accounts-password@3.2.2
accounts-twitter@1.5.2
allow-deny@2.1.0
autoupdate@2.0.1
babel-compiler@7.12.2
babel-compiler@7.13.0
babel-runtime@1.5.2
base64@1.0.13
binary-heap@1.0.12
boilerplate-generator@2.0.2
boilerplate-generator@2.1.0
callback-hook@1.6.1
check@1.4.4
check@1.5.0
core-runtime@1.0.0
ddp@1.4.2
ddp-client@3.1.1
Expand All @@ -23,7 +23,7 @@ ddp-server@3.1.2
diff-sequence@1.1.3
dispatch:run-as-user@1.1.1
dynamic-import@0.7.4
ecmascript@0.16.13
ecmascript@0.17.0
ecmascript-runtime@0.8.3
ecmascript-runtime-client@0.12.3
ecmascript-runtime-server@0.11.1
Expand All @@ -41,16 +41,16 @@ id-map@1.2.0
inter-process-messaging@0.1.2
localstorage@1.2.1
logging@1.3.6
meteor@2.1.1
meteor@2.2.0
meteor-base@1.5.2
meteor-developer-oauth@1.3.3
meteorhacks:inject-initial@1.0.5
minifier-css@2.0.1
minimongo@2.0.4
minimongo@2.0.5
modern-browsers@0.2.3
modules@0.20.3
modules-runtime@0.13.2
mongo@2.1.4
mongo@2.2.0
mongo-decimal@0.2.0
mongo-dev-server@1.1.1
mongo-id@1.0.9
Expand All @@ -63,7 +63,7 @@ ostrio:cookies@2.7.2
promise@1.0.0
random@1.2.2
rate-limit@1.1.2
react-fast-refresh@0.2.9
react-fast-refresh@0.3.0
reactive-dict@1.3.2
reactive-var@1.0.13
reload@1.3.2
Expand All @@ -75,15 +75,15 @@ routepolicy@1.1.2
service-configuration@1.3.5
session@1.2.2
sha@1.0.10
shell-server@0.6.2
shell-server@0.7.0
socket-stream-client@0.6.1
standard-minifier-css@1.9.3
standard-minifier-css@1.10.0
tracker@1.3.4
twitter-oauth@1.3.4
typescript@5.6.6
typescript@5.9.3
underscore@1.6.4
url@1.3.5
webapp@2.0.7
webapp@2.1.0
webapp-hashing@1.1.2
zodern:caching-minifier@0.5.0
zodern:standard-minifier-js@5.3.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { transformSync } from '@babel/core';
import presetEnv from '@babel/preset-env';
Comment thread
KevLehman marked this conversation as resolved.
import type { IUser, INewOutgoingIntegration, IOutgoingIntegration, IUpdateOutgoingIntegration } from '@rocket.chat/core-typings';
import { Subscriptions, Users, Rooms } from '@rocket.chat/models';
import { pick } from '@rocket.chat/tools';
import { Babel } from 'meteor/babel-compiler';
import { Match } from 'meteor/check';
import { Meteor } from 'meteor/meteor';

Expand Down Expand Up @@ -179,13 +180,15 @@ export const validateOutgoingIntegration = async function (
integration.script.trim() !== ''
) {
try {
const babelOptions = Object.assign(Babel.getDefaultOptions({ runtime: false }), {
const result = transformSync(integration.script, {
presets: [presetEnv],
compact: true,
minified: true,
comments: false,
});

integrationData.scriptCompiled = Babel.compile(integration.script, babelOptions).code;
// TODO: Webhook Integration Editor should inform the user if the script is compiled successfully
integrationData.scriptCompiled = result?.code ?? undefined;
Comment on lines +183 to +191

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Same modules: false consideration applies here.

This file has the same preset-env configuration as updateIncomingIntegration.ts. If the module transformation issue is confirmed, apply the same fix here:

🛠️ Proposed fix
 const result = transformSync(integration.script, {
-  presets: [presetEnv],
+  presets: [[presetEnv, { modules: false }]],
   compact: true,
   minified: true,
   comments: false,
 });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const result = transformSync(integration.script, {
presets: [presetEnv],
compact: true,
minified: true,
comments: false,
});
integrationData.scriptCompiled = Babel.compile(integration.script, babelOptions).code;
integrationData.scriptCompiled = result?.code ?? undefined;
const result = transformSync(integration.script, {
presets: [[presetEnv, { modules: false }]],
compact: true,
minified: true,
comments: false,
});
integrationData.scriptCompiled = result?.code ?? undefined;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/app/integrations/server/lib/validateOutgoingIntegration.ts`
around lines 184 - 191, The preset-env usage in the transformSync call that
produces integrationData.scriptCompiled should explicitly disable module
transformation to mirror the fix in updateIncomingIntegration.ts; update the
transformSync invocation that uses presetEnv (or the presetEnv definition) so it
includes { modules: false } when passing presets to transformSync for
integration.script, ensuring compiled output doesn't rewrite ES modules.

Comment thread
ggazzo marked this conversation as resolved.
integrationData.scriptError = undefined;
} catch (e) {
integrationData.scriptCompiled = undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { transformSync } from '@babel/core';
import presetEnv from '@babel/preset-env';
import type { INewIncomingIntegration, IIncomingIntegration } from '@rocket.chat/core-typings';
import type { ServerMethods } from '@rocket.chat/ddp-client';
import { Integrations, Subscriptions, Users, Rooms } from '@rocket.chat/models';
import { Random } from '@rocket.chat/random';
import { removeEmpty } from '@rocket.chat/tools';
import { Babel } from 'meteor/babel-compiler';
import { Match, check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import _ from 'underscore';
Expand Down Expand Up @@ -111,10 +112,15 @@ export const addIncomingIntegration = async (userId: string, integration: INewIn
integration.script.trim() !== ''
) {
try {
let babelOptions = Babel.getDefaultOptions({ runtime: false });
babelOptions = _.extend(babelOptions, { compact: true, minified: true, comments: false });
const result = transformSync(integration.script, {
presets: [presetEnv],
compact: true,
minified: true,
comments: false,
});

integrationData.scriptCompiled = Babel.compile(integration.script, babelOptions).code;
// TODO: Webhook Integration Editor should inform the user if the script is compiled successfully
integrationData.scriptCompiled = result?.code ?? undefined;
Comment on lines +115 to +123

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Same modules: false consideration applies here.

This file shares the same preset-env configuration. Apply the same fix if the module transformation is confirmed to break the isolated-vm sandbox:

🛠️ Proposed fix
 const result = transformSync(integration.script, {
-  presets: [presetEnv],
+  presets: [[presetEnv, { modules: false }]],
   compact: true,
   minified: true,
   comments: false,
 });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const result = transformSync(integration.script, {
presets: [presetEnv],
compact: true,
minified: true,
comments: false,
});
integrationData.scriptCompiled = Babel.compile(integration.script, babelOptions).code;
integrationData.scriptCompiled = result?.code ?? undefined;
const result = transformSync(integration.script, {
presets: [[presetEnv, { modules: false }]],
compact: true,
minified: true,
comments: false,
});
integrationData.scriptCompiled = result?.code ?? undefined;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/meteor/app/integrations/server/methods/incoming/addIncomingIntegration.ts`
around lines 116 - 123, The preset-env configuration used when calling
transformSync(integration.script, { presets: [presetEnv], ... }) can transform
ES modules and break the isolated-vm sandbox; update the transform invocation or
the presetEnv config to disable module transformation by setting modules: false
(e.g., ensure presetEnv includes { modules: false }) so that transformSync keeps
module syntax intact and then assign the compiled code to
integrationData.scriptCompiled as before; update references in the transformSync
call and any presetEnv variable definition so the change applies where
transformSync is invoked.

Comment thread
ggazzo marked this conversation as resolved.
delete integrationData.scriptError;
} catch (e) {
integrationData.scriptCompiled = undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { transformSync } from '@babel/core';
import presetEnv from '@babel/preset-env';
import type { IIntegration, INewIncomingIntegration, IUpdateIncomingIntegration } from '@rocket.chat/core-typings';
import type { ServerMethods } from '@rocket.chat/ddp-client';
import { Integrations, Subscriptions, Users, Rooms } from '@rocket.chat/models';
import { wrapExceptions } from '@rocket.chat/tools';
import { Babel } from 'meteor/babel-compiler';
import { Meteor } from 'meteor/meteor';
import _ from 'underscore';

import { addUserRolesAsync } from '../../../../../server/lib/roles/addUserRoles';
import { hasAllPermissionAsync, hasPermissionAsync } from '../../../../authorization/server/functions/hasPermission';
Expand Down Expand Up @@ -90,10 +90,15 @@ export const updateIncomingIntegration = async (

if (integration.scriptEnabled === true && integration.script && integration.script.trim() !== '') {
try {
let babelOptions = Babel.getDefaultOptions({ runtime: false });
babelOptions = _.extend(babelOptions, { compact: true, minified: true, comments: false });
const result = transformSync(integration.script, {
presets: [presetEnv],
compact: true,
minified: true,
comments: false,
});

scriptCompiled = Babel.compile(integration.script, babelOptions).code;
// TODO: Webhook Integration Editor should inform the user if the script is compiled successfully
scriptCompiled = result?.code ?? undefined;
Comment thread
ggazzo marked this conversation as resolved.
scriptError = undefined;
await Integrations.updateOne(
{ _id: integrationId },
Expand Down
5 changes: 3 additions & 2 deletions apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
"@aws-sdk/client-s3": "^3.862.0",
"@aws-sdk/lib-storage": "^3.862.0",
"@aws-sdk/s3-request-presigner": "^3.862.0",
"@babel/core": "~7.28.6",
"@babel/preset-env": "~7.28.6",
"@babel/runtime": "~7.28.6",
"@bugsnag/js": "~7.20.2",
"@bugsnag/plugin-react": "~7.19.0",
Expand Down Expand Up @@ -311,8 +313,6 @@
},
"devDependencies": {
"@axe-core/playwright": "^4.10.2",
"@babel/core": "~7.28.6",
"@babel/preset-env": "~7.28.6",
"@babel/preset-react": "~7.27.1",
"@babel/register": "~7.28.6",
"@faker-js/faker": "~8.0.2",
Expand All @@ -334,6 +334,7 @@
"@testing-library/user-event": "~14.6.1",
"@types/adm-zip": "^0.5.7",
"@types/archiver": "~6.0.4",
"@types/babel__preset-env": "^7.10.0",
"@types/bad-words": "^3.0.3",
"@types/bcrypt": "^5.0.2",
"@types/body-parser": "^1.19.6",
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10071,6 +10071,7 @@ __metadata:
"@testing-library/user-event": "npm:~14.6.1"
"@types/adm-zip": "npm:^0.5.7"
"@types/archiver": "npm:~6.0.4"
"@types/babel__preset-env": "npm:^7.10.0"
"@types/bad-words": "npm:^3.0.3"
"@types/bcrypt": "npm:^5.0.2"
"@types/body-parser": "npm:^1.19.6"
Expand Down Expand Up @@ -13703,6 +13704,13 @@ __metadata:
languageName: node
linkType: hard

"@types/babel__preset-env@npm:^7.10.0":
version: 7.10.0
resolution: "@types/babel__preset-env@npm:7.10.0"
checksum: 10/7d4d12758d89708afe327079d7d7580e8af3292295f087b8a9a48e12ac1d90aadc18ac3bc00f9b0cbc8778f3ce9fe778801d4d49b7691a75e3f13a901b69fd07
languageName: node
linkType: hard

"@types/babel__template@npm:*":
version: 7.4.1
resolution: "@types/babel__template@npm:7.4.1"
Expand Down
Loading