Skip to content

Commit

Permalink
fix(db): possible sql injection on /search endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
hbollon committed May 25, 2022
1 parent 608d9d5 commit 2a5dbaa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions db/db.go
Expand Up @@ -370,11 +370,13 @@ func (db *Database) SearchAttribute(query url.Values) (results []types.SearchRes
}

if v := query.Get("tf_version"); string(v) != "" {
where = append(where, fmt.Sprintf("states.tf_version LIKE '%s'", fmt.Sprintf("%%%s%%", v)))
where = append(where, "states.tf_version LIKE ?")
params = append(params, fmt.Sprintf("%%%s%%", v))
}

if v := query.Get("lineage_value"); string(v) != "" {
where = append(where, fmt.Sprintf("lineages.value LIKE '%s'", fmt.Sprintf("%%%s%%", v)))
where = append(where, "lineages.value LIKE ?")
params = append(params, fmt.Sprintf("%%%s%%", v))
}

if len(where) > 0 {
Expand Down

0 comments on commit 2a5dbaa

Please sign in to comment.