Merge pull request #787 from openziti/dont-allow-hash-at-on-attr

Don't allow hashtags or at symbols on role attributes. Fixes #786
This commit is contained in:
Paul Lorenz
2021-09-22 13:56:23 -04:00
committed by GitHub
4 changed files with 16 additions and 0 deletions
@@ -85,6 +85,7 @@ func (entity *EdgeRouter) SetValues(ctx *boltz.PersistContext) {
ctx.SetBool(FieldEdgeRouterIsVerified, entity.IsVerified)
ctx.SetStringP(FieldEdgeRouterHostname, entity.Hostname)
ctx.SetMap(FieldEdgeRouterProtocols, toStringInterfaceMap(entity.EdgeRouterProtocols))
store.validateRoleAttributes(entity.RoleAttributes, ctx.Bucket)
ctx.SetStringList(FieldRoleAttributes, entity.RoleAttributes)
ctx.SetBool(FieldEdgeRouterIsTunnelerEnabled, entity.IsTunnelerEnabled)
ctx.Bucket.PutMap(FieldEdgeRouterAppData, entity.AppData, ctx.FieldChecker, false)
@@ -67,6 +67,7 @@ func (entity *EdgeService) SetValues(ctx *boltz.PersistContext) {
store := ctx.Store.(*edgeServiceStoreImpl)
ctx.SetString(FieldName, entity.Name)
store.validateRoleAttributes(entity.RoleAttributes, ctx.Bucket)
ctx.SetStringList(FieldRoleAttributes, entity.RoleAttributes)
ctx.SetLinkedIds(EntityTypeConfigs, entity.Configs)
ctx.SetBool(FieldServiceEncryptionRequired, entity.EncryptionRequired)
+1
View File
@@ -160,6 +160,7 @@ func (entity *Identity) SetValues(ctx *boltz.PersistContext) {
ctx.Bucket.SetError(errors.New("cannot change type of router identity"))
}
}
store.validateRoleAttributes(entity.RoleAttributes, ctx.Bucket)
ctx.SetStringList(FieldRoleAttributes, entity.RoleAttributes)
ctx.SetInt32(FieldIdentityDefaultHostingPrecedence, int32(entity.DefaultHostingPrecedence))
ctx.SetInt32(FieldIdentityDefaultHostingCost, int32(entity.DefaultHostingCost))
+13
View File
@@ -79,6 +79,19 @@ func (self *roleAttributeChangeContext) addServicePolicyEvent(identityId, servic
self.addServiceEvent(self.tx, identityId, serviceId, eventType)
}
func (store *baseStore) validateRoleAttributes(attributes []string, holder errorz.ErrorHolder) {
for _, attr := range attributes {
if strings.HasPrefix(attr, "#") {
holder.SetError(errorz.NewFieldError("role attributes may not be prefixed with #", "roleAttributes", attr))
return
}
if strings.HasPrefix(attr, "@") {
holder.SetError(errorz.NewFieldError("role attributes may not be prefixed with @", "roleAttributes", attr))
return
}
}
}
func (store *baseStore) updateServicePolicyRelatedRoles(ctx *roleAttributeChangeContext, entityId []byte, newRoleAttributes []boltz.FieldTypeAndValue) {
cursor := ctx.rolesSymbol.GetStore().IterateIds(ctx.tx, ast.BoolNodeTrue)