Skip to content

Commit

Permalink
[CNS-9920] support aws paas (#960)
Browse files Browse the repository at this point in the history
* support aws paas resources

* add aws paas network query destinations

* add aws paas cloud nodes

* run make all
  • Loading branch information
kcarrasco-panw committed Apr 15, 2024
1 parent 13c9c6d commit 5b3e927
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 18 deletions.
15 changes: 12 additions & 3 deletions cloudnetworkquerydestination.go

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

15 changes: 12 additions & 3 deletions cloudnode.go

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

18 changes: 14 additions & 4 deletions custom_validations.go
Expand Up @@ -1704,16 +1704,26 @@ func ValidateCloudNetworkQueryFilter(attribute string, f *CloudNetworkQueryFilte
return makeValidationError(attribute, fmt.Sprintf("paas filtering only allowed for selectors with resource type: %s", CloudNetworkQueryFilterResourceTypePaaS))
}

var azure bool
var (
isAzure bool
isAWS bool
)
for _, ct := range f.CloudTypes {
if strings.EqualFold(ct, constants.CloudTypeAzure) {
azure = true
isAzure = true
break
}
if strings.EqualFold(ct, constants.CloudTypeAWS) {
isAWS = true
break
}
}

if f.ResourceType == CloudNetworkQueryFilterResourceTypePaaS && !azure {
return makeValidationError(attribute, "paas filtering only allowed for Azure queries")
isPaaS := f.ResourceType == CloudNetworkQueryFilterResourceTypePaaS
if isPaaS && !isAzure && !isAWS {
return makeValidationError(
attribute, "PaaS filtering only allowed for Azure or AWS queries",
)
}

return nil
Expand Down
23 changes: 19 additions & 4 deletions custom_validations_test.go
Expand Up @@ -5005,24 +5005,39 @@ func TestValidateCloudGraphQuery(t *testing.T) {
true,
},
{
"paas filter is set for AWS",
"paas filter is set for GCP",
args{
"invalid",
&CloudNetworkQuery{
SourceIP: "1.1.1.0/24",
DestinationSelector: &CloudNetworkQueryFilter{
ResourceType: CloudNetworkQueryFilterResourceTypePaaS,
CloudTypes: []string{"Aws"},
PaasTypes: []string{"MicrosoftDBforMySQLFlexibleServers"},
CloudTypes: []string{"GCP"},
PaasTypes: []string{"Cloud Functions"},
},
},
},
true,
},
{
"paas filter is set for AWS",
args{
"valid",
&CloudNetworkQuery{
SourceIP: "1.1.1.0/24",
DestinationSelector: &CloudNetworkQueryFilter{
ResourceType: CloudNetworkQueryFilterResourceTypePaaS,
CloudTypes: []string{"Aws"},
PaasTypes: []string{"AWS Lambda"},
},
},
},
false,
},
{
"paas filter is set for Azure",
args{
"invalid",
"valid",
&CloudNetworkQuery{
SourceIP: "1.1.1.0/24",
DestinationSelector: &CloudNetworkQueryFilter{
Expand Down
4 changes: 2 additions & 2 deletions doc/documentation.md
Expand Up @@ -12788,7 +12788,7 @@ Returns true if the destination is reachable through routing.

##### `type` [`autogenerated`,`read_only`]

Type: `enum(Interface | Instance | LoadBalancer | PublicIP | K8sService | MySQLServer | MySQLFlexibleServer | PostgreSQLServer | PostgreSQLFlexibleServer | CosmosDB | SQLServer)`
Type: `enum(Interface | Instance | LoadBalancer | PublicIP | K8sService | MySQLServer | MySQLFlexibleServer | PostgreSQLServer | PostgreSQLFlexibleServer | CosmosDB | SQLServer | LambdaFunction | RDSDBInstance | RedshiftCluster)`

Returns the type of the destination.

Expand Down Expand Up @@ -13607,7 +13607,7 @@ The sub-type of the object as found in the parameters. Used for indexing.

##### `type` [`required`]

Type: `enum(Endpoint | Subnet | VPC | Interface | RouteTable | Gateway | NetworkRuleSet | LoadBalancer | LoadBalancerRoute | PublicIPAddress | ScaleSet | ScaleGroup | K8sNode | K8sService | K8sNamespace | K8sPod | MySQLServer | MySQLFlexibleServer | PostgreSQLServer | PostgreSQLFlexibleServer | CosmosDB | SQLServer)`
Type: `enum(Endpoint | Subnet | VPC | Interface | RouteTable | Gateway | NetworkRuleSet | LoadBalancer | LoadBalancerRoute | PublicIPAddress | ScaleSet | ScaleGroup | K8sNode | K8sService | K8sNamespace | K8sPod | MySQLServer | MySQLFlexibleServer | PostgreSQLServer | PostgreSQLFlexibleServer | CosmosDB | SQLServer | LambdaFunction | RDSDBInstance | RedshiftCluster)`

Type of the endpoint.

Expand Down
5 changes: 4 additions & 1 deletion openapi3_autogen/cloudnetworkquerydestination.json
Expand Up @@ -32,7 +32,10 @@
"PostgreSQLServer",
"PostgreSQLFlexibleServer",
"CosmosDB",
"SQLServer"
"SQLServer",
"LambdaFunction",
"RDSDBInstance",
"RedshiftCluster"
],
"readOnly": true
},
Expand Down
5 changes: 4 additions & 1 deletion openapi3_autogen/cloudnode.json
Expand Up @@ -181,7 +181,10 @@
"PostgreSQLServer",
"PostgreSQLFlexibleServer",
"CosmosDB",
"SQLServer"
"SQLServer",
"LambdaFunction",
"RDSDBInstance",
"RedshiftCluster"
],
"example": "Endpoint"
},
Expand Down
3 changes: 3 additions & 0 deletions specs/cloudnetworkquerydestination.spec
Expand Up @@ -50,6 +50,9 @@ attributes:
- PostgreSQLFlexibleServer
- CosmosDB
- SQLServer
- LambdaFunction
- RDSDBInstance
- RedshiftCluster
autogenerated: true

- name: verdict
Expand Down
3 changes: 3 additions & 0 deletions specs/cloudnode.spec
Expand Up @@ -122,4 +122,7 @@ attributes:
- PostgreSQLFlexibleServer
- CosmosDB
- SQLServer
- LambdaFunction
- RDSDBInstance
- RedshiftCluster
example_value: Endpoint

0 comments on commit 5b3e927

Please sign in to comment.