-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: platform dependent genpolicy config
- Loading branch information
Showing
11 changed files
with
63 additions
and
20 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
File renamed without changes.
File renamed without changes.
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 @@ | ||
# THIS FILE IS REPLACED DURING BUILD AND ONLY HERE TO SATISFY GO TOOLING |
File renamed without changes.
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,44 @@ | ||
// Copyright 2024 Edgeless Systems GmbH | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
package genpolicy | ||
|
||
import ( | ||
_ "embed" | ||
|
||
"github.com/edgelesssys/contrast/internal/platforms" | ||
) | ||
|
||
var ( | ||
//go:embed assets/genpolicy | ||
genpolicyBin []byte | ||
//go:embed assets/genpolicy-settings.json | ||
defaultGenpolicySettings []byte | ||
//go:embed assets/genpolicy-rules.rego | ||
aksCloudHypervisorSNPRules []byte | ||
//go:embed assets/allow-all.rego | ||
permissiveRules []byte | ||
) | ||
|
||
// Config contains configuration files for genpolicy. | ||
type Config struct { | ||
// Rules is a Rego module that verifies agent requests. | ||
Rules []byte | ||
// Settings is a json config file that holds platform-specific configuration. | ||
Settings []byte | ||
} | ||
|
||
// NewConfig selects the appropriate genpolicy configuration for the target platform. | ||
func NewConfig(platform platforms.Platform) *Config { | ||
cfg := &Config{ | ||
Settings: defaultGenpolicySettings, | ||
} | ||
switch platform { | ||
case platforms.AKSCloudHypervisorSNP: | ||
cfg.Rules = aksCloudHypervisorSNPRules | ||
default: | ||
// TODO(burgerdev): use real rules for supported platforms. | ||
cfg.Rules = permissiveRules | ||
} | ||
return cfg | ||
} |
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