Skip to content

Commit c40c661

Browse files
authored
Merge pull request #583 from sipcapture/alert-autofix-2
Fix code scanning alert no. 2: Database query built from user-controlled sources
2 parents 607fbd1 + 15323e8 commit c40c661

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

data/service/agentSub.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,8 @@ func (hs *AgentsubService) GetAgentsubAgainstGUIDAndType(guid string, typeReques
104104
var AgentsubObject model.TableAgentLocationSession
105105
var count int
106106

107-
whereSQL := fmt.Sprintf("expire_date > NOW() AND guid = '%s' AND type LIKE '%%%s%%'", guid, typeRequest)
108-
109107
if err := hs.Session.Debug().Table("agent_location_session").
110-
Where(whereSQL).
108+
Where("expire_date > NOW() AND guid = ? AND type LIKE ?", guid, "%"+typeRequest+"%").
111109
Find(&AgentsubObject).Count(&count).Error; err != nil {
112110
return AgentsubObject, err
113111
}

0 commit comments

Comments
 (0)