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 (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/breakpilot/ai-compliance-sdk/internal/iace"
|
"github.com/breakpilot/ai-compliance-sdk/internal/iace"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -78,21 +79,31 @@ func (h *IACEHandler) ParseNarrative(c *gin.Context) {
|
|||||||
MatchedPatterns: len(matchOutput.MatchedPatterns),
|
MatchedPatterns: len(matchOutput.MatchedPatterns),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add suggested hazards from matched patterns
|
// Add suggested hazards from pattern engine output
|
||||||
for _, mp := range matchOutput.MatchedPatterns {
|
for _, h := range matchOutput.SuggestedHazards {
|
||||||
for _, cat := range mp.GeneratedHazardCats {
|
// Find the first source pattern for name/priority lookup
|
||||||
resp.SuggestedHazards = append(resp.SuggestedHazards, struct {
|
patternName := ""
|
||||||
Category string `json:"category"`
|
priority := 50
|
||||||
PatternID string `json:"pattern_id"`
|
if len(h.SourcePatterns) > 0 {
|
||||||
PatternName string `json:"pattern_name"`
|
for _, mp := range matchOutput.MatchedPatterns {
|
||||||
Priority int `json:"priority"`
|
if mp.PatternID == h.SourcePatterns[0] {
|
||||||
}{
|
patternName = mp.PatternName
|
||||||
Category: cat,
|
priority = mp.Priority
|
||||||
PatternID: mp.ID,
|
break
|
||||||
PatternName: mp.NameDE,
|
}
|
||||||
Priority: mp.Priority,
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
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: h.Category,
|
||||||
|
PatternID: strings.Join(h.SourcePatterns, ","),
|
||||||
|
PatternName: patternName,
|
||||||
|
Priority: priority,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
|
|||||||
Reference in New Issue
Block a user