fix Remove{in,out}bandRuleBy{name,tag} for pre_eval
This commit is contained in:
parent
cb030beaca
commit
b01901b04e
|
@ -27,6 +27,11 @@ func (t *ExtendedTransaction) RemoveRuleByIDWithError(id int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *ExtendedTransaction) RemoveRuleByTagWithError(tag string) error {
|
||||||
|
t.Tx.RemoveRuleByTag(tag)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (t *ExtendedTransaction) IsRuleEngineOff() bool {
|
func (t *ExtendedTransaction) IsRuleEngineOff() bool {
|
||||||
return t.Tx.IsRuleEngineOff()
|
return t.Tx.IsRuleEngineOff()
|
||||||
}
|
}
|
||||||
|
|
|
@ -425,6 +425,38 @@ func (w *WaapRuntimeConfig) RemoveOutbandRuleByID(params ...any) (any, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// func (w *WaapRuntimeConfig) RemoveInbandRuleByTag(tag string) error {
|
||||||
|
func (w *WaapRuntimeConfig) RemoveInbandRuleByTag(params ...any) (any, error) {
|
||||||
|
tag := params[0].(string)
|
||||||
|
w.Logger.Debugf("removing inband rule with tag %s", tag)
|
||||||
|
_ = w.InBandTx.RemoveRuleByTagWithError(tag)
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// func (w *WaapRuntimeConfig) RemoveOutbandRuleByTag(tag string) error {
|
||||||
|
func (w *WaapRuntimeConfig) RemoveOutbandRuleByTag(params ...any) (any, error) {
|
||||||
|
tag := params[0].(string)
|
||||||
|
w.Logger.Debugf("removing outband rule with tag %s", tag)
|
||||||
|
_ = w.OutOfBandTx.RemoveRuleByTagWithError(tag)
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// func (w *WaapRuntimeConfig) RemoveInbandRuleByName(name string) error {
|
||||||
|
func (w *WaapRuntimeConfig) RemoveInbandRuleByName(params ...any) (any, error) {
|
||||||
|
tag := fmt.Sprintf("crowdsec-%s", params[0].(string))
|
||||||
|
w.Logger.Debugf("removing inband rule %s", tag)
|
||||||
|
_ = w.InBandTx.RemoveRuleByTagWithError(tag)
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// func (w *WaapRuntimeConfig) RemoveOutbandRuleByName(name string) error {
|
||||||
|
func (w *WaapRuntimeConfig) RemoveOutbandRuleByName(params ...any) (any, error) {
|
||||||
|
tag := fmt.Sprintf("crowdsec-%s", params[0].(string))
|
||||||
|
w.Logger.Debugf("removing outband rule %s", tag)
|
||||||
|
_ = w.OutOfBandTx.RemoveRuleByTagWithError(tag)
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (w *WaapRuntimeConfig) CancelEvent(params ...any) (any, error) {
|
func (w *WaapRuntimeConfig) CancelEvent(params ...any) (any, error) {
|
||||||
w.Logger.Debugf("canceling event")
|
w.Logger.Debugf("canceling event")
|
||||||
w.Response.SendEvent = false
|
w.Response.SendEvent = false
|
||||||
|
|
|
@ -23,9 +23,9 @@ func GetOnLoadEnv(w *WaapRuntimeConfig) map[string]interface{} {
|
||||||
//FIXME: use expr.Function instead of this
|
//FIXME: use expr.Function instead of this
|
||||||
return map[string]interface{}{
|
return map[string]interface{}{
|
||||||
"RemoveInBandRuleByID": w.DisableInBandRuleByID,
|
"RemoveInBandRuleByID": w.DisableInBandRuleByID,
|
||||||
"RemoveOutBandRuleByID": w.DisableOutBandRuleByID,
|
|
||||||
"RemoveInBandRuleByName": w.DisableInBandRuleByName,
|
|
||||||
"RemoveInBandRuleByTag": w.DisableInBandRuleByTag,
|
"RemoveInBandRuleByTag": w.DisableInBandRuleByTag,
|
||||||
|
"RemoveInBandRuleByName": w.DisableInBandRuleByName,
|
||||||
|
"RemoveOutBandRuleByID": w.DisableOutBandRuleByID,
|
||||||
"RemoveOutBandRuleByTag": w.DisableOutBandRuleByTag,
|
"RemoveOutBandRuleByTag": w.DisableOutBandRuleByTag,
|
||||||
"RemoveOutBandRuleByName": w.DisableOutBandRuleByName,
|
"RemoveOutBandRuleByName": w.DisableOutBandRuleByName,
|
||||||
"SetRemediationByTag": w.SetActionByTag,
|
"SetRemediationByTag": w.SetActionByTag,
|
||||||
|
@ -40,7 +40,11 @@ func GetPreEvalEnv(w *WaapRuntimeConfig, request *ParsedRequest) map[string]inte
|
||||||
"IsInBand": request.IsInBand,
|
"IsInBand": request.IsInBand,
|
||||||
"IsOutBand": request.IsOutBand,
|
"IsOutBand": request.IsOutBand,
|
||||||
"RemoveInBandRuleByID": w.RemoveInbandRuleByID,
|
"RemoveInBandRuleByID": w.RemoveInbandRuleByID,
|
||||||
|
"RemoveInBandRuleByName": w.RemoveInbandRuleByName,
|
||||||
|
"RemoveInBandRuleByTag": w.RemoveInbandRuleByTag,
|
||||||
"RemoveOutBandRuleByID": w.RemoveOutbandRuleByID,
|
"RemoveOutBandRuleByID": w.RemoveOutbandRuleByID,
|
||||||
|
"RemoveOutBandRuleByTag": w.RemoveOutbandRuleByTag,
|
||||||
|
"RemoveOutBandRuleByName": w.RemoveOutbandRuleByName,
|
||||||
"SetRemediationByTag": w.SetActionByTag,
|
"SetRemediationByTag": w.SetActionByTag,
|
||||||
"SetRemediationByID": w.SetActionByID,
|
"SetRemediationByID": w.SetActionByID,
|
||||||
"SetRemediationByName": w.SetActionByName,
|
"SetRemediationByName": w.SetActionByName,
|
||||||
|
|
Loading…
Reference in a new issue