@@ -2,8 +2,6 @@ package testapi
22
33import (
44 "time"
5-
6- "github.com/google/uuid"
75)
86
97// IssueIgnoreDetails provides combined information about issue suppression/ignore status,
@@ -39,57 +37,59 @@ type IssueIgnoreDetails interface {
3937
4038 // GetIgnoredBy returns the user who created the ignore action.
4139 GetIgnoredBy () * IgnoredBy
40+
41+ IsActive () bool
4242}
4343
4444// issueIgnoreDetailsImpl is the concrete implementation of IssueIgnoreDetails.
4545type issueIgnoreDetailsImpl struct {
46- suppression * Suppression
47- policyID * string
48- ignoreData * Ignore
46+ finding * FindingData
47+ policyID * string
48+ ignoreData * Ignore
4949}
5050
5151// === Suppression Status Methods ===
5252
5353func (id * issueIgnoreDetailsImpl ) GetStatus () SuppressionStatus {
54- if id .suppression == nil {
54+ if ! id .isInitialized () {
5555 return ""
5656 }
57- return id .suppression .Status
57+ return id .finding . Attributes . Suppression .Status
5858}
5959
6060func (id * issueIgnoreDetailsImpl ) GetCreatedAt () * time.Time {
61- if id .suppression == nil {
61+ if ! id .isInitialized () {
6262 return nil
6363 }
64- return id .suppression .CreatedAt
64+ return id .finding . Attributes . Suppression .CreatedAt
6565}
6666
6767func (id * issueIgnoreDetailsImpl ) GetExpiresAt () * time.Time {
68- if id .suppression == nil {
68+ if ! id .isInitialized () {
6969 return nil
7070 }
71- return id .suppression .ExpiresAt
71+ return id .finding . Attributes . Suppression .ExpiresAt
7272}
7373
7474func (id * issueIgnoreDetailsImpl ) GetJustification () * string {
75- if id .suppression == nil {
75+ if ! id .isInitialized () {
7676 return nil
7777 }
78- return id .suppression .Justification
78+ return id .finding . Attributes . Suppression .Justification
7979}
8080
8181func (id * issueIgnoreDetailsImpl ) GetPath () * []string {
82- if id .suppression == nil {
82+ if ! id .isInitialized () {
8383 return nil
8484 }
85- return id .suppression .Path
85+ return id .finding . Attributes . Suppression .Path
8686}
8787
8888func (id * issueIgnoreDetailsImpl ) SkipIfFixable () * bool {
89- if id .suppression == nil {
89+ if ! id .isInitialized () {
9090 return nil
9191 }
92- return id .suppression .SkipIfFixable
92+ return id .finding . Attributes . Suppression .SkipIfFixable
9393}
9494
9595// === Policy Information Methods ===
@@ -128,65 +128,23 @@ func (id *issueIgnoreDetailsImpl) GetIgnoredBy() *IgnoredBy {
128128 return id .ignoreData .Ignore .IgnoredBy
129129}
130130
131- // newIgnoreDetailsFromSuppression creates an IssueIgnoreDetails from suppression data and findings.
132- func newIgnoreDetailsFromSuppression (suppression * Suppression , findings []* FindingData ) IssueIgnoreDetails {
133- if suppression == nil {
134- return nil
131+ func (id * issueIgnoreDetailsImpl ) IsActive () bool {
132+ if ! id .isInitialized () {
133+ return false
135134 }
136135
137- result := & issueIgnoreDetailsImpl {
138- suppression : suppression ,
136+ if id . finding . Attributes . Suppression . Status != SuppressionStatusIgnored {
137+ return false
139138 }
140139
141- // Extract policy information from suppression
142- if suppression .Policy != nil {
143- // Determine policy type and ID by checking the structure
144- // PolicyRef is a union of either a string (local) or an object with ID (managed)
145-
146- if localRef , err := suppression .Policy .AsPolicyRef0 (); ! (err == nil && localRef == PolicyRef0LocalPolicy ) {
147- // Try as a managed policy (has ID field)
148- if managedRef , err := suppression .Policy .AsManagedPolicyRef (); err == nil && managedRef .Id != uuid .Nil {
149- // It's a managed policy with a valid ID
150- idStr := managedRef .Id .String ()
151- result .policyID = & idStr
152-
153- // Try to find the matching expanded policy data in findings
154- result .ignoreData = findMatchingIgnoreData (suppression .Policy , findings )
155- }
156- // If both fail, policy type cannot be determined (isLocalPolicy remains nil)
157- }
158- }
159-
160- return result
140+ return true
161141}
162142
163- // findMatchingIgnoreData finds the Ignore action that matches the given policy reference.
164- func findMatchingIgnoreData (policyRef * PolicyRef , findings []* FindingData ) * Ignore {
165- if policyRef == nil {
166- return nil
143+ func (id * issueIgnoreDetailsImpl ) isInitialized () bool {
144+ if id .finding == nil || id .finding .Attributes == nil || id .finding .Attributes .Suppression == nil {
145+ return false
167146 }
168-
169- policyIDToMatch := extractPolicyTypeFromRef (policyRef )
170-
171- // Search through findings for matching policy
172- for _ , finding := range findings {
173- if ignoreAction := searchFindingForIgnoreAction (finding , policyIDToMatch ); ignoreAction != nil {
174- return ignoreAction
175- }
176- }
177-
178- return nil
179- }
180-
181- // extractPolicyTypeFromRef determines if a PolicyRef is local or managed and returns the policy ID.
182- func extractPolicyTypeFromRef (policyRef * PolicyRef ) * string {
183- // Try as a managed policy (has ID field)
184- if managedRef , err := policyRef .AsManagedPolicyRef (); err == nil && managedRef .Id != uuid .Nil {
185- idStr := managedRef .Id .String ()
186- return & idStr
187- }
188-
189- return nil
147+ return true
190148}
191149
192150// searchFindingForIgnoreAction searches a finding for a matching ignore action.
0 commit comments