-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Cleanup Handler to update resolved failures for targets lik…
…e SecurityHub (#426) * Implement Cleanup Handler to update resolved failures for targets like SecurityHub Signed-off-by: Frank Jogeleit <frank.jogeleit@lovoo.com>
- Loading branch information
Showing
29 changed files
with
394 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package listener | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/kyverno/policy-reporter/pkg/report" | ||
"github.com/kyverno/policy-reporter/pkg/target" | ||
) | ||
|
||
const CleanUpListener = "cleanup_listener" | ||
|
||
func NewCleanupListener(ctx context.Context, handlers []target.Client) report.PolicyReportListener { | ||
return func(event report.LifecycleEvent) { | ||
for _, handler := range handlers { | ||
handler.CleanUp(ctx, event.PolicyReport) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package listener_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/kyverno/policy-reporter/pkg/listener" | ||
"github.com/kyverno/policy-reporter/pkg/report" | ||
"github.com/kyverno/policy-reporter/pkg/target" | ||
) | ||
|
||
func Test_CleanupListener(t *testing.T) { | ||
t.Run("Execute Cleanup Handler", func(t *testing.T) { | ||
c := &client{} | ||
|
||
slistener := listener.NewCleanupListener(ctx, []target.Client{c}) | ||
slistener(report.LifecycleEvent{Type: report.Added, PolicyReport: preport1}) | ||
|
||
if !c.cleanupCalled { | ||
t.Error("expected cleanup method was called") | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.