Skip to content
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

G201/G202 only works with the stdlib sql pkg #1237

Closed
adrianlungu opened this issue Oct 1, 2024 · 3 comments
Closed

G201/G202 only works with the stdlib sql pkg #1237

adrianlungu opened this issue Oct 1, 2024 · 3 comments

Comments

@adrianlungu
Copy link

Summary

It seems, at least the latest version of, gosec only works with the standard sql package ?

Steps to reproduce the behavior

By changing the code from the documentation to

import (
	"database/sql"

	"github.com/jmoiron/sqlx"
)

var staticQuery = "SELECT * FROM foo WHERE age < "

func main() {
	db, err := sql.Open("sqlite3", ":memory:")
	if err != nil {
		panic(err)
	}

	xdb := sqlx.NewDb(db, "sqlite3")

	var gender string = "M"
	rows, err := xdb.Query("SELECT * FROM foo WHERE gender = " + gender)
	if err != nil {
		panic(err)
	}
	defer rows.Close()
}

the summary returns

Summary:
  Gosec  : 2.21.4
  Nosec  : 0
  Issues : 0

While when running the Query against the db, it returns

Summary:
  Gosec  : 2.21.4
  Nosec  : 0
  Issues : 1

gosec version

2.21.4

Go version (output of 'go version')

go version go1.23.1 darwin/arm64

Operating system / Environment

MacOS 14.6.1

Expected behavior

Gosec to find sql query issues when using libraries like sqlx or pgx for interacting with various dbs.

Actual behavior

Gosec reporting no issues when using libraries outside of the std lib sql pkg.

@ccojocar
Copy link
Member

ccojocar commented Oct 1, 2024

Thanks for this issue but we aren't planning to support third party libraries.

@ccojocar ccojocar closed this as completed Oct 1, 2024
@adrianlungu
Copy link
Author

adrianlungu commented Oct 1, 2024

@ccojocar is there openness to PRs being made to add support for third party libraries or is it a hard no ?

Thanks!

@ccojocar
Copy link
Member

ccojocar commented Oct 2, 2024

Adding third party library requires maintenance which we would like to avoid for now. Thanks

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

No branches or pull requests

2 participants