Skip to content

Commit

Permalink
Updating explorer behavior & theme structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
Macmod committed Mar 16, 2024
1 parent bb0dc69 commit 4e5a640
Show file tree
Hide file tree
Showing 7 changed files with 345 additions and 360 deletions.
39 changes: 18 additions & 21 deletions ace.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
permsPanel *tview.Flex
normalPermsForm *tview.Form
objectPermsForm *tview.Form
propertyPermsForm *tview.Form
propertyPermsForm *XForm
controlPermsForm *tview.Form
validatedWritePermsForm *tview.Form
newAceTable *tview.Table
Expand Down Expand Up @@ -286,7 +286,7 @@ func loadDeleteAceForm(aceIdx int) {

// Forms
func getNormalPermsForm(mask int, checkedFull func(bool), checkedRight func(bool, int)) *tview.Form {
form := tview.NewForm().SetItemPadding(0)
form := NewXForm()

form.AddCheckbox("Full control", false, checkedFull)

Expand All @@ -298,55 +298,54 @@ func getNormalPermsForm(mask int, checkedFull func(bool), checkedRight func(bool
mask&rightMask != 0,
func(checked bool) {
checkedRight(checked, curRightMask)
}).
SetFieldBackgroundColor(tcell.GetColor("black"))
})
}

return form
return form.SetItemPadding(0)
}

func getObjectPermsForm(object int, objectRight int, selectedObject func(string, int), selectedRight func(string, int)) *tview.Form {
form := tview.NewForm().
form := NewXForm().
AddDropDown("Object Class", classVals,
object, selectedObject).
SetFieldBackgroundColor(tcell.GetColor("black")).
SetFieldBackgroundColor(fieldBackgroundColor).
AddDropDown(
"Right", []string{"Create Child", "Delete Child", "Create & Delete Child"},
objectRight, selectedRight).
SetFieldBackgroundColor(tcell.GetColor("black"))
SetFieldBackgroundColor(fieldBackgroundColor)

return form
}

func getPropertyPermsForm(property int, propertyRight int, selectedProperty func(string, int), selectedRight func(string, int)) *tview.Form {
form := tview.NewForm()
func getPropertyPermsForm(property int, propertyRight int, selectedProperty func(string, int), selectedRight func(string, int)) *XForm {
form := NewXForm()
form.
AddDropDown(
"Property", attributesVals, property, selectedProperty).
SetFieldBackgroundColor(tcell.GetColor("black")).
SetFieldBackgroundColor(fieldBackgroundColor).
AddDropDown(
"Right",
[]string{"Read Property", "Write Property", "Read & Write Property"},
propertyRight, selectedRight).
SetFieldBackgroundColor(tcell.GetColor("black"))
SetFieldBackgroundColor(fieldBackgroundColor)
return form
}

func getControlPermsForm(controlRight int, selectedRight func(string, int)) *tview.Form {
form := tview.NewForm().
form := NewXForm().
AddDropDown(
"Extended Right", extendedVals,
controlRight, selectedRight).
SetFieldBackgroundColor(tcell.GetColor("black"))
SetFieldBackgroundColor(fieldBackgroundColor)
return form
}

func getValidatedWritePermsForm(validatedWriteRight int, selectedRight func(string, int)) *tview.Form {
form := tview.NewForm().
form := NewXForm().
AddDropDown(
"Validated Write", validatedWriteRightsVals,
validatedWriteRight, selectedRight).
SetFieldBackgroundColor(tcell.GetColor("black"))
SetFieldBackgroundColor(fieldBackgroundColor)
return form
}

Expand Down Expand Up @@ -584,7 +583,7 @@ func loadAceEditorForm(aceIdx int) {
SetTitle("Permissions").
SetBorder(true)

headerForm := tview.NewForm().SetItemPadding(0)
headerForm := NewXForm()
headerForm.
AddDropDown(
"ACE Kind",
Expand Down Expand Up @@ -715,15 +714,12 @@ func loadAceEditorForm(aceIdx int) {

updateACETypeCell(newAceTable, getType(newObjectGuid, newAllowOrDeny))
}).
SetFieldBackgroundColor(tcell.GetColor("black")).
AddInputField("Principal", selectedPrincipal, 0, nil, nil).
SetFieldBackgroundColor(tcell.GetColor("black")).
AddDropDown("Type", typeOptions, selectedType,
func(option string, optionIdx int) {
newAllowOrDeny = (optionIdx == 0)
updateACETypeCell(newAceTable, getType(newObjectGuid, newAllowOrDeny))
}).
SetFieldBackgroundColor(tcell.GetColor("black")).
AddCheckbox("No Propagate", selectedNoPropagate, func(checked bool) {
if checked {
newACEFlags |= sdl.AceFlagsMap["NO_PROPAGATE_INHERIT_ACE"]
Expand Down Expand Up @@ -767,9 +763,10 @@ func loadAceEditorForm(aceIdx int) {
updateFlagsCell(newAceTable, getFlags(newObjectGuid, newInheritedGuid))
updateACEFlagsCell(newAceTable, newACEFlags)
}).
SetFieldBackgroundColor(tcell.GetColor("black"))
SetFieldBackgroundColor(fieldBackgroundColor)

headerForm.
SetItemPadding(0).
SetTitle("Options").
SetBorder(true)

Expand Down
37 changes: 37 additions & 0 deletions cache.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"sync"

"github.com/go-ldap/ldap/v3"
)

type EntryCache struct {
entries map[string]*ldap.Entry
lock sync.Mutex
}

func (sc *EntryCache) Delete(key string) {
sc.lock.Lock()
delete(sc.entries, key)
sc.lock.Unlock()
}

func (sc *EntryCache) Clear() {
sc.lock.Lock()
clear(sc.entries)
sc.lock.Unlock()
}

func (sc *EntryCache) Add(key string, val *ldap.Entry) {
sc.lock.Lock()
sc.entries[key] = val
sc.lock.Unlock()
}

func (sc *EntryCache) Get(key string) (*ldap.Entry, bool) {
sc.lock.Lock()
defer sc.lock.Unlock()
entry, ok := sc.entries[key]
return entry, ok
}
44 changes: 25 additions & 19 deletions dacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ func initDaclPage(includeCurSchema bool) {

objectNameInputDacl = tview.NewInputField()
objectNameInputDacl.
SetFieldBackgroundColor(tcell.GetColor("black")).
SetTitle("Object (sAMAccountName or DN)").
SetPlaceholder("Type an object's sAMAccountName or DN").
SetPlaceholderStyle(placeholderStyle).
SetPlaceholderTextColor(placeholderTextColor).
SetFieldBackgroundColor(fieldBackgroundColor).
SetTitle("Object").
SetBorder(true)

acePanel = tview.NewList()
Expand All @@ -47,27 +50,23 @@ func initDaclPage(includeCurSchema bool) {
daclOwnerTextView = tview.NewTextView()
daclOwnerTextView.
SetTextAlign(tview.AlignCenter).
SetBackgroundColor(tcell.GetColor("black")).
SetTitle("Owner").
SetBorder(true)
aceMask = tview.NewTextView()
aceMask.
SetTextAlign(tview.AlignCenter).
SetBackgroundColor(tcell.GetColor("black")).
SetTitle("ACE Mask").
SetBorder(true)

aceMaskBinary = tview.NewTextView()
aceMaskBinary.
SetTextAlign(tview.AlignCenter).
SetBackgroundColor(tcell.GetColor("black")).
SetTitle("ACE Mask (Binary)").
SetBorder(true)

controlFlagsTextView = tview.NewTextView()
controlFlagsTextView.
SetTextAlign(tview.AlignCenter).
SetBackgroundColor(tcell.GetColor("black")).
SetTitle("ControlFlags").
SetBorder(true)

Expand Down Expand Up @@ -345,20 +344,11 @@ func daclRotateFocus() {
}

func loadChangeOwnerForm() {
changeOwnerForm := tview.NewForm()
changeOwnerForm.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Key() == tcell.KeyEscape {
app.SetRoot(appPanel, true).SetFocus(daclEntriesPanel)
return nil
}
return event
})

changeOwnerForm := NewXForm()
changeOwnerForm.
AddTextView("Owner", ownerPrincipal, 0, 1, true, true).
AddTextView("Group", groupPrincipal, 0, 1, true, true).
AddInputField("New Owner", "", 0, nil, nil).
SetFieldBackgroundColor(tcell.GetColor("black")).
AddInputField("New Owner SID", "", 0, nil, nil).
AddInputField("New Group SID", "", 0, nil, nil)

Expand Down Expand Up @@ -444,6 +434,17 @@ func loadChangeOwnerForm() {
changeOwnerForm.
SetTitle("Change DACL Owner (" + object + ")").
SetBorder(true)
changeOwnerForm.
SetButtonBackgroundColor(formButtonBackgroundColor).
SetButtonTextColor(formButtonTextColor).
SetButtonActivatedStyle(formButtonActivatedStyle)
changeOwnerForm.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
if event.Key() == tcell.KeyEscape {
app.SetRoot(appPanel, true).SetFocus(daclEntriesPanel)
return nil
}
return event
})

app.SetRoot(changeOwnerForm, true).SetFocus(changeOwnerForm)
}
Expand All @@ -453,8 +454,7 @@ func loadChangeControlFlagsForm() {
return
}

updateControlFlagsForm := tview.NewForm()
updateControlFlagsForm.SetItemPadding(0)
updateControlFlagsForm := NewXForm()

controlFlags := sd.GetControl()
checkboxState := controlFlags
Expand Down Expand Up @@ -484,7 +484,7 @@ func loadChangeControlFlagsForm() {
if flagPreview != nil {
flagPreview.SetText(strconv.Itoa(checkboxState))
}
}).SetFieldBackgroundColor(tcell.GetColor("black"))
}).SetFieldBackgroundColor(fieldBackgroundColor)
}

updateControlFlagsForm.
Expand All @@ -508,6 +508,12 @@ func loadChangeControlFlagsForm() {
})

updateControlFlagsForm.SetTitle("ControlFlags Editor").SetBorder(true)
updateControlFlagsForm.
SetButtonBackgroundColor(formButtonBackgroundColor).
SetButtonTextColor(formButtonTextColor).
SetButtonActivatedStyle(formButtonActivatedStyle)
updateControlFlagsForm.SetItemPadding(0)

app.SetRoot(updateControlFlagsForm, true).SetFocus(updateControlFlagsForm)
}

Expand Down
Loading

0 comments on commit 4e5a640

Please sign in to comment.