-
Notifications
You must be signed in to change notification settings - Fork 482
fix: propagate max-ai-credits to external detector AWF config
#50721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -158,6 +158,9 @@ func buildExternalDetectorWorkflowData(data *WorkflowData, engineID string) *Wor | |
| if d.EngineConfig.APITarget == "" && data.EngineConfig != nil { | ||
| d.EngineConfig.APITarget = data.EngineConfig.APITarget | ||
| } | ||
| if data.SafeOutputs != nil && data.SafeOutputs.ThreatDetection != nil && data.SafeOutputs.ThreatDetection.MaxAICredits != 0 { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: this relies on an implicit, unenforced invariant that 💡 Details
But the sibling inline path ( Suggested hardening, mirroring the inline path's defensiveness: if data.SafeOutputs != nil && data.SafeOutputs.ThreatDetection != nil {
d.EngineConfig.MaxAICredits = data.SafeOutputs.ThreatDetection.MaxAICredits // always resets to 0 when unset
}This removes the dependency on the current parsing behavior never populating that nested field, and a corresponding test (nonzero Not currently exploitable — no path today sets that nested field nonzero — so this is a defense-in-depth suggestion, not a blocker. |
||
| d.EngineConfig.MaxAICredits = data.SafeOutputs.ThreatDetection.MaxAICredits | ||
| } | ||
| return d | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[/tdd] Missing interaction test: when
canReuseThreatDetectionEngineConfigForExternalDetectorreturnstrue(i.e.ThreatDetection.EngineConfig != nil), the cloned engine config may already carry its ownMaxAICredits. The new code unconditionally overwrites it withThreatDetection.MaxAICredits, which is the correct priority rule, but there is no test covering both fields being set simultaneously.💡 Suggested additional sub-test
This pins the priority rule:
ThreatDetection.MaxAICreditswins over any value inThreatDetection.EngineConfig.MaxAICredits.@copilot please address this.