Repository navigation
Conversation
|
Please fix conflicts. Also: we're expecting you're reviewing, testing, and editing before opening the PR. Including a statement of "never ran CI tests" doesn't make me super confident. You can run them locally with |
That's why I announced this in Discord first. I let the agents do their thing and I'm also reviewing these now and running tests. I supposed I could've marked them Drafts. |
|
@NicoPiel You can't have any merge commits in your PR with the project's linear history requirement. If you hard reset your branch to the myBatis commit before the merge (7f8f597), you can do an interactive rebase and drop the dbcp2 commit. After that you can do a clean rebase on main with only 3 commits in the PR. I wouldn't worry about the removals missing from |
439d496 to
83622e2
Compare
|
Done, thanks |
tonygermano
left a comment
There was a problem hiding this comment.
Thanks for the rebase. The code changes look good to me. My comments are mostly about the commit messages, plus one compatibility point that should go in the release notes.
Commit messages
- Bump commons-pool2 to 2.13.1: "commons-dbcp2 releases from 2.10 on need a recent pool2" no longer applies. main dropped dbcp2 in a178dfb, and this PR no longer has the dbcp2 commit. I'd remove that sentence; the age of 2.3 is reason enough.
- Bump mybatis to 3.5.19: the metadata entry for mybatis-parent 15 isn't just dropped, it's replaced by mybatis-parent 48, which is 3.5.19's parent.
- Bump mybatis to 3.5.19: "The other String and Integer parameterTypes match what their callers pass" isn't quite true.
DebugUsage.deleteDebugUsageStatisticsdeclaresjava.lang.String, butDefaultDebugUsageControllerpasses aDebugUsagebean. It still works on 3.5, because the parameter handler finds no type handler forDebugUsage, reads#{serverId}from the bean, and gets a String. So it's only an inaccurate declaration, not a bug. You could either change it tocom.mirth.connect.model.DebugUsagein the five*-debugusage.xmlmappers or reword the sentence. Either is fine with me.
Plugin SQL maps (release notes)
SqlConfig.addPluginSqlMaps loads SQL maps from installed plugins into the same MyBatis configuration. A third-party plugin whose mapper has the same mismatch as selectPreferencesForUser (a simple parameterType that differs from what the caller passes) will now get a ClassCastException at runtime instead of working. Nothing in this repo needs a change for that, but it should be called out for plugin authors in the release notes for whichever release includes this, together with the HikariCP default changes listed in the Hikari commit message.
It would also be worth mentioning in the PR description that this resolves CVE-2020-26945 / GHSA-qq48-m4jx-xqh8 (MyBatis < 3.5.6, second-level cache deserialization). cacheEnabled is true in SqlMapConfig.xml.
What Claude checked
- The sha256 of every new jar and POM in
verification-metadata.xmlmatches the artifact downloaded from Maven Central. HikariCP 7.1.0 and mybatis-parent 48 have no parent POM, and commons-parent 93 (the parent of pool2 2.13.1) already has an entry. - HikariCP 7.1.0 is Java 11 bytecode, and its only non-optional runtime dependency is slf4j-api. It's compiled against slf4j 2.0.17 but uses none of the 2.x-only API (no
org.slf4j.spi/ fluentatXxx()calls), so the slf4j 1.7.30 we ship works. commons-pool2 2.13.1 has only optional and test dependencies. - The mybatis 3.5.19 jar shades OGNL 3.4.4 and javassist 3.30.2-GA, which matches the THIRD-PARTY-README changes. The jar's own NOTICE still carries the same OGNL BSD notice the README reproduces.
- Every simple
parameterType(String/Integer) inserver/dbconfmatches its caller's argument type, except theDebugUsagecase above. The<if test='value != null'>statements (getAlert,getChannel,getCodeTemplate, and so on) still work on 3.5 with both a String and anullargument, becauseDynamicContextfalls back to the parameter object for simple types. HikariConnectionPoolcalls only setters that still exist in 7.x. InFileConnector,setTimeBetweenEvictionRunsMillis(0)still disables the evictor in pool2 2.13, which treats a non-positive duration as "no evictor".- OSV reports no known vulnerabilities for HikariCP 7.1.0, commons-pool2 2.13.1 or mybatis 3.5.19.
Drafted with Claude Code
|
@tonygermano Anything you would like me to do? I can't read any further asks out of that message. Approved? |
83622e2 to
2dae1e5
Compare
2dae1e5 to
1af9250
Compare
|
@NicoPiel Sorry for the slow answer. It's not approved yet. Thanks for the commit-message updates and the rebase. I've pushed the remaining changes to your branch as two
Please also drop the commons-pool2 commit. In 2.13, To apply it yourself: Claude also tested the squashed result at runtime, and everything passed:
Drafted with Claude Code |
2.5.1 is from 2016. 7.1.0 is the current release and runs on Java 11+; it needs only slf4j-api at runtime, which the build already ships (the metrics and javassist dependencies are optional and unused here). The calls in HikariConnectionPool are unchanged in 7.x: a connectionTimeout of 0 still means wait indefinitely, and ProxyConnection.unwrap(Connection.class) still returns the driver's connection. Behavior that does change comes from upstream defaults, such as idle connections now being pinged every two minutes (keepaliveTime). Signed-off-by: Nico Piel <nicopiel@mailbox.org>
3.1.1 is from 2012. 3.5.19 is the last Java 8 release of the 3.5 line. 3.6.0 is only days old, so this stays on 3.5. OGNL and javassist are still shaded inside the mybatis jar, and nothing else is needed at runtime. The 3.5 line binds a simple parameterType's type handler from the declared type. User.selectPreferencesForUser declared java.lang.String but is called with the Integer user id, so it now declares java.lang.Integer in every database's mapper. Upstream Mirth made the same change when it moved to 3.5.15. DebugUsage.getDebugUsageStatistics and deleteDebugUsageStatistics declared java.lang.String but are called with a DebugUsage, so they now declare that class; they worked either way, because the serverId property they read is a String. The other String and Integer parameterTypes match what their callers pass. MyBatis stopped logging SQL under the java.sql loggers in 3.2 and logs each statement under its own ID instead, so the java.sql entry in log4j2.properties had no effect any more. logPrefix is now set, so every statement logs under mybatis.<namespace>.<id>, and that entry now names mybatis, so one logger still controls all SQL logging. The comments there now explain how to log a single namespace and warn that DEBUG and TRACE can write sensitive data to the logs. mybatis-parent 15 was only the parent of 3.1.1, so its checksum entry is replaced by mybatis-parent 48, the parent of 3.5.19. Signed-off-by: Nico Piel <nicopiel@mailbox.org> Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Tony Germano <tony@germano.name>
8fbe423 to
60cf02f
Compare
|
Merging this also closes #381 |
jonbartels
left a comment
There was a problem hiding this comment.
I left one non-blocking comment.
jonbartels
left a comment
There was a problem hiding this comment.
The core mappers look right after this change. I checked every statement in server/dbconf/*/*.xml against its Java caller, and none still declare the wrong parameterType. What's left are upgrade-compatibility issues that need fixing or documenting before merge: plugin mappers, the HikariCP keepalive default, existing java.sql logging configs, and the OGNL license notice. Details are inline.
These checked out: HikariCP 7.1.0 works with the pinned slf4j 1.7.30 (it only calls 1.7-compatible methods), its Java 11 bytecode is fine on the Java 17 toolchain, setConnectionTimeout(0) still means wait indefinitely, and the custom TypeHandlers, BridgeDataSourceFactory, getMappedStatement's IllegalArgumentException and logPrefix all still behave the same on 3.5.19.
| mockito-inline = { module = "org.mockito:mockito-inline", version.ref = "mockito" } | ||
| mssql-jdbc = { module = "com.microsoft.sqlserver:mssql-jdbc", version = "10.2.4.jre11" } | ||
| mybatis = { module = "org.mybatis:mybatis", version = "3.1.1" } | ||
| mybatis = { module = "org.mybatis:mybatis", version = "3.5.19" } |
There was a problem hiding this comment.
Plugin mappers can break with no warning. From 3.2 on, MyBatis picks the type handler for static SQL from the declared parameterType when the mapper is parsed. Before, it used the runtime argument. This PR fixes the core mappers, but mapper XMLs that plugins load through SqlConfig.addPluginSqlMaps aren't covered.
Example: a plugin declares parameterType='java.lang.String' on a static <select> and passes an Integer, the same mismatch fixed here in selectPreferencesForUser. That worked on 3.1.1 because every statement was treated as dynamic. On 3.5.19 it binds StringTypeHandler and throws ClassCastException on every call. Please add a release or upgrade note telling plugin authors to check their parameterType declarations.
| hapi-structures-v28 = { module = "ca.uhn.hapi:hapi-structures-v28", version.ref = "hapi" } | ||
| hapi-structures-v281 = { module = "ca.uhn.hapi:hapi-structures-v281", version.ref = "hapi" } | ||
| hikaricp = { module = "com.zaxxer:HikariCP", version = "2.5.1" } | ||
| hikaricp = { module = "com.zaxxer:HikariCP", version = "7.1.0" } |
There was a problem hiding this comment.
HikariCP 6+ turns keepalive on by default. The default keepaliveTime went from 0 (off) to 2 minutes (DEFAULT_KEEPALIVE_TIME in the 7.1.0 jar). donkey/.../HikariConnectionPool.java doesn't set it, so every idle pooled connection now gets pinged about every 2 minutes, up to the 10-minute idleTimeout. With jdbc4=false that ping is the configured testQuery.
That's new background query traffic compared with 2.5.1, which matters for large pools and remote or metered databases. Either call setKeepaliveTime(0) to keep the old behaviour, or keep the new default on purpose and say so in the release notes.
| # message content (which may contain PHI), channel and server configuration | ||
| # (including passwords stored in it), and user credential hashes. Enable it | ||
| # only while troubleshooting, and protect or delete the resulting logs. | ||
| logger.sql.name = mybatis |
There was a problem hiding this comment.
Existing installs lose SQL logging. MyBatis 3.5 no longer logs SQL under java.sql.* (3.1's ConnectionLogger and PreparedStatementLogger). It logs under mybatis.<namespace>.<id>. Existing installs keep their own conf/log4j2.properties, so a logger.sql.name = java.sql line there stops working with no error. This needs an upgrade note telling operators to switch to mybatis.
Related: SqlConfig still calls LogFactory.useLog4JLogging(), which sends MyBatis through its deprecated Log4j 1 adapter (Log4jImpl) and the log4j-1.2-api bridge. Since this PR already reworks SQL logging, consider switching to LogFactory.useLog4J2Logging() so a later bump that drops either piece doesn't break it.
|
|
||
| The license below pertains to OGNL (Object-Graph Navigation Language), which is | ||
| included within the MyBatis 3.1.1 library. | ||
| included within the MyBatis 3.5.19 library. |
There was a problem hiding this comment.
Wrong OGNL license. This block now says OGNL is included within MyBatis 3.5.19, but it still carries the 2004 Drew Davidson/Luke Blanshard BSD text. MyBatis 3.5.19 bundles OGNL 3.4.4 (orphan-oss), which is Apache-2.0. It belongs in the Apache 2.0 list with its version, like the new Javassist 3.30.2-GA entry.
| </update> | ||
|
|
||
| <select id='selectPreferencesForUser' parameterType='java.lang.String' resultType='KeyValuePair'> | ||
| <select id='selectPreferencesForUser' parameterType='java.lang.Integer' resultType='KeyValuePair'> |
There was a problem hiding this comment.
Optional: the fix here is a hand edit of the declared type, repeated in all 5 database copies. The declaration is the fragile part, because if it's ever wrong again, static SQL fails only at runtime and only on that database. Removing parameterType from statements that take a single simple value makes MyBatis resolve the handler from the runtime value (Object -> UnknownTypeHandler). That removes this class of bug instead of needing 10 matching edits.
| </update> | ||
|
|
||
| <delete id='deleteDebugUsageStatistics' parameterType='java.lang.String'> | ||
| <delete id='deleteDebugUsageStatistics' parameterType='com.mirth.connect.model.DebugUsage'> |
There was a problem hiding this comment.
Nothing tests the behaviour change that made these parameterType edits necessary. The unit tests mock SqlSessionManager (for example DefaultUserControllerAuthorizeUserTest), so a future mismatch in one database's mapper would pass CI and only fail in production. A test that builds the SqlSessionFactory for each database's mappers and runs these statements against embedded Derby would catch it.
What
Bumps two stale database-layer libraries, one commit each:
This PR originally also bumped commons-dbcp2 and commons-pool2. Main has since removed the custom DBCP pooling and the dbcp2 dependency, so that commit was dropped. The pool2 commit was dropped after review: in 2.13,
GenericObjectPool.invalidateObject()always creates a replacement object, which would open an extra connection per message in File Writers with "Keep connection open" off. It can come back in its own PR together with a File connector fix.Why
MyBatis 3.1.1 dates from 2012, and HikariCP 2.5.1 from 2016. The MyBatis bump also resolves CVE-2020-26945 / GHSA-qq48-m4jx-xqh8 (MyBatis < 3.5.6, deserialization through the second-level cache), which applies here because
cacheEnabledistrueinSqlMapConfig.xml. It supersedes Renovate's MyBatis 3.5.6 security update in #381, which can be closed once this merges.Reviewer notes
parameterType.User.selectPreferencesForUserdeclaredjava.lang.Stringbut receives an Integer, so it's nowjava.lang.Integerin all 5 database mappers. This is the same fix upstream Mirth made.DebugUsage.getDebugUsageStatisticsanddeleteDebugUsageStatisticsnow declarecom.mirth.connect.model.DebugUsage, which is whatDefaultDebugUsageControllerpasses (they worked either way). Every other String and IntegerparameterTypematches its caller.java.sqlloggers, so thejava.sqlentry inlog4j2.propertieshad stopped doing anything.SqlMapConfig.xmlnow setslogPrefixtomybatis., and that entry namesmybatis, so one logger still controls all SQL logging. Its comments explain how to log one namespace and warn that DEBUG and TRACE can log PHI, stored passwords and credential hashes.#{name}bind parameters from main's event-search SQL injection fix also work under 3.5.connectionTimeout(0)still means wait forever. HikariCP 7 needs only slf4j-api, which already ships.Release Note
Library updates: MyBatis 3.5.19 and HikariCP 7.1.0
These replace MyBatis 3.1.1 and HikariCP 2.5.1. The changes below are the ones that remain in the new versions and apply to the engine.
Security
<cache>was. MyBatis 3.5.6 and later also log a one-time warning the first time a cache entry is deserialized without ajdk.serialFilterset.SQL logging
java.sqlloggers. Each statement now logs undermybatis.<namespace>.<statement ID>, for examplemybatis.Message.getMessages: SQL and parameters at DEBUG, result rows at TRACE. The defaultlog4j2.propertiesnow setslogger.sql.name = mybatis, sologger.sql.levelstill controls all SQL logging. If an upgraded installation keeps its existinglog4j2.properties, changelogger.sql.name = java.sqltologger.sql.name = mybatisthere. Raising a more specific logger, such asmybatis.Message, logs only those statements. At the default ERROR level nothing is logged, before or after. When SQL logging is enabled, the logger names in the log lines change accordingly, so update any log filters, parsers or alerts that matchjava.sql.Connection,java.sql.PreparedStatementorjava.sql.ResultSet.Database connection pool (HikariCP)
maxLifetimewith up to 25% random variation), instead of 29.25 to 30 minutes, so connections are replaced somewhat more often.0A000, and error code 1105 from any database. An error while closing a statement left open when its connection is returned now also removes the connection, with a warning in the log.PersistenceException("Error getting a new connection") caused by the driver'sSQLException, instead of aHikariPool$PoolInitializationException("Failed to initialize pool"). The server still retries as before.HikariPool-1:housekeeper. Update any log alerts or thread-dump tooling that matches the old text.For plugin authors
Plugin SQL maps and type handlers now run on MyBatis 3.5. Check for the following:
<if>,${}, and so on), a simpleparameterTypesuch asjava.lang.Stringnow fixes the type handler. Calling it with a different type, such as anInteger, fails with aPersistenceExceptioncaused by aClassCastException. MakeparameterTypematch what the plugin passes, or remove it.mybatis-3-mapper.dtd(as inhttp://mybatis.org/dtd/mybatis-3-mapper.dtd, orconf/dtd/mybatis-3-mapper.dtdas the engine's own SQL maps use; the path doesn't need to exist), not by the public ID. With any other system ID, the parser tries to load the DTD from that location, and the mapper fails to load if it can't.ResultSet.wasNull()aftergetNullableResult, so a handler that returns0orfalsefor SQL NULL now returns that value instead ofnull.Executor,ParameterHandler,ResultSetHandlerorStatementHandler.PersistenceExceptionis still the exception to catch, but its message and cause chain now contain more wrapping, such asTypeExceptionandResultMapException.Testing
buildandverifyVendoredParityon these two commits, and earlier a staged server on a fresh Derby DB driven through about 30 REST calls.GET /events/countwithout a level filter returns 500, with MyBatis 3.1.1 too.🤖 Generated with Claude Code