Skip to content

Commit 2e2dbdc

Browse files
authored
Merge pull request #10 from p0dalirius/added-IsInherited()-and-hasflag
[enhancement] Added ace.IsInherited() and ace.HasFlag() functions
2 parents 862d085 + 5c67398 commit 2e2dbdc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ace/AccessControlEntry.go

+22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ace
22

33
import (
44
"fmt"
5+
"slices"
56
"strings"
67

78
"github.com/p0dalirius/winacl/identity"
@@ -412,6 +413,27 @@ func (ace *AccessControlEntry) Parse(RawBytes []byte) {
412413
ace.RawBytes = ace.RawBytes[:ace.RawBytesSize]
413414
}
414415

416+
// IsInherited checks whether the Access Control Entry (ACE) is inherited
417+
// from a parent object. This is determined by checking if the ACE_FLAG_INHERITED
418+
// is present in the Flags.Values slice of the ACE header.
419+
//
420+
// Returns:
421+
// - bool: true if the ACE is inherited, false otherwise.
422+
func (ace *AccessControlEntry) IsInherited() bool {
423+
return slices.Contains(ace.Header.Flags.Values, ACE_FLAG_INHERITED)
424+
}
425+
426+
// HasFlag checks if a specific flag is set within the ACE's flags.
427+
//
428+
// Parameters:
429+
// - flag: The integer value of the flag to check.
430+
//
431+
// Returns:
432+
// - bool: true if the specified flag is set, false otherwise.
433+
func (ace *AccessControlEntry) HasFlag(flag uint8) bool {
434+
return slices.Contains(ace.Header.Flags.Values, flag)
435+
}
436+
415437
func (ace *AccessControlEntry) Describe(indent int) {
416438
indentPrompt := strings.Repeat(" │ ", indent)
417439

0 commit comments

Comments
 (0)