Implement the TODO on RestrictedEntityManager & block transaction related calls on JDBC session.

Description

In particular, block the `getTransaction` method. Look at what other methods could be destructive.

Activity

Show:
Rick Parker
February 13, 2020, 4:15 PM

We should also fix methods on the raw connection returned by ServiceHub.jdbcSession.

Rick Parker
February 13, 2020, 4:30 PM
Edited

I was also just reading up on JDBC savepoints. They seem to be supported by MS SQL Server, Oracle and Postgres and also H2 (apparently). I think we might actually be able to use savepoints to be slightly richer than just banning rollbacks. Need to think how that might interact with Hibernate. Of course, this might all just be a bad idea and we should perhaps start by outright banning, but my brain is wondering what we might be able to use savepoints for. Seems like they should be useful.

ryan.fowler
March 24, 2020, 9:17 AM

Looking at the EntityManager docs does locking out the following make sense?

  • detach

  • getLockMode

  • getMetamodel

  • getProperties

  • getTransaction

  • joinTransaction

  • lock

  • setProperty

I’m not terribly sure but all of those seem like extra rope…

As for the jdbcSession which is a Connection object:

  • abort

  • clearWarnings

  • close (only for us)

  • commit

  • getMetaData

  • set/releaseSavepoint (until we know how we want to use it)

  • rollback

  • set[*]

 

Rick Parker
March 30, 2020, 1:00 PM

For EntityManager that list sounds okay, but we should retain detach access.

For jdbcSession that also sounds reasonable.

The ones that I am less clear on are getLockMode, getMetamodel and getProperties (plus getMetaData on the connection). Do the objects returned by those allow attempts to mutate things?

 

nikolett.nagy
March 31, 2020, 12:48 PM

I checked those methods.

LockModeType getLockMode(Object entity): Returns an enum, so I think we can leave it as it is.

Metamodel getMetamodel(): You can access Sets there and possibly add new elements to them. I would block it.

Map<String, Object> getProperties() : Regarding this method the documentation says: ‘Changing the contents of the map does not change the configuration in effect.’ I would leave this one as well as it is for now.

DatabaseMetaData getMetaData(): Comprehensive information about the database as a whole. I don’t think you can mutate things in it.

Assignee

nikolett.nagy

Reporter

Rick Parker

Sprint

None

Epic Link

None

Priority

High

Severity

High

CVSS Score

None

CVSS Vector

None

Due Date

None

Engineering Teams

Kernel

Fix versions

Affects versions

None

Ported to...

Corda 4.5
Corda Enterprise 4.5

Story Points / Dev Days

5
Configure