2023-12-07 11:21:04 +00:00
|
|
|
package appsec
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/crowdsecurity/crowdsec/pkg/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GetOnLoadEnv(w *AppsecRuntimeConfig) map[string]interface{} {
|
|
|
|
return map[string]interface{}{
|
|
|
|
"RemoveInBandRuleByID": w.DisableInBandRuleByID,
|
|
|
|
"RemoveInBandRuleByTag": w.DisableInBandRuleByTag,
|
|
|
|
"RemoveInBandRuleByName": w.DisableInBandRuleByName,
|
|
|
|
"RemoveOutBandRuleByID": w.DisableOutBandRuleByID,
|
|
|
|
"RemoveOutBandRuleByTag": w.DisableOutBandRuleByTag,
|
|
|
|
"RemoveOutBandRuleByName": w.DisableOutBandRuleByName,
|
|
|
|
"SetRemediationByTag": w.SetActionByTag,
|
|
|
|
"SetRemediationByID": w.SetActionByID,
|
|
|
|
"SetRemediationByName": w.SetActionByName,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetPreEvalEnv(w *AppsecRuntimeConfig, request *ParsedRequest) map[string]interface{} {
|
|
|
|
return map[string]interface{}{
|
|
|
|
"IsInBand": request.IsInBand,
|
|
|
|
"IsOutBand": request.IsOutBand,
|
2024-01-16 09:33:44 +00:00
|
|
|
"req": request.HTTPRequest,
|
2023-12-07 11:21:04 +00:00
|
|
|
"RemoveInBandRuleByID": w.RemoveInbandRuleByID,
|
|
|
|
"RemoveInBandRuleByName": w.RemoveInbandRuleByName,
|
|
|
|
"RemoveInBandRuleByTag": w.RemoveInbandRuleByTag,
|
|
|
|
"RemoveOutBandRuleByID": w.RemoveOutbandRuleByID,
|
|
|
|
"RemoveOutBandRuleByTag": w.RemoveOutbandRuleByTag,
|
|
|
|
"RemoveOutBandRuleByName": w.RemoveOutbandRuleByName,
|
|
|
|
"SetRemediationByTag": w.SetActionByTag,
|
|
|
|
"SetRemediationByID": w.SetActionByID,
|
|
|
|
"SetRemediationByName": w.SetActionByName,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetPostEvalEnv(w *AppsecRuntimeConfig, request *ParsedRequest) map[string]interface{} {
|
|
|
|
return map[string]interface{}{
|
|
|
|
"IsInBand": request.IsInBand,
|
|
|
|
"IsOutBand": request.IsOutBand,
|
|
|
|
"DumpRequest": request.DumpRequest,
|
2024-01-16 09:33:44 +00:00
|
|
|
"req": request.HTTPRequest,
|
2023-12-07 11:21:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetOnMatchEnv(w *AppsecRuntimeConfig, request *ParsedRequest, evt types.Event) map[string]interface{} {
|
|
|
|
return map[string]interface{}{
|
|
|
|
"evt": evt,
|
2024-01-16 09:33:44 +00:00
|
|
|
"req": request.HTTPRequest,
|
2023-12-07 11:21:04 +00:00
|
|
|
"IsInBand": request.IsInBand,
|
|
|
|
"IsOutBand": request.IsOutBand,
|
|
|
|
"SetRemediation": w.SetAction,
|
|
|
|
"SetReturnCode": w.SetHTTPCode,
|
|
|
|
"CancelEvent": w.CancelEvent,
|
|
|
|
"SendEvent": w.SendEvent,
|
|
|
|
"CancelAlert": w.CancelAlert,
|
|
|
|
"SendAlert": w.SendAlert,
|
|
|
|
"DumpRequest": request.DumpRequest,
|
|
|
|
}
|
|
|
|
}
|