You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: rename explainQuery to unsafeExplainQuery (#225)
Related discussion #223
We already improved it in #224, this
PR makes it more secure by
1. Renaming `explainQuery` to `unsafeExplainQuery` while the single
query check and transaction wrapping is pretty secure already, there
might be edge cases where a query escapes the designated boundaries.
Therefore, we rename the tool to `unsafeExplainQuery`
2. Create a new tool called `safeExplainQuery`, this operates on
`queryId` and fetches the actual SQL from `pg_stat_statements` table
itself thereby eliminating the code path that can lead to any SQL
injection. This is done in the following stacked PR
#226
3. Use the new `safeExplainQuery` tool instead of `unsafeExplainQuery`,
to make it work, we had to additionally return `queryId` from
`getSlowQueries` tool in addition to the slow SQL query. This is done in
the following stacked PR #227
Copy file name to clipboardExpand all lines: apps/dbagent/src/lib/ai/prompts.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ If the user asks for something that is not related to PostgreSQL or database adm
11
11
exportconstchatSystemPrompt=`
12
12
Provide clear, concise, and accurate responses to questions.
13
13
Use the provided tools to get context from the PostgreSQL database to answer questions.
14
-
When asked why a query is slow, call the explainQuery tool and also take into account the table sizes.
14
+
When asked why a query is slow, call the safeExplainQuery tool and also take into account the table sizes.
15
15
During the initial assessment use the getTablesInfo, getPerfromanceAndVacuumSettings, getConnectionsStats, and getPostgresExtensions, and others if you want.
16
16
When asked to run a playbook, use the getPlaybook tool to get the playbook contents. Then use the contents of the playbook
0 commit comments