-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cluster-ui: add safesql
to cluster-ui
#96286
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, @THardy98! Just wanted to double-check: IIUC, this library does (and should) stop short of interpolating arguments to queries, yes? It's strictly for things like user, database, table, and column names? And everything else we'd pass along for the db driver to interpolate -- I think drawing that line limits our security exposure.
Reviewable status: complete! 0 of 0 LGTMs obtained
61efb06
to
f27c91a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe so yes. The most common use case I've seen being adding identifiers directly to query strings:
safesql.Format(`SELECT * FROM %1.this_is_a_table_name`, safesql.Identifier(`this is my db name`))
Reviewable status: complete! 0 of 0 LGTMs obtained
f27c91a
to
7ad2606
Compare
Epic: none This change ports the `safesql` package from managed-service to cluster-ui. Safesql ensures that SQL literals/identifiers are properly quoted. Release note: None
7ad2606
to
1403411
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @matthewtodd and @THardy98)
pkg/ui/workspaces/cluster-ui/src/api/safesql.ts
line 22 at r2 (raw file):
} // TODO(thomas): @knz says: the quoting rules for usernames are different from
are you addressing this on this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @maryliag and @matthewtodd)
pkg/ui/workspaces/cluster-ui/src/api/safesql.ts
line 22 at r2 (raw file):
Previously, maryliag (Marylia Gutierrez) wrote…
are you addressing this on this PR?
TLDR: no
This was actually an old TODO
left by Peter a couple years ago (late 2020) on the corresponding safesql.go
in managed-service. I decided to keep it and tag myself here as I've added this. Alternatively, I could omit the TODO
altogether.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @matthewtodd and @THardy98)
pkg/ui/workspaces/cluster-ui/src/api/safesql.ts
line 22 at r2 (raw file):
Previously, THardy98 (Thomas Hardy) wrote…
TLDR: no
This was actually an old
TODO
left by Peter a couple years ago (late 2020) on the correspondingsafesql.go
in managed-service. I decided to keep it and tag myself here as I've added this. Alternatively, I could omit theTODO
altogether.
You can keep it, np!
TYFR :) |
bors r+ |
Build succeeded: |
Epic: none
This change ports the
safesql
package from managed-service to cluster-ui. Safesql ensures that SQL literals/identifiers are properly quoted.Release note: None