Skip to content
This repository was archived by the owner on Feb 27, 2026. It is now read-only.

Add documentation for rule G201#12

Merged
gcmurphy merged 2 commits intosecurego:masterfrom
MVrachev:g201
Feb 19, 2019
Merged

Add documentation for rule G201#12
gcmurphy merged 2 commits intosecurego:masterfrom
MVrachev:g201

Conversation

@MVrachev
Copy link
Copy Markdown
Collaborator

Introduction + incorrect example + correct example + reference links.

Signed-off-by: Martin Vrachev mvrachev@vmware.com

Copy link
Copy Markdown
Member

@gcmurphy gcmurphy left a comment

Choose a reason for hiding this comment

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

Found a couple of typos and grammar type problems that you should fix. The other suggestion I have is a static query in not the only safe thing we can recommend people use. If you use the DB interface correctly you can avoid most SQL injection vectors.

title: G201: SQL query construction using format stringg
---

SQL injection is one of the top security issues develops made and the consequences of this can be enormous.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would change 'develops made' to 'developers make', and maybe 'enormous' to 'severe'.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree and I will change it.

@@ -0,0 +1,67 @@
---
id: g201
title: G201: SQL query construction using format stringg
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

'stringg' should be 'string'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yep, sorry.

## The right way

Using a static SQL query is always preferred.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It can also be safe to use a prepared SQL query, or using parametrised queries like db.Query("SELECT * FROM foo WHERE name = ?", name) in addition to static queries.

Martin Vrachev added 2 commits February 18, 2019 10:51
Introduction + incorrect example + correct example + reference links.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
I fixed a few typos and added a paragraph about the use of database/sql package.

Signed-off-by: Martin Vrachev <mvrachev@vmware.com>
Copy link
Copy Markdown
Member

@gcmurphy gcmurphy left a comment

Choose a reason for hiding this comment

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

Fantastic!

@gcmurphy gcmurphy merged commit 16f1c78 into securego:master Feb 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants