@@ -18,13 +18,15 @@ package command
18
18
19
19
import (
20
20
"context"
21
+ "encoding/json"
21
22
"fmt"
22
23
23
24
"github.com/snyk/code-client-go/sarif"
24
25
"github.com/snyk/go-application-framework/pkg/configuration"
25
26
"github.com/snyk/go-application-framework/pkg/local_workflows/ignore_workflow"
26
27
"github.com/snyk/snyk-ls/application/config"
27
28
"github.com/snyk/snyk-ls/domain/snyk"
29
+ "github.com/snyk/snyk-ls/infrastructure/code"
28
30
"github.com/snyk/snyk-ls/internal/types"
29
31
)
30
32
@@ -77,16 +79,28 @@ func (cmd *submitIgnoreRequest) Execute(ctx context.Context) (any, error) {
77
79
gafConfig .Set (ignore_workflow .InteractiveKey , false )
78
80
gafConfig .Set (configuration .INPUT_DIRECTORY , contentRoot )
79
81
80
- result , err := engine .InvokeWithConfig (ignore_workflow .WORKFLOWID_IGNORE_CREATE , gafConfig )
81
- if err != nil && len ( result ) == 0 {
82
- return nil , fmt . Errorf ( "failed to invoke ignore-create workflow: %w" , err )
82
+ data , err := engine .InvokeWithConfig (ignore_workflow .WORKFLOWID_IGNORE_CREATE , gafConfig )
83
+ if err != nil {
84
+ return nil , err
83
85
}
84
86
85
- suppressionResponse , ok := result [0 ].GetPayload ().(* sarif.Suppression )
87
+ if data == nil || len (data ) == 0 {
88
+ return nil , fmt .Errorf ("no data returned from ignore workflow" )
89
+ }
90
+
91
+ output , ok := data [0 ].GetPayload ().([]byte )
86
92
if ! ok {
87
- return nil , fmt .Errorf ("unexpected payload type: expected *sarif.Suppression" )
93
+ return nil , fmt .Errorf ("invalid response from ignore workflow" ) //TODO fix this
94
+ }
95
+
96
+ var suppression * sarif.Suppression
97
+ err = json .Unmarshal (output , suppression )
98
+ if err != nil {
99
+ return nil , err
88
100
}
89
- issue .SetSuppressionStatus (string (suppressionResponse .Status ))
101
+ ignoreDetails := code .SarifSuppressionToIgnoreDetails (suppression )
102
+
103
+ issue .SetIgnoreDetails (ignoreDetails )
90
104
91
105
case "update" :
92
106
if len (cmd .command .Arguments ) < 5 {
@@ -129,7 +143,7 @@ func (cmd *submitIgnoreRequest) Execute(ctx context.Context) (any, error) {
129
143
if ! ok {
130
144
return nil , fmt .Errorf ("unexpected payload type: expected *sarif.Suppression" )
131
145
}
132
- issue .SetSuppressionStatus (string (suppressionResponse .Status ))
146
+ issue .SetIgnoreDetails (string (suppressionResponse .Status ))
133
147
134
148
case "delete" :
135
149
if len (cmd .command .Arguments ) < 3 {
@@ -157,7 +171,7 @@ func (cmd *submitIgnoreRequest) Execute(ctx context.Context) (any, error) {
157
171
if ! ok {
158
172
return nil , fmt .Errorf ("unexpected payload type: expected *sarif.Suppression" )
159
173
}
160
- issue .SetSuppressionStatus (string (suppressionResponse .Status ))
174
+ issue .SetIgnoreDetails (string (suppressionResponse .Status ))
161
175
162
176
default :
163
177
return nil , fmt .Errorf (`unkown worflow` )
0 commit comments