Skip to content

Commit

Permalink
fix(notify): don't login to matrix to verify (could run into a rate-l…
Browse files Browse the repository at this point in the history
…imit) (#198)
  • Loading branch information
JosephKav authored Jan 13, 2023
1 parent 81a2a72 commit a15437d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 8 additions & 5 deletions notifiers/shoutrrr/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ func (s *Shoutrrr) CheckValues(prefix string) (errs error) {
if s.Main != nil {
s.checkValuesMaster(prefix, &errs, &errsOptions, &errsURLFields, &errsParams)

//#nosec G104 -- Disregard as we're not giving any rawURLs
sender, _ := shoutrrr_lib.CreateSender()
if _, err := sender.Locate(s.GetURL()); err != nil {
errsLocate = fmt.Errorf("%s%s^ %w\\",
util.ErrorToString(errsLocate), prefix, err)
// Exclude matrix since it logs in, so may run into a rate-limit
if s.GetType() != "matrix" {
//#nosec G104 -- Disregard as we're not giving any rawURLs
sender, _ := shoutrrr_lib.CreateSender()
if _, err := sender.Locate(s.GetURL()); err != nil {
errsLocate = fmt.Errorf("%s%s^ %w\\",
util.ErrorToString(errsLocate), prefix, err)
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions notifiers/shoutrrr/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ func TestShoutrrrCheckValues(t *testing.T) {
main: &Shoutrrr{}, sType: "gotify"},
"does field check service shoutrrrs - invalid params + locate fail": {errRegex: "fromaddress: <required>.*toaddresses: <required>", serviceShoutrrr: true,
urlFields: map[string]string{"host": "https://release-argus.io"}, main: &Shoutrrr{}, sType: "smtp"},
"valid matrix - skip Locate": {errRegex: "^$", serviceShoutrrr: true,
main: &Shoutrrr{URLFields: map[string]string{"host": "matrix.example.io", "password": "access_token"}}, sType: "matrix"},
}

for name, tc := range tests {
Expand Down

0 comments on commit a15437d

Please sign in to comment.