Skip to content

Commit

Permalink
change query type to constant type
Browse files Browse the repository at this point in the history
  • Loading branch information
0c34 committed Nov 6, 2017
1 parent c2a33d4 commit 2b1058a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 4 additions & 3 deletions vulnerability/idor/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package idor

import(
"log"
"fmt"
"html"
"regexp"
"database/sql"
Expand Down Expand Up @@ -35,7 +34,8 @@ func(p *Profile)GetData(uid string) error{

/* this funciton use to get data Profile from database with prepare statement */

getProfileSql := fmt.Sprintf(`SELECT p.user_id, p.full_name, p.city, p.phone_number
const (
getProfileSql = `SELECT p.user_id, p.full_name, p.city, p.phone_number
FROM Profile as p,Users as u
where p.user_id = u.id
and u.id=?`)
Expand All @@ -55,7 +55,8 @@ func(p *Profile)GetData(uid string) error{

func(p *Profile)UpdateProfile(name,city,phoneNumber, uid string)error{

sql := fmt.Sprintf(`UPDATE Profile
const (
sql = `UPDATE Profile
set full_name=?,
city=?,
phone_number=?
Expand Down
6 changes: 4 additions & 2 deletions vulnerability/sqli/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ func(p *Profile)SafeQueryGetData(uid string) error{

/* this funciton use to get data Profile from database with prepare statement */

getProfileSql := fmt.Sprintf(`SELECT p.user_id, p.full_name, p.city, p.phone_number
const (
getProfileSql =
`SELECT p.user_id, p.full_name, p.city, p.phone_number
FROM Profile as p,Users as u
where p.user_id = u.id
and u.id=?`)
and u.id=?`)

stmt, err := DB.Prepare(getProfileSql) //prepare statement
if err != nil{
Expand Down

0 comments on commit 2b1058a

Please sign in to comment.