DapperLib / DapperLib/DapperAOT

Analyzer: interpolated string usage

Open
#143 0 comments 0 reactions 1 assignee View on GitHub

@DeagleGross is already working on this.

Since Dec 14, 2024.

analyzer
Dominant language
C#
Stars
472
Forks
43
Avg merge
1d 4h
Merged PRs (30d)
18

Description

we should detect usage like:

conn.Execute($"update foo set balance={value} where id={id}");

and issue a warning, but: this should only apply when the receiving parameter is a string. I have a plan for future magic voodoo here! There is a future version of Dapper where something very similar, i.e.

conn.Execute($"update foo set balance=@{value} where id=@{id}");

actually works and does the correct thing. I have a working prototype. Must handle all types of interpolated string literal ($", $""", possible $"" etc)

Warning something like:

Interpolated strings should not be used as an alternative to parameterization, and can represent a significant security risk (SQL injection)

If we add the proposed Dapper feature, we can reword this and point them to the new usage.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.