fix: IACE parser handler — use MatchOutput.SuggestedHazards instead of MatchedPatterns fields
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package handlers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/breakpilot/ai-compliance-sdk/internal/iace"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -78,22 +79,32 @@ func (h *IACEHandler) ParseNarrative(c *gin.Context) {
|
||||
MatchedPatterns: len(matchOutput.MatchedPatterns),
|
||||
}
|
||||
|
||||
// Add suggested hazards from matched patterns
|
||||
// Add suggested hazards from pattern engine output
|
||||
for _, h := range matchOutput.SuggestedHazards {
|
||||
// Find the first source pattern for name/priority lookup
|
||||
patternName := ""
|
||||
priority := 50
|
||||
if len(h.SourcePatterns) > 0 {
|
||||
for _, mp := range matchOutput.MatchedPatterns {
|
||||
for _, cat := range mp.GeneratedHazardCats {
|
||||
if mp.PatternID == h.SourcePatterns[0] {
|
||||
patternName = mp.PatternName
|
||||
priority = mp.Priority
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
resp.SuggestedHazards = append(resp.SuggestedHazards, struct {
|
||||
Category string `json:"category"`
|
||||
PatternID string `json:"pattern_id"`
|
||||
PatternName string `json:"pattern_name"`
|
||||
Priority int `json:"priority"`
|
||||
}{
|
||||
Category: cat,
|
||||
PatternID: mp.ID,
|
||||
PatternName: mp.NameDE,
|
||||
Priority: mp.Priority,
|
||||
Category: h.Category,
|
||||
PatternID: strings.Join(h.SourcePatterns, ","),
|
||||
PatternName: patternName,
|
||||
Priority: priority,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user