@@ -93,14 +93,23 @@ type client struct {
93
93
94
94
// TestResult defines the contract for accessing test result information.
95
95
type TestResult interface {
96
- GetState () string
96
+ GetTestID () * uuid.UUID
97
+ GetTestConfiguration () * TestConfiguration
98
+ GetCreatedAt () * time.Time
99
+ GetTestSubject () TestSubject
100
+ GetSubjectLocators () * []TestSubjectLocator
101
+
102
+ GetExecutionState () TestExecutionStates
97
103
GetErrors () * []IoSnykApiCommonError
98
104
GetWarnings () * []IoSnykApiCommonError
99
- GetTestID () * uuid. UUID
100
- GetOutcome () * PassFail
105
+
106
+ GetPassFail () * PassFail
101
107
GetOutcomeReason () * TestOutcomeReason
108
+ GetBreachedPolicies () * PolicyRefSet
109
+
102
110
GetEffectiveSummary () * FindingSummary
103
111
GetRawSummary () * FindingSummary
112
+
104
113
Findings (ctx context.Context ) (resultFindings []FindingData , complete bool , err error )
105
114
}
106
115
@@ -156,14 +165,22 @@ type StartTestParams struct {
156
165
// testResult is the concrete implementation of the TestResult interface for
157
166
// accessing summary and findings data of a completed test.
158
167
type testResult struct {
159
- State string // e.g., "finished", "errored"
160
- Errors * []IoSnykApiCommonError
161
- Warnings * []IoSnykApiCommonError
162
- TestID * uuid.UUID // The final Test ID (different from Job ID)
163
- Outcome * PassFail // Pass or Fail
168
+ TestID * uuid.UUID // The final Test ID (different from Job ID)
169
+ TestConfiguration * TestConfiguration
170
+ CreatedAt * time.Time
171
+ TestSubject TestSubject
172
+ SubjectLocators * []TestSubjectLocator
173
+
174
+ ExecutionState TestExecutionStates // e.g., "finished", "errored"
175
+ Errors * []IoSnykApiCommonError
176
+ Warnings * []IoSnykApiCommonError
177
+
178
+ PassFail * PassFail // Pass or Fail
164
179
OutcomeReason * TestOutcomeReason // Reason for the outcome (e.g., policy_breach)
165
- EffectiveSummary * FindingSummary // Summary excluding suppressed findings
166
- RawSummary * FindingSummary // Summary including suppressed findings
180
+ BreachedPolicies * PolicyRefSet // A set of local or managed policies
181
+
182
+ EffectiveSummary * FindingSummary // Summary excluding suppressed findings
183
+ RawSummary * FindingSummary // Summary including suppressed findings
167
184
168
185
findings []FindingData // Stores the actual findings
169
186
findingsComplete bool // True if all findings pages were fetched
@@ -174,8 +191,8 @@ type testResult struct {
174
191
handle * testHandle // Populated when testResult is created
175
192
}
176
193
177
- // GetState returns the execution state of the test.
178
- func (r * testResult ) GetState () string { return r .State }
194
+ // GetExecutionState returns the execution state of the test.
195
+ func (r * testResult ) GetExecutionState () TestExecutionStates { return r .ExecutionState }
179
196
180
197
// GetErrors returns any API errors encountered during the test execution.
181
198
func (r * testResult ) GetErrors () * []IoSnykApiCommonError { return r .Errors }
@@ -186,12 +203,27 @@ func (r *testResult) GetWarnings() *[]IoSnykApiCommonError { return r.Warnings }
186
203
// GetTestID returns the final Test ID.
187
204
func (r * testResult ) GetTestID () * uuid.UUID { return r .TestID }
188
205
189
- // GetOutcome returns the pass/fail outcome of the test.
190
- func (r * testResult ) GetOutcome () * PassFail { return r .Outcome }
206
+ // GetPassFail returns the pass/fail outcome of the test.
207
+ func (r * testResult ) GetPassFail () * PassFail { return r .PassFail }
191
208
192
209
// GetOutcomeReason returns the reason for the test outcome.
193
210
func (r * testResult ) GetOutcomeReason () * TestOutcomeReason { return r .OutcomeReason }
194
211
212
+ // GetBreachedPolicies returns the policies that were breached.
213
+ func (r * testResult ) GetBreachedPolicies () * PolicyRefSet { return r .BreachedPolicies }
214
+
215
+ // GetTestConfiguration returns the test configuration.
216
+ func (r * testResult ) GetTestConfiguration () * TestConfiguration { return r .TestConfiguration }
217
+
218
+ // GetCreatedAt returns the creation timestamp of the test.
219
+ func (r * testResult ) GetCreatedAt () * time.Time { return r .CreatedAt }
220
+
221
+ // GetTestSubject returns the test subject.
222
+ func (r * testResult ) GetTestSubject () TestSubject { return r .TestSubject }
223
+
224
+ // GetSubjectLocators returns the subject locators.
225
+ func (r * testResult ) GetSubjectLocators () * []TestSubjectLocator { return r .SubjectLocators }
226
+
195
227
// GetEffectiveSummary returns the summary excluding suppressed findings.
196
228
func (r * testResult ) GetEffectiveSummary () * FindingSummary { return r .EffectiveSummary }
197
229
@@ -471,31 +503,36 @@ func (h *testHandle) fetchResultStatus(ctx context.Context, testID uuid.UUID) (T
471
503
472
504
testData := resp .ApplicationvndApiJSON200 .Data
473
505
attrs := testData .Attributes
474
- status := & testResult {
475
- TestID : testData .Id ,
476
- EffectiveSummary : attrs .EffectiveSummary ,
477
- RawSummary : attrs .RawSummary ,
478
- handle : h ,
506
+ result := & testResult {
507
+ TestID : testData .Id ,
508
+ TestConfiguration : attrs .Config ,
509
+ CreatedAt : attrs .CreatedAt ,
510
+ TestSubject : attrs .Subject ,
511
+ SubjectLocators : attrs .SubjectLocators ,
512
+ EffectiveSummary : attrs .EffectiveSummary ,
513
+ RawSummary : attrs .RawSummary ,
514
+ handle : h ,
479
515
}
480
516
481
517
if attrs .State != nil {
482
- status . State = string ( attrs .State .Execution )
518
+ result . ExecutionState = attrs .State .Execution
483
519
if attrs .State .Errors != nil && len (* attrs .State .Errors ) > 0 {
484
- status .Errors = attrs .State .Errors
520
+ result .Errors = attrs .State .Errors
485
521
}
486
522
if attrs .State .Warnings != nil && len (* attrs .State .Warnings ) > 0 {
487
- status .Warnings = attrs .State .Warnings
523
+ result .Warnings = attrs .State .Warnings
488
524
}
489
525
} else {
490
- status . State = "unknown" // API spec defines this as always set
526
+ result . ExecutionState = TestExecutionStates ( "unknown" ) // API spec defines this as always set
491
527
}
492
528
493
529
if attrs .Outcome != nil {
494
- status .Outcome = & attrs .Outcome .Result
495
- status .OutcomeReason = attrs .Outcome .Reason
530
+ result .PassFail = & attrs .Outcome .Result
531
+ result .OutcomeReason = attrs .Outcome .Reason
532
+ result .BreachedPolicies = attrs .Outcome .BreachedPolicies
496
533
}
497
534
498
- return status , nil
535
+ return result , nil
499
536
}
500
537
501
538
// Returns a channel signaling completion of Wait()
0 commit comments