Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(notify): don't login to matrix to verify (could rate-limit fail) #198

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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