mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-02-11 15:45:06 -05:00
This pull request introduces a new tool for executing arbitrary Cypher queries against a Neo4j database (`neo4j-execute-cypher`) and implements robust query classification functionality to distinguish between read and write operations. The changes include updates to documentation, the addition of a query classifier, and comprehensive test coverage for the classifier. ### Addition of `neo4j-execute-cypher` tool: - **Documentation**: Added a new markdown file `neo4j-execute-cypher.md` that explains the tool's functionality, usage, and configuration options, including the ability to enforce read-only mode for security. - **Import statement**: Registered the new tool in the `cmd/root.go` file to make it available in the toolbox. ### Query classification functionality: - **Query classifier implementation**: Added `QueryClassifier` in `classifier.go`, which classifies Cypher queries into read or write operations based on keywords, procedures, and subquery analysis. It supports handling edge cases like nested subqueries, multi-word keywords, and invalid syntax. - **Test coverage**: Created extensive tests in `classifier_test.go` to validate the classifier's behavior across various query types, including abuse cases, subqueries, and procedure calls. Tests ensure the classifier is robust and does not panic on malformed queries. --------- Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>