Skip to content

Commit

Permalink
fix unit tests and more some..in lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturRibeiro-CX committed Nov 20, 2024
1 parent 119406f commit 4d0a3b7
Show file tree
Hide file tree
Showing 36 changed files with 218 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ shell_possibilities := {
}

CxPolicy[result] {
some document in input.keywords
some document in input.document
resource := document.command[name][_]
resource.Cmd == "run"
value := resource.Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Cx
import future.keywords.in

CxPolicy[result] {
some document in input.keywords
some document in input.document
resource := document.command[name][_]
resource.Cmd == "copy"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Cx
import future.keywords.in

CxPolicy[result] {
some i, name
some name
some document in input.document
resource := document.command[name][_]
resource.Cmd == "maintainer"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package Cx

import data.generic.common as common_lib
import future.keywords.in

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "container.v1.cluster"

not common_lib.valid_key(resource.properties, "masterAuth")

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties", [resource.name]),
Expand All @@ -21,14 +23,15 @@ CxPolicy[result] {
}

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "container.v1.cluster"

not common_lib.valid_key(resource.properties.masterAuth, "username")
not common_lib.valid_key(resource.properties.masterAuth, "password")

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.masterAuth", [resource.name]),
Expand All @@ -40,14 +43,15 @@ CxPolicy[result] {
}

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "container.v1.cluster"

not count(resource.properties.masterAuth.username) > 0
not count(resource.properties.masterAuth.password) > 0

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.masterAuth", [resource.name]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package Cx

import data.generic.common as common_lib
import future.keywords.in

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "compute.v1.instance"

resource.properties.networkInterfaces[idx].accessConfigs

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.networkInterfaces", [resource.name]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package Cx

import data.generic.common as common_lib
import future.keywords.in

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "container.v1.nodePool"

not startswith(lower(resource.properties.config.imageType), "cos")

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.config.imageType", [resource.name]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package Cx

import data.generic.common as common_lib
import future.keywords.in

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "compute.v1.instance"

disks := resource.properties.disks[d]
not common_lib.valid_key(disks, "diskEncryptionKey")

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.disks", [resource.name]),
Expand All @@ -22,15 +24,16 @@ CxPolicy[result] {
}

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "compute.v1.instance"

disks := resource.properties.disks[d]
not common_lib.valid_key(disks.diskEncryptionKey, "rawKey")
not common_lib.valid_key(disks.diskEncryptionKey, "kmsKeyName")

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.disks.diskEncryptionKey", [resource.name]),
Expand All @@ -44,14 +47,15 @@ CxPolicy[result] {
fields := {"rawKey", "kmsKeyName"}

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "compute.v1.instance"

disks := resource.properties.disks[d]
disks.diskEncryptionKey[fields[f]] == ""

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.disks.diskEncryptionKey.%s", [resource.name, fields[f]]),
Expand All @@ -65,14 +69,15 @@ CxPolicy[result] {
valid_disk_resources := ["compute.beta.disk", "compute.v1.disk"]

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == valid_disk_resources[_]

disk := resource.properties
not common_lib.valid_key(disk, "diskEncryptionKey")

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.disks", [resource.name]),
Expand All @@ -84,15 +89,16 @@ CxPolicy[result] {
}

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == valid_disk_resources[_]

disk := resource.properties
not common_lib.valid_key(disk.diskEncryptionKey, "rawKey")
not common_lib.valid_key(disk.diskEncryptionKey, "kmsKeyName")

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.diskEncryptionKey", [resource.name]),
Expand All @@ -104,14 +110,15 @@ CxPolicy[result] {
}

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == valid_disk_resources[_]

disk := resource.properties
disk.diskEncryptionKey[fields[f]] == ""

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.diskEncryptionKey.%s", [resource.name, fields[f]]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package Cx

import data.generic.common as common_lib
import future.keywords.in

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "dns.v1.managedZone"

resource.properties.dnssecConfig.defaultKeySpecs[d].algorithm == "rsasha1"

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.dnssecConfig.defaultKeySpecs", [resource.name]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package Cx

import data.generic.common as common_lib
import future.keywords.in

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "container.v1.cluster"

resource.properties.legacyAbac.enabled == true

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.legacyAbac.enabled", [resource.name]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package Cx

import data.generic.common as common_lib
import future.keywords.in

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "container.v1.cluster"

not common_lib.valid_key(resource.properties, "masterAuthorizedNetworksConfig")

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties", [resource.name]),
Expand All @@ -21,13 +23,14 @@ CxPolicy[result] {
}

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "container.v1.cluster"

not common_lib.valid_key(resource.properties.masterAuthorizedNetworksConfig, "enabled")

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.masterAuthorizedNetworksConfig", [resource.name]),
Expand All @@ -39,13 +42,14 @@ CxPolicy[result] {
}

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "container.v1.cluster"

resource.properties.masterAuthorizedNetworksConfig.enabled == false

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.masterAuthorizedNetworksConfig.enabled", [resource.name]),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package Cx

import data.generic.common as common_lib
import future.keywords.in

CxPolicy[result] {
resource := input.document[i].resources[idx]
some document in input.document
resource := document.resources[idx]
resource.type == "storage.v1.bucket"

resource.properties.iamConfiguration.uniformBucketLevelAccess.enabled == false

result := {
"documentId": input.document[i].id,
"documentId": document.id,
"resourceType": resource.type,
"resourceName": resource.name,
"searchKey": sprintf("resources.name={{%s}}.properties.iamConfiguration.uniformBucketLevelAccess.enabled", [resource.name]),
Expand Down
Loading

0 comments on commit 4d0a3b7

Please sign in to comment.