-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Anurag Rajawat <[email protected]>
- Loading branch information
1 parent
65e0acc
commit c736ce3
Showing
19 changed files
with
487 additions
and
143 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,20 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2023 Authors of Nimbus | ||
|
||
// Package adapter provides security engine adapters to use with nimbus. | ||
package adapter | ||
|
||
import ( | ||
"context" | ||
|
||
v1 "github.com/5GSEC/nimbus/api/v1" | ||
) | ||
|
||
// The Adapters currently supported by nimbus. | ||
var Adapters = []string{"kubearmor"} | ||
|
||
// Adapter knows how to create/update and delete security-engine policies. | ||
type Adapter interface { | ||
ApplyPolicy(ctx context.Context, np v1.NimbusPolicy) error | ||
DeletePolicy(ctx context.Context, np v1.NimbusPolicy) error | ||
} |
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,39 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2023 Authors of Nimbus | ||
|
||
package exporter | ||
|
||
import ( | ||
"context" | ||
|
||
"go.uber.org/zap" | ||
|
||
v1 "github.com/5GSEC/nimbus/api/v1" | ||
"github.com/5GSEC/nimbus/pkg/adapter" | ||
"github.com/5GSEC/nimbus/pkg/adapter/k8s" | ||
"github.com/5GSEC/nimbus/pkg/adapter/kubearmor" | ||
) | ||
|
||
// ExportNpToAdapters export nimbus policy to security-engine adapters. | ||
func ExportNpToAdapters(loggr *zap.SugaredLogger, nimbusPolicy v1.NimbusPolicy) { | ||
for _, adptr := range adapter.Adapters { | ||
loggr.Infof("Exporting '%s' NimbusPolicy to %s security engine", nimbusPolicy.Name, adptr) | ||
err := sendNpTo(loggr, nimbusPolicy, adptr) | ||
if err != nil { | ||
loggr.Warnf("%v", err) | ||
} | ||
} | ||
} | ||
|
||
func sendNpTo(loggr *zap.SugaredLogger, nimbusPolicy v1.NimbusPolicy, adptr string) error { | ||
var securityEngineClient adapter.Adapter | ||
k8sClient := k8s.NewClient(loggr) | ||
switch adptr { | ||
case "kubearmor": | ||
securityEngineClient = kubearmor.NewKubeArmorClient(loggr, k8sClient) | ||
err := securityEngineClient.ApplyPolicy(context.Background(), nimbusPolicy) | ||
return err | ||
default: | ||
return nil | ||
} | ||
} |
Oops, something went wrong.