Skip to content

Commit

Permalink
Add security scope validation to all reference-adding workflows
Browse files Browse the repository at this point in the history
Change-Id: I2266e6a519feba203c729692eff1432ea3d0a9ad
Closes-Bug: #1772594
(cherry picked from commit 879485c)
  • Loading branch information
IridiumOxide committed Jun 18, 2018
1 parent 5929a1d commit 6ef7f40
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions o11nplugin-contrail-config/buildNumber.properties
@@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Tue Jun 12 14:22:55 CEST 2018
buildNumber=1460
#Thu Jun 14 17:13:15 CEST 2018
buildNumber=1461
Expand Up @@ -162,6 +162,15 @@ val readUponQuery = setOf(
the<FirewallRule>()
)

val validateSecurityScope = setOf(
the<ApplicationPolicySet>(),
the<FirewallPolicy>(),
the<FirewallRule>(),
the<AddressGroup>(),
the<ServiceGroup>(),
the<Tag>()
)

private inline fun <reified T> the() =
T::class.java.simpleName

Expand Down Expand Up @@ -234,6 +243,9 @@ fun ObjectClass.hasCustomAddReferenceWorkflow(child: Class<*>) =
fun ObjectClass.hasCustomRemoveReferenceWorkflow(child: Class<*>) =
customRemoveReference.containsUnordered(simpleName, child.simpleName)

val ObjectClass.needsSecurityScopeValidation get() =
validateSecurityScope.contains(simpleName)

infix fun String.isDisplayableChildOf(parent: String) =
this != parent &&
! hiddenRelations.containsUnordered(parent, this) &&
Expand Down
Expand Up @@ -4,8 +4,11 @@

package net.juniper.contrail.vro.generator.workflows

import net.juniper.contrail.api.types.Project
import net.juniper.contrail.vro.config.constants.child
import net.juniper.contrail.vro.config.constants.item
import net.juniper.contrail.vro.config.isA
import net.juniper.contrail.vro.config.needsSecurityScopeValidation
import net.juniper.contrail.vro.config.propertyValue
import net.juniper.contrail.vro.generator.model.ForwardRelation
import net.juniper.contrail.vro.workflows.dsl.WorkflowDefinition
Expand All @@ -16,6 +19,7 @@ import net.juniper.contrail.vro.workflows.dsl.asBrowserRoot
import net.juniper.contrail.vro.workflows.dsl.actionCallTo
import net.juniper.contrail.vro.workflows.model.reference
import net.juniper.contrail.vro.schema.Schema
import net.juniper.contrail.vro.workflows.custom.matchesSecurityScope
import net.juniper.contrail.vro.workflows.dsl.parentConnection
import net.juniper.contrail.vro.workflows.util.addRelationWorkflowName
import net.juniper.contrail.vro.workflows.util.childDescriptionInCreateRelation
Expand All @@ -30,6 +34,7 @@ fun addReferenceWorkflow(relation: ForwardRelation, schema: Schema): WorkflowDef
val childClass = relation.declaredChildClass
val workflowName = schema.addRelationWorkflowName(parentClass, childClass)
val scriptBody = relation.addReferenceRelationScriptBody()
val directValidation = parentClass.isA<Project>()

return workflow(workflowName).withScript(scriptBody) {
parameter(item, parentClass.reference) {
Expand All @@ -42,6 +47,8 @@ fun addReferenceWorkflow(relation: ForwardRelation, schema: Schema): WorkflowDef
description = schema.childDescriptionInCreateRelation(parentClass, childClass, ignoreMissing = true)
mandatory = true
browserRoot = item.parentConnection
if (childClass.needsSecurityScopeValidation)
validWhen = matchesSecurityScope(item, directValidation)
}
}
}
Expand Down

0 comments on commit 6ef7f40

Please sign in to comment.