watchtower/wtdb: apply sanity checks to session policy before accepting

This commit is contained in:
Conner Fromknecht
2019-06-13 17:39:24 -07:00
parent 1979f9a7c0
commit 059887bd7b
3 changed files with 18 additions and 0 deletions

View File

@@ -81,6 +81,11 @@ func (db *TowerDB) InsertSessionInfo(info *wtdb.SessionInfo) error {
return wtdb.ErrSessionAlreadyExists
}
// Perform a quick sanity check on the session policy before accepting.
if err := info.Policy.Validate(); err != nil {
return err
}
db.sessions[info.ID] = info
return nil