Skip to content

Allow unsafe raw SQL injection in PostgresQuery #258

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

Merged
merged 2 commits into from
Mar 16, 2022

Conversation

fabianfett
Copy link
Collaborator

@fabianfett fabianfett commented Mar 12, 2022

Motivation

Sometimes developers want to have the freedom to inject values into a PostgresQuery that are not bindable. Examples for this can be tableNames or columnNames.

Changes

  • Allow adopters to interpolate raw sql into the PostgresQuery

Result

More use-cases covered. Make unsafe code explicit unsafe.

Open question

What is the best unsafe marker word? Right now I have unsafeSQLInjection. I like this because it makes potential users google for SQL injection... This is rather long. Other previously discussed options are: raw, unsafeRaw.

@fabianfett fabianfett force-pushed the ff-allow-unsafe-raw-sql-injection branch from 284ce3b to c1e28eb Compare March 12, 2022 11:14
@codecov-commenter
Copy link

codecov-commenter commented Mar 12, 2022

Codecov Report

Merging #258 (13eec94) into main (57fda42) will increase coverage by 4.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #258      +/-   ##
==========================================
+ Coverage   39.78%   43.84%   +4.05%     
==========================================
  Files         115      115              
  Lines        9513     9523      +10     
==========================================
+ Hits         3785     4175     +390     
+ Misses       5728     5348     -380     
Flag Coverage Δ
unittests 43.84% <100.00%> (+4.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
Sources/PostgresNIO/New/PostgresQuery.swift 87.17% <100.00%> (+0.51%) ⬆️
...ces/PostgresNIO/New/PostgresRow-multi-decode.swift 4.44% <0.00%> (+0.19%) ⬆️
...es/PostgresNIO/Connection/PostgresConnection.swift 17.48% <0.00%> (+0.93%) ⬆️
Sources/PostgresNIO/Data/PostgresRow.swift 50.00% <0.00%> (+1.02%) ⬆️
...rces/PostgresNIO/New/Extensions/Logging+PSQL.swift 19.60% <0.00%> (+1.42%) ⬆️
...s/PostgresNIO/New/Data/Array+PostgresCodable.swift 93.25% <0.00%> (+2.24%) ⬆️
...ostgresNIO/Deprecated/PostgresMessageDecoder.swift 95.45% <0.00%> (+2.27%) ⬆️
...ostgresNIO/New/PostgresBackendMessageDecoder.swift 93.28% <0.00%> (+2.98%) ⬆️
...urces/PostgresNIO/New/Messages/ErrorResponse.swift 32.30% <0.00%> (+3.07%) ⬆️
Sources/PostgresNIO/New/PostgresCell.swift 96.77% <0.00%> (+3.22%) ⬆️
... and 21 more

@fabianfett fabianfett requested review from 0xTim and gwynne March 12, 2022 11:16
@fabianfett fabianfett force-pushed the ff-allow-unsafe-raw-sql-injection branch from c1e28eb to 912b9ae Compare March 15, 2022 21:12
@fabianfett fabianfett force-pushed the ff-allow-unsafe-raw-sql-injection branch from 912b9ae to 13eec94 Compare March 15, 2022 22:57
Copy link
Member

@0xTim 0xTim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fabianfett fabianfett merged commit f11cc9b into vapor:main Mar 16, 2022
@fabianfett fabianfett deleted the ff-allow-unsafe-raw-sql-injection branch March 16, 2022 06:43
@fabianfett fabianfett added this to the 1.9.0 milestone Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants