Skip to content

Commit 53fc029

Browse files
committed
Make reject and soft reject have configurable action in rspamd module.
1 parent 813964d commit 53fc029

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

dist/vim/syntax/maddy-conf.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ syn keyword maddyModDir
183183
\ quarantine_threshold
184184
\ read_timeout
185185
\ reject_threshold
186+
\ reject_action
186187
\ relaxed_requiretls
187188
\ required_fields
188189
\ require_sender_match
@@ -198,6 +199,7 @@ syn keyword maddyModDir
198199
\ sig_expiry
199200
\ sign_fields
200201
\ sign_subdomains
202+
\ soft_reject_action
201203
\ softfail_action
202204
\ SOME_action
203205
\ source

docs/reference/checks/rspamd.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ check.rspamd {
1414
error_resp_action ignore
1515
add_header_action quarantine
1616
rewrite_subj_action quarantine
17+
reject_action reject
18+
soft_reject_action reject
1719
flags pass_all
1820
}
1921
@@ -90,6 +92,20 @@ X-Spam-Flag and X-Spam-Score are added to the header irregardless of value.
9092

9193
---
9294

95+
### reject_action _action_
96+
Default: `reject`
97+
98+
Action to take when rspamd requests to "reject".
99+
100+
---
101+
102+
### soft_reject_action _action_
103+
Default: `reject`
104+
105+
Action to take when rspamd requests to "soft reject".
106+
107+
---
108+
93109
### flags _string-list..._
94110
Default: `pass_all`
95111

internal/check/rspamd/rspamd.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ type Check struct {
5757
errorRespAction modconfig.FailAction
5858
addHdrAction modconfig.FailAction
5959
rewriteSubjAction modconfig.FailAction
60+
rejectAction modconfig.FailAction
61+
softRejectAction modconfig.FailAction
6062

6163
client *http.Client
6264
}
@@ -117,6 +119,15 @@ func (c *Check) Configure(inlineArgs []string, cfg *config.Map) error {
117119
func() (interface{}, error) {
118120
return modconfig.FailAction{Quarantine: true}, nil
119121
}, modconfig.FailActionDirective, &c.rewriteSubjAction)
122+
cfg.Custom("reject_action", false, false,
123+
func() (interface{}, error) {
124+
return modconfig.FailAction{Reject: true}, nil
125+
}, modconfig.FailActionDirective, &c.rejectAction)
126+
cfg.Custom("soft_reject_action", false, false,
127+
func() (interface{}, error) {
128+
return modconfig.FailAction{Reject: true}, nil
129+
}, modconfig.FailActionDirective, &c.softRejectAction)
130+
120131
cfg.StringList("flags", false, false, []string{"pass_all"}, &flags)
121132
if _, err := cfg.Process(); err != nil {
122133
return err
@@ -320,7 +331,7 @@ func (s *state) CheckBody(ctx context.Context, hdr textproto.Header, body buffer
320331
Header: hdrAdd,
321332
})
322333
case "soft reject":
323-
return module.CheckResult{
334+
return s.c.softRejectAction.Apply(module.CheckResult{
324335
Reject: true,
325336
Reason: &exterrors.SMTPError{
326337
Code: 450,
@@ -329,9 +340,9 @@ func (s *state) CheckBody(ctx context.Context, hdr textproto.Header, body buffer
329340
CheckName: modName,
330341
Misc: map[string]interface{}{"action": "soft reject"},
331342
},
332-
}
343+
})
333344
case "reject":
334-
return module.CheckResult{
345+
return s.c.rejectAction.Apply(module.CheckResult{
335346
Reject: true,
336347
Reason: &exterrors.SMTPError{
337348
Code: 550,
@@ -340,7 +351,7 @@ func (s *state) CheckBody(ctx context.Context, hdr textproto.Header, body buffer
340351
CheckName: modName,
341352
Misc: map[string]interface{}{"action": "reject"},
342353
},
343-
}
354+
})
344355
}
345356

346357
s.log.Msg("unhandled action", "action", respData.Action)

0 commit comments

Comments
 (0)