Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
prevent collective super/non-collective sub, collective OC members
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Coretta authored and Jesse Coretta committed Aug 8, 2024
1 parent 2767303 commit 0bca188
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
16 changes: 13 additions & 3 deletions at.go
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,7 @@ compliant per the required clauses of [§ 4.1.2 of RFC 4512]:
- Numeric OID must be present and valid
- Specified EQUALITY, SUBSTR and ORDERING [MatchingRule] instances must be COMPLIANT
- Specified [LDAPSyntax] MUST be COMPLIANT
- [AttributeType], if not COLLECTIVE, cannot extend from a COLLECTIVE super type
Additional consideration is given to RFC 3671 in that an [AttributeType]
shall not be both COLLECTIVE and SINGLE-VALUE'd.
Expand Down Expand Up @@ -1672,14 +1673,23 @@ func (r AttributeType) Compliant() bool {
}
}

collective := r.Collective()
sup := r.schema().AttributeTypes().get(r.SuperType().NumericOID())
if !sup.IsZero() && !sup.Compliant() {
return false
if !sup.IsZero() {
if sup.Collective() && !collective {
// Non collective types cannot derive from
// collective super types.
return false
}

if !sup.Compliant() {
return false
}
}

// Any combination of SV/C is permitted
// EXCEPT for BOTH. See RFC 3671.
return !(r.SingleValue() && r.Collective())
return !(r.SingleValue() && collective)
}

/*
Expand Down
5 changes: 3 additions & 2 deletions oc.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ compliant per the required clauses of [§ 4.1.1 of RFC 4512]:
- Numeric OID must be present and valid
- MUST and MAY clause [AttributeTypes] are compliant
- MUST and MAY clause contains no Collective [AttributeType] instances
[§ 4.1.1 of RFC 4512]: https://rfc-editor.org/rfc/rfc4512.html#section-4.1.1
*/
Expand All @@ -518,13 +519,13 @@ func (r ObjectClass) Compliant() bool {
)

for i := 0; i < must.Len(); i++ {
if !must.Index(i).Compliant() {
if !must.Index(i).Compliant() || must.Index(i).Collective() {
return false
}
}

for i := 0; i < may.Len(); i++ {
if !may.Index(i).Compliant() {
if !may.Index(i).Compliant() || may.Index(i).Collective() {
return false
}
}
Expand Down

0 comments on commit 0bca188

Please sign in to comment.