nextgenhealthcare / connect

The swiss army knife of healthcare integration.
Other
868 stars 265 forks source link

EVENT.IP_ADDRESS does not hold some addresses and do crash #6136

Open FoSoFix opened 3 months ago

FoSoFix commented 3 months ago

for some reason my issue raised with a value of 50 image

while the maximum lenght is coded as 40 as seems in https://github.com/nextgenhealthcare/connect/blob/bde0bdbafe9d81d57875b8afe80978188cafc7f9/server/dbconf/oracle/oracle-database.sql#L13

I did fix the Oracle with ALTER TABLE MIRTH.EVENT MODIFY IP_ADDRESS VARCHAR2(120);

then the saved value results to be a triple private ipv4 as follows 10.56.111.229:53709, 10.190.160.116, 10.188.160.68

pacmano1 commented 3 months ago

That a multihomed mirth engine with all those IPs?

ab-mg-23 commented 3 months ago

If there's an X-Forwarded-For header on messages that hit the Mirth API endpoint it uses that for the IP_ADDRESS. https://github.com/nextgenhealthcare/connect/blob/bde0bdbafe9d81d57875b8afe80978188cafc7f9/core-server-plugins/src/com/mirth/connect/server/api/MirthServlet.java#L334-L342

pacmano1 commented 3 months ago

Interesting @ab-mg-23 , why all three then? Meaing I would expect the single IP.

ab-mg-23 commented 3 months ago

Client address and two pass through proxies.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For

jonbartels commented 3 months ago
/Users/jonathan.bartels/Projects/connect/server/dbconf
./oracle/oracle-database.sql:   IP_ADDRESS VARCHAR(40),
./derby/derby-database.sql: IP_ADDRESS VARCHAR(40),
./deltas/mysql-7-8.sql: IP_ADDRESS VARCHAR(40)) ENGINE=InnoDB
./deltas/postgres-7-8.sql:  IP_ADDRESS VARCHAR(40))
./deltas/derby-7-8.sql: IP_ADDRESS VARCHAR(40))
./deltas/sqlserver-7-8.sql: IP_ADDRESS VARCHAR(40))
./deltas/oracle-7-8.sql:    IP_ADDRESS VARCHAR(40))
./postgres/postgres-database.sql:   IP_ADDRESS VARCHAR(40),
./mysql/mysql-database.sql: IP_ADDRESS VARCHAR(40),

This would affect all DB engines and is not Oracle specific. Increasing the column the size to ~120 characters is a good workaround. 120 chars should have room for three IPv6 addresses and any separator characters.

I think the correct solution would be to properly parse the X-Forwarded-For header and store the first IP address in the comma separated list.