Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aggregate functions. #22

Open
steven-legg opened this issue May 20, 2024 · 4 comments
Open

Add aggregate functions. #22

steven-legg opened this issue May 20, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@steven-legg
Copy link

The proposal is to add XACML functions to compute the minimum, maximum, sum or average of a bag of values. These functions could be added to both XACML 3.0 and XACML 4.0.

The sum and average functions only make sense for data types that can be added, i.e., integer and double. The sum of integers would return an integer. The average of integers and the sum and average of doubles would return a double.

urn:oasis:names:tc:xacml:3.0:function:integer-sum
urn:oasis:names:tc:xacml:3.0:function:integer-average
urn:oasis:names:tc:xacml:3.0:function:double-sum
urn:oasis:names:tc:xacml:3.0:function:double-average

The minimum and maximum functions could be used with any data type that has an ordering relationship, i.e., integer, double, string, time, date and dateTime.

urn:oasis:names:tc:xacml:3.0:function:integer-minimum
urn:oasis:names:tc:xacml:3.0:function:integer-maximum
urn:oasis:names:tc:xacml:3.0:function:double-minimum
urn:oasis:names:tc:xacml:3.0:function:double-maximum
urn:oasis:names:tc:xacml:3.0:function:string-minimum
urn:oasis:names:tc:xacml:3.0:function:string-maximum
urn:oasis:names:tc:xacml:3.0:function:time-minimum
urn:oasis:names:tc:xacml:3.0:function:time-maximum
urn:oasis:names:tc:xacml:3.0:function:date-minimum
urn:oasis:names:tc:xacml:3.0:function:date-maximum
urn:oasis:names:tc:xacml:3.0:function:dateTime-minimum
urn:oasis:names:tc:xacml:3.0:function:dateTime-maximum
@steven-legg steven-legg added the enhancement New feature or request label May 20, 2024
@humantypo
Copy link

An interesting idea. Do you have some specific use cases in mind?

@steven-legg
Copy link
Author

I thought about adding aggregates in the Entities profile to match more of the capabilities of XPath but didn't have a need at the time. Now I might have one. I've been looking at the processing of NATO confidentiality labels (a structured type) where there is an original label and an optional succession label that overrides at a later time. The references don't specify if there can be more than one succession label, but the XSD allows it. The PEP converts the XML confidentiality labels to XACML entities. If multiple succession labels are allowed then I want to choose the activated one with the latest time. The dateTime-maximum function would let me determine this latest time and I can use the Select expression from the Entities profile to pick just the label with that time (or otherwise ignore the labels that don't have this time).

@steven-legg
Copy link
Author

The aggregate functions aren't defined if the input bag is empty. They could evaluate to Indeterminate in that case, though I don't like it.

The XPath aggregate functions avoid throwing an error by returning an empty sequence. We can't mix return data types, but we could have the functions return a bag that is either empty (because the input is empty) or contains a single value that is the computed result.

@steven-legg
Copy link
Author

Another alternative is to add a second argument that specifies the primitive return value if the bag is empty. The second argument has the same type as the return type and the type in the bag.

Examples:

<Apply  FunctionId="urn:oasis:names:tc:xacml:3.0:function:double-average">
  <AttributeDesignator
    Category="urn:oasis:names:tc:xacml:3.0:attribute-category:environment"
    AttributeId="http://example.com/threat-levels"
    DataType="http://www.w3.org/2001/XMLSchema#double"  MustBePresent="false"/>
  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#double"
    >0.5</AttributeValue>
</Apply>

<Apply  FunctionId="urn:oasis:names:tc:xacml:3.0:function:dateTime-minimum">
  <AttributeDesignator
    Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource"
    AttributeId="http://example.com/activation-times"
    DataType="http://www.w3.org/2001/XMLSchema#dateTime"  MustBePresent="false"/>
  <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#dateTime"
    >2030-01-01T12:00:00Z</AttributeValue>
</Apply>

The second argument should only be evaluated if the first argument is empty. If a policy writer really wants the result to be Indeterminate in that case then they can purposely make the second argument evaluate to Indeterminate without disrupting the non-empty case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants