condition

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package condition implements the conditional-expression codec used by conditional (callback) ACEs, as specified in MS-DTYP 2.4.4.17 and its subsections (2.4.4.17.1 Conditional ACE Expressions, and the Literal / Attribute / Relational / Logical operator token tables).

A conditional expression lives in the ApplicationData member of a callback ACE, prefixed by the 4-byte ACE_CONDITION_SIGNATURE "artx" (0x61 0x72 0x74 0x78). The remainder is a series of tokens in postfix (reverse Polish) order. This package converts between the SDDL textual form of a conditional expression (e.g. `(@User.Title=="PM" && @User.Division=="Finance")`) and that binary form.

text -> Marshal   -> ApplicationData bytes ("artx" + tokens + DWORD padding)
bytes -> Unmarshal -> text

All multibyte integers (including UTF-16 characters) are stored least-significant byte first, and the encoded expression is padded with 0x00 to a DWORD (4-byte) boundary.

Index

Constants

This section is empty.

Variables

View Source
var ACE_CONDITION_SIGNATURE = []byte{0x61, 0x72, 0x74, 0x78}

ACE_CONDITION_SIGNATURE marks a callback ACE's ApplicationData as a conditional expression (MS-DTYP 2.4.4.17.1).

Functions

func Encode

func Encode(root Node) ([]byte, error)

Encode serializes an AST into binary ApplicationData.

func IsConditional

func IsConditional(applicationData []byte) bool

IsConditional reports whether applicationData carries a conditional expression, i.e. whether it begins with the ACE_CONDITION_SIGNATURE.

func Marshal

func Marshal(expr string) ([]byte, error)

Marshal parses an SDDL conditional-expression string and returns the binary ApplicationData encoding (signature + postfix token stream + DWORD padding). The input may optionally be wrapped in a single outer pair of parentheses, as it appears in an ACE string.

func Serialize

func Serialize(root Node) string

Serialize converts an AST back into an SDDL conditional-expression string (without an outer pair of parentheses).

func Unmarshal

func Unmarshal(applicationData []byte) (string, error)

Unmarshal decodes binary conditional-expression ApplicationData into its SDDL textual form (without an outer pair of parentheses).

Types

type Attribute

type Attribute struct {
	Token byte // one of tokenLocalAttr/tokenUserAttr/tokenResourceAttr/tokenDeviceAttr/tokenTokenAttr
	Name  string
}

Attribute is an attribute-name operand (local or @User./@Resource./@Device.).

type BinaryOp

type BinaryOp struct {
	Op          byte
	Left, Right Node
}

BinaryOp applies a binary operator (relational or logical) to two operands.

type Composite

type Composite struct{ Items []Node }

Composite is a braced set of literals ("{a,b,c}").

type IntLiteral

type IntLiteral struct {
	Value int64
	Width byte
	Base  byte
	Sign  byte
}

IntLiteral is an integer literal. Width is the token byte-code (int8..int64), Base and Sign preserve the textual representation for lossless round-tripping.

type Node

type Node interface {
	// contains filtered or unexported methods
}

Node is a node in a conditional-expression AST.

func Decode

func Decode(data []byte) (Node, error)

Decode parses binary ApplicationData into an AST.

func Parse

func Parse(expr string) (Node, error)

Parse converts an SDDL conditional-expression string into an AST.

type OctetLiteral

type OctetLiteral struct{ Value []byte }

OctetLiteral is an octet (byte) string literal (SDDL "#hex" form).

type SIDLiteral

type SIDLiteral struct{ SID string }

SIDLiteral is a SID literal (SDDL "SID(...)" form).

type StringLiteral

type StringLiteral struct{ Value string }

StringLiteral is a Unicode string literal.

type UnaryOp

type UnaryOp struct {
	Op      byte
	Operand Node
}

UnaryOp applies a unary operator (logical !, Exists/Not_Exists, or a Member_of-family operator) to a single operand.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL