Packages built without the UI are incomplete, so -Dskip.yarn=true and
-Dskip.ui.build=true now imply -Dpkg.skip=true through dedicated profiles
in the root pom and msa/pom.xml.
This replaces the module-level pkg.skip.zip properties in msa/js-executor
and msa/web-ui, which shadowed the root skip-pkg profile and made
-Dpkg.skip=true build their Windows ZIPs again.
frontend-maven-plugin reads skip.yarn on its own, so -Dskip.yarn=true switches
off every yarn invocation in the project at once. That is the right shortcut for
a local backend build, but it is too blunt for CI: it also silences the
msa/js-executor sandbox tests, which are the only yarn-driven tests worth
keeping.
skip.ui.build is declared once in the root pom and defaults to ${skip.yarn}. It
is wired into the frontend-maven-plugin configuration of ui-ngx and msa/web-ui,
and into the pkg.skip.zip of msa/web-ui, whose Windows ZIP bundles the launcher
that `yarn run pkg` produces. It is deliberately NOT wired into
msa/js-executor: with -Dskip.ui.build=true that module still runs its yarn
install, its `yarn run pkg` and its sandbox tests.
Behaviour:
no flags everything builds and is tested as before
-Dskip.ui.build=true ui-ngx and msa/web-ui skip;
msa/js-executor still builds and runs its tests
-Dskip.yarn=true everything skips, exactly as before
The <skip> element is declared at plugin level rather than per execution so that
it also covers the executions contributed by the yarn-build and yarn-start
profiles, and so that node/yarn itself is no longer downloaded when there is
nothing to run.
The yarn test execution in msa/js-executor declared its own skip flag,
which overrode the mojo default of ${skip.yarn}, so a build run with
-Dskip.yarn=true still invoked yarn run test with no node_modules
installed. The two JS packaging modules had the same gap: the ZIP
assembly requires a launcher binary produced by yarn run pkg, so it
failed on a missing file rather than being skipped along with the yarn
work that would have produced it.
Both now follow skip.yarn while continuing to honour maven.test.skip.
Two test layers covering the controller surface that the JVN PoC uses:
Java unit (Spring MockMvc):
RuleChainControllerTest#testScriptForbiddenForCustomer asserts a
customer JWT against POST /api/ruleChain/testScript returns 403,
locking in the existing @PreAuthorize('TENANT_ADMIN') guard.
Black-box (live docker-compose):
JsExecutorSandboxIsolationTest#testRuleChainScriptCannotReachHostProcess
posts the JVN exploit payload as a tenant admin and asserts the
response carries error='process is not defined'. End-to-end through
tb-node -> Kafka -> tb-js-executor with use_sandbox=true.
Registered the new org.thingsboard.server.msa.security package in
the connectivity TestNG suite so the black-box runner picks it up.
Added a thin TestRestClient.testRuleChainScript() helper.
Four test cases under describe('js-executor'):
- sandbox isolates args from host realm (JVN#16937365 — regression guard)
- sandbox passes string args through unchanged
- non-sandbox path does not isolate from host realm (documented contract)
- non-sandbox path passes string args through unchanged
Tests use Node's built-in node:test + node:assert (zero new devDependencies;
ts-node was already there). Two npm scripts:
test — spec output for local dev
test:ci — spec to stdout + Node's built-in junit reporter to
target/surefire-reports/TEST-js-executor.xml
Wired 'yarn test:ci' into the Maven 'test' phase via frontend-maven-plugin,
so 'mvn test -pl=msa/js-executor' produces JUnit XML that TeamCity's
Maven runner auto-discovers under the 'js-executor' suite name.
TEST_FAST.md picks up the same step.
tsconfig excludes test/ from the production pkg bundle.
The args array passed into the sandbox carried the host realm prototype
chain, so a script could reach the host Function constructor via
args.constructor.constructor and execute arbitrary code in the host
process (read files, run shell commands, dump env vars).
Construct args inside the sandbox context using vm.runInContext('[]'),
then populate with string primitives. The resulting array's prototype
chain belongs to the sandbox realm, so constructor traversal cannot
escape. Strings are primitives and safe to cross the realm boundary.
Affects use_sandbox=true path only. The use_sandbox=false path
(invokeFunction) is intentionally left as-is and explicitly marked as
dangerous-by-design — it compiles and runs user-supplied scripts in
the host realm via vm.compileFunction (parsingContext only isolates
parsing, not execution). It remains as a documented performance
trade-off for trusted, non-public clusters; a startup WARN is logged
when script.use_sandbox=false, and an operator-facing yaml comment
sits next to the setting in config/default.yml.
Reported by Hiroki Imai, LAC Co., Ltd.
--no-bytecode is only required for the Windows target; running pkg as a
single multi-target invocation applied it to Linux too, dropping V8
bytecode from the Linux exe. Split into two pkg invocations so Linux
keeps bytecode and only the Windows build relaxes it.
Under `mvn -T<n>` with the three yarn-using modules (ui-ngx,
msa/web-ui, msa/js-executor), concurrent yarn 1.x processes contend
on the shared `~/.cache/yarn`. The `--mutex network` flag was applied
only to `yarn install`, so `yarn run pkg` could overlap with another
module's install. Intermittent failures observed on CI:
`/bin/sh: 1: tsc: not found` during `yarn run pkg`, caused by
incomplete typescript extraction into per-module node_modules.
Fix at two layers:
1. Maven reactor chain (primary): add reactor-only pom <dependency>
entries (type=pom, scope=provided, wildcard exclusions) to form
ui-ngx -> msa/web-ui -> msa/js-executor
so the MultiThreadedBuilder schedules them strictly serial,
regardless of -T thread count. msa/web-ui already had a real
dependency on ui-ngx; only one new fake link was needed.
2. Yarn-level mutex (defense in depth): add `--mutex network` to
`yarn run pkg` (msa/web-ui, msa/js-executor) and
`yarn run build:prod` (ui-ngx), so single-module builds outside the
reactor chain (`mvn -pl msa/<module>`) still serialize against any
other yarn process on the agent.
Comment in msa/pom.xml updated: the previous "Modules order is
important..." note was misleading - module order in the reactor does
not enforce serialization under -T; the dependency edges do.
The base image thingsboard/openjdk17:bookworm-slim ships a customized
/etc/java-17-openjdk/security/java.security. When apt-get install pulls
in a newer openjdk-17-jre-headless to satisfy cassandra's java11-runtime
dependency, dpkg blocks on a non-interactive conffile prompt and the
build fails. The ensuing "cassandra depends on java11-runtime" error is
just the cascade from openjdk-17-jre-headless never finishing configure.
Pass --force-confdef --force-confold so dpkg silently keeps the base
image's customized conffile and the upgrade completes.