Skip to content

Commit

Permalink
Merge pull request #54 from ContainerSolutions/fix/demonstration
Browse files Browse the repository at this point in the history
Adding several fixes
  • Loading branch information
gusfcarvalho authored Jul 17, 2023
2 parents 862cbec + 413f452 commit 97d699c
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 52 deletions.
2 changes: 1 addition & 1 deletion infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ resource "google_container_node_pool" "primary_preemptible_nodes" {
node_count = 3

node_config {
machine_type = "e2-medium"
machine_type = "e2-standard-4"

service_account = google_service_account.default.email
oauth_scopes = [
Expand Down
9 changes: 6 additions & 3 deletions operator/api/v1alpha1/componentattestation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ type ComponentAttestationStatus struct {
}

type AttestationResult struct {
Logs string `json:"logs"`
//+optional
Logs string `json:"logs,omitempty"`
Result AttestationResultType `json:"result"`
Reason string `json:"reason"`
//+optional
Err string `json:"err,omitempty"`
Reason string `json:"reason"`
//+optional
Err string `json:"err,omitempty"`
//+optional
RunAt metav1.Time `json:"runAt"`
}
type AttestationResultType string
Expand Down
3 changes: 0 additions & 3 deletions operator/config/crd/bases/argus.io_componentattestations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ spec:
format: date-time
type: string
required:
- logs
- reason
- result
- runAt
type: object
status:
type: string
Expand Down
2 changes: 1 addition & 1 deletion operator/config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: controller
newName: us-central1-docker.pkg.dev/gfc-personal-use/argus/controller
newTag: latest
10 changes: 5 additions & 5 deletions operator/config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ spec:
- --leader-elect
image: controller:latest
name: manager
imagePullPolicy: IfNotPresent
imagePullPolicy: Always
ports:
- containerPort: 8080
name: metrics
Expand All @@ -97,10 +97,10 @@ spec:
# More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
resources:
limits:
cpu: 500m
memory: 128Mi
cpu: 2000m
memory: 2Gi
requests:
cpu: 10m
memory: 64Mi
cpu: 1000m
memory: 1Gi
serviceAccountName: controller-manager
terminationGracePeriodSeconds: 10
21 changes: 21 additions & 0 deletions operator/config/samples/terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions operator/config/samples/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@ provider "kubernetes" {
config_path = "~/.kube/config"
}

resource "kubernetes_manifest" "resource_type1" {
count=10
manifest = yamldecode(templatefile("resource.yaml", {name="app-${count.index+1}",class="Application",parent="app-platform"}))
}

resource "kubernetes_manifest" "resource_type2" {
count=10
manifest = yamldecode(templatefile("resource.yaml", {name="vm-${count.index+1}",class="VirtualMachine",parent="vm-platform"}))
}

resource "kubernetes_manifest" "resource_type3" {
count=10
manifest = yamldecode(templatefile("resource.yaml", {name="rt-${count.index+1}",class="NetworkElement",parent="rt-platform"}))
manifest = yamldecode(templatefile("resource.yaml", {name="router-${count.index+1}",class="NetworkElement",parent="rt-platform"}))
}

resource "kubernetes_manifest" "random_provider" {
Expand Down
36 changes: 14 additions & 22 deletions operator/config/samples/terraform/network.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
resource "kubernetes_manifest" "network_control_1" {
manifest = yamldecode(templatefile("requirement.yaml",
{
# name="Auto routing should be disabled",
description="Auto routing should be disabled",
name="net-req-01"
code="NET-REQ-01",
version="1.0.0",
description="Auto routing can be used to propagate information",
componentclass="NetworkElement",
}
))
Expand All @@ -14,11 +13,10 @@ resource "kubernetes_manifest" "network_control_1" {
resource "kubernetes_manifest" "network_control_2" {
manifest = yamldecode(templatefile("requirement.yaml",
{
# name="Outbound traffic should be sent to NSEC device",
description="Outbound traffic should be sent to NSEC device",
name="net-req-02"
code="NET-REQ-02",
version="1.0.0",
description="",
componentclass="NetworkElement",
}
))
Expand All @@ -27,11 +25,10 @@ resource "kubernetes_manifest" "network_control_2" {
resource "kubernetes_manifest" "network_control_3" {
manifest = yamldecode(templatefile("requirement.yaml",
{
# name="Public IP Addresses must not be used",
description="Public IP Addresses must not be used",
name="net-req-03"
code="NET-REQ-03",
version="1.0.0",
description="",
componentclass="NetworkElement",
}
))
Expand All @@ -40,11 +37,10 @@ resource "kubernetes_manifest" "network_control_3" {
resource "kubernetes_manifest" "network_control_4" {
manifest = yamldecode(templatefile("requirement.yaml",
{
# name="Inbound internet facing communication must be behind central firewall",
description="Inbound internet facing communication must be behind central firewall",
name="net-req-04"
code="NET-REQ-04",
version="1.0.0",
description="",
componentclass="NetworkElement",
}
))
Expand All @@ -53,11 +49,10 @@ resource "kubernetes_manifest" "network_control_4" {
resource "kubernetes_manifest" "network_control_5" {
manifest = yamldecode(templatefile("requirement.yaml",
{
# name="DNS requests must be microsegmented between network environments",
description="DNS requests must be microsegmented between network environments",
name="net-req-05"
code="NET-REQ-05",
version="1.0.0",
description="",
componentclass="NetworkElement",
}
))
Expand All @@ -66,11 +61,10 @@ resource "kubernetes_manifest" "network_control_5" {
resource "kubernetes_manifest" "network_control_6" {
manifest = yamldecode(templatefile("requirement.yaml",
{
# name="Any Inbound traffic needs to be properly managed behind firewall rules",
name="net-req-06"
code="NET-REQ-06",
version="1.0.0",
description="",
description="Any Inbound traffic needs to be properly managed behind firewall rules",
componentclass="NetworkElement",
}
))
Expand All @@ -79,11 +73,10 @@ resource "kubernetes_manifest" "network_control_6" {
resource "kubernetes_manifest" "network_control_7" {
manifest = yamldecode(templatefile("requirement.yaml",
{
# name="Networking design needs to ensure network isolation between different applications",
description="Networking design needs to ensure network isolation between different applications",
name="net-req-07"
code="NET-REQ-07",
version="1.0.0",
description="",
componentclass="NetworkElement",
}
))
Expand All @@ -92,11 +85,10 @@ resource "kubernetes_manifest" "network_control_7" {
resource "kubernetes_manifest" "network_control_8" {
manifest = yamldecode(templatefile("requirement.yaml",
{
# name="Network traffic cannot leave the same bounded region/datacenter",
description="Network traffic cannot leave the same bounded region/datacenter",
name="net-req-08"
code="NET-REQ-08",
version="1.0.0",
description="",
componentclass="NetworkElement",
}
))
Expand All @@ -110,7 +102,7 @@ resource "kubernetes_manifest" "preventative_control" {
class= "PreventativeControl",
code= "NET-REQ-0${count.index+1}",
version="1.0.0",
type="rt"
type="router"
}
))
}
Expand All @@ -123,7 +115,7 @@ resource "kubernetes_manifest" "detective_control" {
class= "DetectiveControl",
code= "NET-REQ-0${count.index+1}",
version="1.0.0",
type="rt"
type="router"
}
))
}
Expand All @@ -136,7 +128,7 @@ resource "kubernetes_manifest" "reactive_control" {
class= "ReactiveControl",
code= "NET-REQ-0${count.index+1}",
version="1.0.0",
type="rt"
type="router"
}
))
}
Expand All @@ -145,8 +137,8 @@ resource "kubernetes_manifest" "reasoning_attestation" {
count = 8
manifest = yamldecode(templatefile("attestation.yaml",
{
name="req${count.index+1}-reasoning",
implementation = "req${count.index+1}-preventative",
name="req${count.index+1}-detective",
implementation = "req${count.index+1}-detective",
}
))
}
Expand All @@ -155,7 +147,7 @@ resource "kubernetes_manifest" "deployed_attestation" {
count = 8
manifest = yamldecode(templatefile("attestation.yaml",
{
name="req${count.index+1}-prev-deployed",
name="req${count.index+1}-preventative",
implementation = "req${count.index+1}-preventative",
}
))
Expand Down
1 change: 1 addition & 0 deletions operator/config/samples/terraform/requirement.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ spec:
code: ${code}
class: "Security"
category: "Internal"
description: ${description}
applicableComponentClasses:
- ${componentclass}
requiredAssessmentClasses:
Expand Down
14 changes: 8 additions & 6 deletions operator/internal/provider/checkov/checkov.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ type Client struct {

func (c *Client) Attest() (argusiov1alpha1.AttestationResult, error) {
mu.Lock()
// ToDo: generate unique file names for clone_location and output_file_path
defer os.RemoveAll("/tmp/location")
defer mu.Unlock()
defer func() {
os.RemoveAll("/tmp/location")
mu.Unlock()
}()
clone_location := "/tmp/location"
cmd := exec.Command("git", "clone", c.RepoUrl, clone_location)
out, err := cmd.CombinedOutput()
Expand All @@ -33,7 +34,7 @@ func (c *Client) Attest() (argusiov1alpha1.AttestationResult, error) {
res := argusiov1alpha1.AttestationResult{
Result: argusiov1alpha1.AttestationResultTypeUnknown,
Logs: string(out),
Err: err.Error(), // Logs has to be type string
Err: err.Error(),
RunAt: v1.Now(),
Reason: fmt.Sprintf("could not get source repo for '%v'", c.RepoUrl),
}
Expand All @@ -44,7 +45,6 @@ func (c *Client) Attest() (argusiov1alpha1.AttestationResult, error) {

out, err = checkov_cmd.CombinedOutput()

// Distinguish between execution and validation failure
res := argusiov1alpha1.AttestationResult{
Result: argusiov1alpha1.AttestationResultTypePass,
Logs: string(out),
Expand All @@ -55,6 +55,7 @@ func (c *Client) Attest() (argusiov1alpha1.AttestationResult, error) {
res.Result = argusiov1alpha1.AttestationResultTypeUnknown
res.Err = err.Error()
res.Reason = "checkov execution returned error"
return res, err
}
if checkov_cmd.ProcessState.ExitCode() != 0 {
res.Result = argusiov1alpha1.AttestationResultTypeFail
Expand All @@ -69,7 +70,8 @@ func (c *Client) Close() error {

type Provider struct{}

func (p *Provider) New(_ string, spec *argusiov1alpha1.AttestationProviderSpec) (provider.AttestationClient, error) {
func (p *Provider) New(name string, spec *argusiov1alpha1.AttestationProviderSpec) (provider.AttestationClient, error) {

c := &Client{}
repourl_value, ok := spec.ProviderConfig["repo"]

Expand Down

0 comments on commit 97d699c

Please sign in to comment.