V
V
v- death2015-10-23 14:08:15
MySQL
v- death, 2015-10-23 14:08:15

How to safely work with sql?

Hello. I did not find anything on the Internet about protection against sql injections in golang. Now there is a code

rows, err := DB.Query("SELECT * FROM dev_method WHERE name=?", ps.ByName("methods"))
  if err != nil {
    status.Code503(w, r)
  }
  defer rows.Close()
  bks := make([]*dev_method, 0)
  for rows.Next() {
    bk := new(dev_method)
    err := rows.Scan(&bk.id, &bk.id_menu, &bk.name, &bk.description)
    if err != nil {
      status.Code503(w, r)
    }
    bks = append(bks, bk)
  }
  if err = rows.Err(); err != nil {
    status.Code503(w, r)
  }

what vulnerabilities does it have and if so, how to fix them?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pavlyuk, 2015-10-23
@vGrabko99

The request here is quite normally formed, using placeholders. There can be no SQL injection, because "?" is replaced by the value via escaping.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question