From f457d1e04576fc4fc77bb4a49a546070843bb531 Mon Sep 17 00:00:00 2001 From: Rohan Vazarkar Date: Tue, 22 Oct 2024 16:04:36 -0400 Subject: [PATCH] chore: add test --- cmd/api/src/daemons/datapipe/convertors.go | 1 - packages/go/ein/ad_test.go | 72 ++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 packages/go/ein/ad_test.go diff --git a/cmd/api/src/daemons/datapipe/convertors.go b/cmd/api/src/daemons/datapipe/convertors.go index 949056d465..19b014386f 100644 --- a/cmd/api/src/daemons/datapipe/convertors.go +++ b/cmd/api/src/daemons/datapipe/convertors.go @@ -94,7 +94,6 @@ func convertDomainData(domain ein.Domain, converted *ConvertedData) { domainTrustData := ein.ParseDomainTrusts(domain) converted.RelProps = append(converted.RelProps, domainTrustData.TrustRelationships...) converted.NodeProps = append(converted.NodeProps, domainTrustData.ExtraNodeProps...) - } func convertGPOData(gpo ein.GPO, converted *ConvertedData) { diff --git a/packages/go/ein/ad_test.go b/packages/go/ein/ad_test.go new file mode 100644 index 0000000000..cf86ee425f --- /dev/null +++ b/packages/go/ein/ad_test.go @@ -0,0 +1,72 @@ +package ein_test + +import ( + "github.com/specterops/bloodhound/ein" + "github.com/specterops/bloodhound/graphschema/ad" + "github.com/stretchr/testify/assert" + "testing" +) + +func TestConvertObjectToNode_DomainInvalidProperties(t *testing.T) { + baseItem := ein.IngestBase{ + ObjectIdentifier: "ABC123", + Properties: map[string]any{ + "machineaccountquota": "1", + "minpwdlength": "1", + "pwdproperties": "1", + "pwdhistorylength": "1", + "lockoutthreshold": "1", + "expirepasswordsonsmartcardonlyaccounts": "false", + }, + Aces: nil, + IsDeleted: false, + IsACLProtected: false, + ContainedBy: ein.TypedPrincipal{}, + } + + result := ein.ConvertObjectToNode(baseItem, ad.Domain) + props := result.PropertyMap + assert.Contains(t, props, "machineaccountquota") + assert.Contains(t, props, "minpwdlength") + assert.Contains(t, props, "pwdproperties") + assert.Contains(t, props, "pwdhistorylength") + assert.Contains(t, props, "lockoutthreshold") + assert.Contains(t, props, "expirepasswordsonsmartcardonlyaccounts") + assert.Equal(t, 1, props["machineaccountquota"]) + assert.Equal(t, 1, props["minpwdlength"]) + assert.Equal(t, 1, props["pwdproperties"]) + assert.Equal(t, 1, props["pwdhistorylength"]) + assert.Equal(t, 1, props["lockoutthreshold"]) + assert.Equal(t, false, props["expirepasswordsonsmartcardonlyaccounts"]) + + baseItem = ein.IngestBase{ + ObjectIdentifier: "ABC123", + Properties: map[string]any{ + "machineaccountquota": 1, + "minpwdlength": 1, + "pwdproperties": 1, + "pwdhistorylength": 1, + "lockoutthreshold": 1, + "expirepasswordsonsmartcardonlyaccounts": false, + }, + Aces: nil, + IsDeleted: false, + IsACLProtected: false, + ContainedBy: ein.TypedPrincipal{}, + } + + result = ein.ConvertObjectToNode(baseItem, ad.Domain) + props = result.PropertyMap + assert.Contains(t, props, "machineaccountquota") + assert.Contains(t, props, "minpwdlength") + assert.Contains(t, props, "pwdproperties") + assert.Contains(t, props, "pwdhistorylength") + assert.Contains(t, props, "lockoutthreshold") + assert.Contains(t, props, "expirepasswordsonsmartcardonlyaccounts") + assert.Equal(t, 1, props["machineaccountquota"]) + assert.Equal(t, 1, props["minpwdlength"]) + assert.Equal(t, 1, props["pwdproperties"]) + assert.Equal(t, 1, props["pwdhistorylength"]) + assert.Equal(t, 1, props["lockoutthreshold"]) + assert.Equal(t, false, props["expirepasswordsonsmartcardonlyaccounts"]) +}