Commit Graph

16 Commits (63422c7d6cfe092af402f48e16729acd1e3bae1c)

Author SHA1 Message Date
merlin 90a77b13b2
add docs to sanitize tests 2024-12-28 13:31:08 +02:00
merlin 59d6aa87b9
rework QuoteString and QuoteBytes as append-style 2024-12-28 13:31:08 +02:00
merlin ea1e13a660
quoteString 2024-12-28 13:31:08 +02:00
merlin 58d4c0c94f
quoteBytes
check new quoteBytes
2024-12-28 13:31:08 +02:00
Jack Christensen 49b6aad319 Use spaces instead of parentheses for SQL sanitization
This still solves the problem of negative numbers creating a line
comment, but this avoids breaking edge cases such as `set foo to $1`
where the substition is taking place in a location where an arbitrary
expression is not allowed.

https://github.com/jackc/pgx/issues/1928
2024-03-09 12:09:42 -06:00
Jack Christensen c543134753 SQL sanitizer wraps arguments in parentheses
pgx v5 was not vulnerable to CVE-2024-27289 do to how the sanitizer was
being called. But the sanitizer itself still had the underlying issue.
This commit ports the fix from pgx v4 to v5 to ensure that the issue
does not emerge if pgx uses the sanitizer differently in the future.
2024-03-04 09:09:42 -06:00
Jack Christensen ba4bbf92af Fix query sanitizer
...when query text has contains Unicode replacement character.
uft8.RuneError actually is a valid character.
2022-11-14 18:32:26 -06:00
Jack Christensen 1f4b34f932 Merge branch 'master' into v5-dev 2022-04-23 11:05:24 -05:00
Jack Christensen f14fb3d692 Replace interface{} with any 2022-04-09 09:12:55 -05:00
Andrew Rusakow a86ece025c Fix single line comment for line endings in mac when sanitizing. 2022-03-04 18:17:40 -06:00
Jack Christensen 72cc95e4dd Bump module version to v5 2021-12-11 13:29:03 -06:00
Rusakow Andrew 292539a590 Add comment support when sanitizing SQL queries 2021-03-13 07:31:56 -06:00
Andrew Nicoll 816e95d3ee sanatize time to within microsecond accuracy 2020-03-27 13:03:36 +00:00
Jack Christensen 29f02807b0 Restore simple protocol support 2019-05-20 20:36:03 -05:00
Jack Christensen c53c9e6eb5 Remove simple protocol and one round trip query options
It is impossible to guarantee that the a query executed with the simple
protocol will behave the same as with the extended protocol. This is
because the normal pgx path relies on knowing the OID of query
parameters. Without this encoding a value can only be determined by the
value instead of the combination of value and PostgreSQL type. For
example, how should a []int32 be encoded? It might be encoded into a
PostgreSQL int4[] or json.

Removal also simplifies the core query path.

The primary reason for the simple protocol is for servers like PgBouncer
that may not be able to support normal prepared statements. After
further research it appears that issuing a "flush" instead "sync" after
preparing the unnamed statement would allow PgBouncer to work.

The one round trip mode can be better handled with prepared statements.

As a last resort, all original server functionality can still be accessed by
dropping down to PgConn.
2019-04-13 11:39:01 -05:00
Jack Christensen 7b1f461ec3 Add simple protocol suuport with (Query|Exec)Ex 2017-04-10 08:58:51 -05:00