ScanForSafety runs content-safety scanning on the given data. cmdPath is the raw cobra CommandPath(). When MODE=off, no provider registered, or the command is not allowlisted, returns a zero ScanResult.
(cmdPath string, data any, errOut io.Writer)
| 25 | // When MODE=off, no provider registered, or the command is not allowlisted, |
| 26 | // returns a zero ScanResult. |
| 27 | func ScanForSafety(cmdPath string, data any, errOut io.Writer) ScanResult { |
| 28 | alert, csErr := runContentSafety(cmdPath, data, errOut) |
| 29 | if errors.Is(csErr, errBlocked) { |
| 30 | return ScanResult{ |
| 31 | Alert: alert, |
| 32 | Blocked: true, |
| 33 | BlockErr: wrapBlockError(alert), |
| 34 | } |
| 35 | } |
| 36 | return ScanResult{Alert: alert} |
| 37 | } |
| 38 | |
| 39 | // wrapBlockError creates a typed error for content-safety block. |
| 40 | func wrapBlockError(alert *extcs.Alert) error { |