cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Avoiding cypher injects when using parameter maps

I have a use case where I'm generating a dynamic query before eventually calling session.query(...) with it. I'm providing a parameter map to the function that has input that comes from the user. I figured this input would get automatically sanitized but it does not and I can't find anything in documentation that talks about sanitizing inputs for the parameter map.

I'm aware that there's a JDBC PreparedStatement class that will do such a thing...but that seems like a pretty weird solution. Does OGM provide a way to sanitize parameter maps passed to Neo4jSession.query?

1 REPLY 1

Jiropole
Graph Voyager

I'd suggest using your Spring Hibernate/Jackson implementation along with model views (DTOs) to perform the necessary validation. If you then want to get it into map form to pass to cypher, the way I've done this is to define a map method on each DTO to get the map form of the sanitized data.

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online