Skip to content
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
2 changes: 2 additions & 0 deletions dist/vim/syntax/maddy-conf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ syn keyword maddyModDir
\ quarantine_threshold
\ read_timeout
\ reject_threshold
\ reject_action
\ relaxed_requiretls
\ required_fields
\ require_sender_match
Expand All @@ -198,6 +199,7 @@ syn keyword maddyModDir
\ sig_expiry
\ sign_fields
\ sign_subdomains
\ soft_reject_action
\ softfail_action
\ SOME_action
\ source
Expand Down
16 changes: 16 additions & 0 deletions docs/reference/checks/rspamd.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ check.rspamd {
error_resp_action ignore
add_header_action quarantine
rewrite_subj_action quarantine
reject_action reject
soft_reject_action reject
flags pass_all
}

Expand Down Expand Up @@ -90,6 +92,20 @@ X-Spam-Flag and X-Spam-Score are added to the header irregardless of value.

---

### reject_action _action_
Default: `reject`

Action to take when rspamd requests to "reject".

---

### soft_reject_action _action_
Default: `reject`

Action to take when rspamd requests to "soft reject".

---

### flags _string-list..._
Default: `pass_all`

Expand Down
19 changes: 15 additions & 4 deletions internal/check/rspamd/rspamd.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type Check struct {
errorRespAction modconfig.FailAction
addHdrAction modconfig.FailAction
rewriteSubjAction modconfig.FailAction
rejectAction modconfig.FailAction
softRejectAction modconfig.FailAction

client *http.Client
}
Expand Down Expand Up @@ -117,6 +119,15 @@ func (c *Check) Configure(inlineArgs []string, cfg *config.Map) error {
func() (interface{}, error) {
return modconfig.FailAction{Quarantine: true}, nil
}, modconfig.FailActionDirective, &c.rewriteSubjAction)
cfg.Custom("reject_action", false, false,
func() (interface{}, error) {
return modconfig.FailAction{Reject: true}, nil
}, modconfig.FailActionDirective, &c.rejectAction)
cfg.Custom("soft_reject_action", false, false,
func() (interface{}, error) {
return modconfig.FailAction{Reject: true}, nil
}, modconfig.FailActionDirective, &c.softRejectAction)

cfg.StringList("flags", false, false, []string{"pass_all"}, &flags)
if _, err := cfg.Process(); err != nil {
return err
Expand Down Expand Up @@ -320,7 +331,7 @@ func (s *state) CheckBody(ctx context.Context, hdr textproto.Header, body buffer
Header: hdrAdd,
})
case "soft reject":
return module.CheckResult{
return s.c.softRejectAction.Apply(module.CheckResult{
Reject: true,
Reason: &exterrors.SMTPError{
Code: 450,
Expand All @@ -329,9 +340,9 @@ func (s *state) CheckBody(ctx context.Context, hdr textproto.Header, body buffer
CheckName: modName,
Misc: map[string]interface{}{"action": "soft reject"},
},
}
})
case "reject":
return module.CheckResult{
return s.c.rejectAction.Apply(module.CheckResult{
Reject: true,
Reason: &exterrors.SMTPError{
Code: 550,
Expand All @@ -340,7 +351,7 @@ func (s *state) CheckBody(ctx context.Context, hdr textproto.Header, body buffer
CheckName: modName,
Misc: map[string]interface{}{"action": "reject"},
},
}
})
}

s.log.Msg("unhandled action", "action", respData.Action)
Expand Down
Loading