Skip to content

Commit

Permalink
testing sql injection
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrockx committed Aug 23, 2022
1 parent 8d7266d commit 2f082ad
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ func AllBooks() ([]Book, error) {
// the query, you should be using a parameterized query.
func NameQuery(r string) ([]Book, error) {
// Fix: rows, err := DB.Query("SELECT * FROM books WHERE name = ?", r)
rows, err := DB.Query(fmt.Sprintf("SELECT * FROM books WHERE name = '%s'", r))
query := fmt.Sprintf("SELECT * FROM books WHERE name = '%s'", r)
rows, err := DB.Query(query)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 2f082ad

Please sign in to comment.