seeding

package
v0.0.0-...-6aee27a Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var APIKeyHarry1 = newAPIKey(UserHarry.ID, "harry-abc", []byte{0x01, 0x02, 0x03})
View Source
var APIKeyHarry2 = newAPIKey(UserHarry.ID, "harry-123", []byte{0x11, 0x12, 0x13})
View Source
var APIKeyNick = newAPIKey(UserHeadlessNick.ID, "gR6nVtaQmp2SvzIqLUWdedDk", []byte{

	0x5A, 0xFB, 0x6F, 0xC4, 0x56, 0x89, 0x4B, 0x49, 0x8F, 0xB3, 0xCD, 0xA7, 0x0B, 0x3A, 0x9A, 0x98,
	0x8F, 0x9B, 0x38, 0x65, 0xE9, 0xAB, 0xB1, 0x08, 0x42, 0x18, 0x38, 0x50, 0x3F, 0x27, 0xC5, 0x2E,
	0x78, 0xE3, 0xC5, 0xC6, 0xF4, 0xDD, 0x20, 0x34, 0x07, 0x1E, 0x24, 0x60, 0x4B, 0x3D, 0xD0, 0x80,
	0xDE, 0x40, 0x33, 0x0B, 0x83, 0x1D, 0x51, 0x21, 0xE7, 0x28, 0x22, 0x7F, 0x95, 0x90, 0xFE, 0xF8,
})
View Source
var APIKeyRon1 = newAPIKey(UserRon.ID, "ron-abc", []byte{0x01, 0x02, 0x03})
View Source
var APIKeyRon2 = newAPIKey(UserRon.ID, "ron-123", []byte{0x11, 0x12, 0x13})
View Source
var AddCedricToHufflepuff = newUserGroupMapping(UserCedric, UserGroupHufflepuff)
View Source
var AddChoToRavenclaw = newUserGroupMapping(UserCho, UserGroupRavenclaw)
View Source
var AddFleurToHufflepuff = newUserGroupMapping(UserFleur, UserGroupHufflepuff)
View Source
var AddGinnyToGryffindor = newUserGroupMapping(UserGinny, UserGroupGryffindor)
View Source
var AddHarryToGryffindor = newUserGroupMapping(UserHarry, UserGroupGryffindor)
View Source
var AddHermioneToGryffindor = newUserGroupMapping(UserHermione, UserGroupGryffindor)
View Source
var AddLuciusToSlytherin = newUserGroupMapping(UserLucius, UserGroupSlytherin)
View Source
var AddMalfoyToSlytherin = newUserGroupMapping(UserDraco, UserGroupSlytherin)
View Source
var AddRonToGryffindor = newUserGroupMapping(UserRon, UserGroupGryffindor)
View Source
var AddSnapeToSlytherin = newUserGroupMapping(UserSnape, UserGroupSlytherin)
View Source
var AddViktorToRavenclaw = newUserGroupMapping(UserViktor, UserGroupRavenclaw)
View Source
var BehavioralFindingCategory = newHpFindingCategory("Behavioral", false)
View Source
var CommonTagWhatCoS = newHPTag(OpChamberOfSecrets.ID, "What", "lightBlue")
View Source
var CommonTagWhatGoF = newHPTag(OpGobletOfFire.ID, "What", "lightBlue")
View Source
var CommonTagWhatSS = newHPTag(OpSorcerersStone.ID, "What", "lightBlue")
View Source
var CommonTagWhenCoS = newHPTag(OpChamberOfSecrets.ID, "When", "lightIndigo")
View Source
var CommonTagWhenGoF = newHPTag(OpGobletOfFire.ID, "When", "lightIndigo")
View Source
var CommonTagWhenSS = newHPTag(OpSorcerersStone.ID, "When", "lightIndigo")
View Source
var CommonTagWhereCoS = newHPTag(OpChamberOfSecrets.ID, "Where", "lightGreen")
View Source
var CommonTagWhereGoF = newHPTag(OpGobletOfFire.ID, "Where", "lightGreen")
View Source
var CommonTagWhereSS = newHPTag(OpSorcerersStone.ID, "Where", "lightGreen")
View Source
var CommonTagWhoCoS = newHPTag(OpChamberOfSecrets.ID, "Who", "lightRed")
View Source
var CommonTagWhoGoF = newHPTag(OpGobletOfFire.ID, "Who", "lightRed")
View Source
var CommonTagWhoSS = newHPTag(OpSorcerersStone.ID, "Who", "lightRed")

Common tags are used to test migrating content from one operation to another

View Source
var CommonTagWhyCoS = newHPTag(OpChamberOfSecrets.ID, "Why", "lightYellow")
View Source
var CommonTagWhyGoF = newHPTag(OpGobletOfFire.ID, "Why", "lightYellow")
View Source
var CommonTagWhySS = newHPTag(OpSorcerersStone.ID, "Why", "lightYellow")
View Source
var DefaultTagWhat = newDefaultHPTag("What", "lightBlue")
View Source
var DefaultTagWhen = newDefaultHPTag("When", "lightIndigo")
View Source
var DefaultTagWhere = newDefaultHPTag("Where", "lightGreen")
View Source
var DefaultTagWho = newDefaultHPTag("Who", "lightRed")
View Source
var DefaultTagWhy = newDefaultHPTag("Why", "lightYellow")
View Source
var DeletedCategory = newHpFindingCategory("I was deleted", true)
View Source
var DemoServiceWorker = newHPServiceWorker("Demo", `{ "type": "web",  "version": 1, "url": "http://demo:3001/process" }`)
View Source
var DetectionGapFindingCategory = newHpFindingCategory("Detection Gap", false)
View Source
var EnterpriseFindingCategory = newHpFindingCategory("Enterprise", false)
View Source
var EviDobby = newHPEvidence(OpChamberOfSecrets.ID, UserHarry.ID, "seed_dobby", "an elf?", "image", 0, nil)
View Source
var EviDursleys = newHPEvidence(OpSorcerersStone.ID, UserHarry.ID, "seed_dursleys", "Family of self-centered muggles + Harry", "image", 0, &timeNow)
View Source
var EviEntryForm = newHPEvidence(OpGobletOfFire.ID, UserCedric.ID, "seed_entry", "Cedric's entry form for Triwizard competition", "codeblock", 0, nil)
View Source
var EviFlyingCar = newHPEvidence(OpChamberOfSecrets.ID, UserHarry.ID, "seed_car", "A Car that flies", "image", 0, &timeNow)
View Source
var EviHeadlessHuntApplication = newHPEvidence(OpChamberOfSecrets.ID, UserRon.ID, "seed_py_aoc201717", "This group is very particular", "codeblock", 0, &timeNow)
View Source
var EviLevitateSpell = newHPEvidence(OpSorcerersStone.ID, UserHarry.ID, "seed_md_levitate", "Documented Levitation Spell effects", "codeblock", 0, &timeNow)
View Source
var EviMetaDobby = newHPEviMetadata(EviDobby.ID, "color-averager", "rgb(74, 51, 32)\n#4a3320\nhsl(27, 40%, 21%)", nil, helpers.PTrue(), 0)
View Source
var EviMetaDursleys = newHPEviMetadata(EviDursleys.ID, "color-averager", "rgb(65, 65, 65)\n#414141\nhsl(0, 0%, 25%)", nil, helpers.PTrue(), 0)
View Source
var EviMetaEntryForm = newHPEviMetadata(EviEntryForm.ID, "run-result", "(No output)", nil, helpers.PTrue(), 0)
View Source
var EviMetaEntryFormTwo = newHPEviMetadata(EviEntryForm.ID, "wc -l", "13 seed_entry", nil, helpers.PTrue(), 0)
View Source
var EviMetaFlyingCar = newHPEviMetadata(EviFlyingCar.ID, "color-averager", "rgb(106, 109, 84)\n#6a6d54\nhsl(67, 13%, 38%)", evidencemetadata.StatusCompleted.Ptr(), helpers.PTrue(), 0)
View Source
var EviMetaHeadlessHuntApplication = newHPEviMetadata(EviHeadlessHuntApplication.ID, "run-result", "41797835\nelapsed time (seconds): 3.772843360900879", nil, helpers.PTrue(), 0)
View Source
var EviMetaLevitateSpell = newHPEviMetadata(EviLevitateSpell.ID, "wc -l", "12 seed_md_levitate", nil, helpers.PTrue(), 0)
View Source
var EviMetaMirrorOfErised = newHPEviMetadata(EviMirrorOfErised.ID, "color-averager", "rgb(111, 77, 14)\n#6f4d0e\nhsl(39, 78%, 25%)", nil, helpers.PTrue(), 0)
View Source
var EviMetaMoaningMyrtle = newHPEviMetadata(EviMoaningMyrtle.ID, "color-averager", "rgb(118, 103, 102)\n#766766\nhsl(4, 7%, 43%)", nil, helpers.PTrue(), 0)
View Source
var EviMetaPetrifiedHermione = newHPEviMetadata(EviPetrifiedHermione.ID, "color-averager", "rgb(162, 104, 101)\n#a26865\nhsl(3, 25%, 52%)", nil, helpers.PTrue(), 0)
View Source
var EviMetaPolyjuice = newHPEviMetadata(EviPolyjuice.ID, "wc -l", "13 seed_juice", nil, helpers.PTrue(), 0)
View Source
var EviMetaRulesForQuidditch = newHPEviMetadata(EviRulesForQuidditch.ID, "run-result", "Last floor reached: 138 \n Step on which basement is reached (first time): 1771", nil, helpers.PTrue(), 0)
View Source
var EviMetaRulesForQuidditchTwo = newHPEviMetadata(EviRulesForQuidditch.ID, "wc-l", "33 main.rs", nil, helpers.PTrue(), 0)
View Source
var EviMetaSpiderAragog = newHPEviMetadata(EviSpiderAragog.ID, "color-averager", "rgb(189, 156, 146)\n#bd9c92\nhsl(14, 25%, 66%)", nil, helpers.PTrue(), 0)
View Source
var EviMetaTomRiddlesDiary = newHPEviMetadata(EviTomRiddlesDiary.ID, "run-result", "All keys found by index:  19968", nil, helpers.PTrue(), 0)
View Source
var EviMetaTomRiddlesDiaryTwo = newHPEviMetadata(EviTomRiddlesDiary.ID, "wc -l", "98 main.go", nil, helpers.PTrue(), 0)
View Source
var EviMetaTristateTrophy = newHPEviMetadata(EviTristateTrophy.ID, "color-averager", "rgb(182, 184, 183)\n#b6b8b7\nhsl(150, 1%, 72%)", nil, helpers.PTrue(), 0)
View Source
var EviMetaWarewolf = newHPEviMetadata(EviWarewolf.ID, "duration", "348.163058815", nil, helpers.PTrue(), 0)
View Source
var EviMetaWarewolfOther = newHPEviMetadata(EviWarewolf.ID, "color-averager", "Yo, I can't process this", nil, helpers.PFalse(), 0)
View Source
var EviMetaWhompingWillow = newHPEviMetadata(EviWhompingWillow.ID, "color-averager", "rgb(115, 109, 81)\n#736d51\nhsl(49, 17%, 38%)", nil, helpers.PTrue(), 0)
View Source
var EviMetaWizardDance = newHPEviMetadata(EviWizardDance.ID, "color-averager", "rgb(22, 19, 2nil, 0)\n#161314\nhsl(340, 7%, 8%)", nil, helpers.PTrue(), 0)
View Source
var EviMirrorOfErised = newHPEvidence(OpSorcerersStone.ID, UserHarry.ID, "seed_mirror", "Mysterious mirror that shows you your deepest desires", "image", 0, nil)
View Source
var EviMoaningMyrtle = newHPEvidence(OpChamberOfSecrets.ID, UserHarry.ID, "seed_myrtle", "She's very sad", "image", 0, nil)
View Source
var EviPetrifiedHermione = newHPEvidence(OpChamberOfSecrets.ID, UserHarry.ID, "seed_statue", "Strangely real-looking statue", "image", 0, &timeNow)
View Source
var EviPolyjuice = newHPEvidence(OpGobletOfFire.ID, UserAlastor.ID, "seed_juice", "DIY instructions for Polyjuice Potion", "codeblock", 0, &timeNow)
View Source
var EviRulesForQuidditch = newHPEvidence(OpSorcerersStone.ID, UserHarry.ID, "seed_rs_aoc201501", "Complex rules for a simple game", "codeblock", 0, &timeNow)
View Source
var EviSpiderAragog = newHPEvidence(OpChamberOfSecrets.ID, UserHagrid.ID, "seed_aragog", "Just a big spider", "image", 0, nil)
View Source
var EviTomRiddlesDiary = newHPEvidence(OpChamberOfSecrets.ID, UserHarry.ID, "seed_go_aoc201614", "What's a Horcrux?", "codeblock", 0, &timeNow)
View Source
var EviTristateTrophy = newHPEvidence(OpGobletOfFire.ID, UserHarry.ID, "seed_trophy", "First Triwizard Champion Trophy", "image", 0, nil)
View Source
var EviWarewolf = newHPEvidence(OpGobletOfFire.ID, UserViktor.ID, "seed_wolf", "Strangely real-looking statue", "terminal-recording", 0, &timeNow)
View Source
var EviWhompingWillow = newHPEvidence(OpChamberOfSecrets.ID, UserHarry.ID, "seed_tree", "Don't get too close", "image", 0, &timeNow)
View Source
var EviWizardDance = newHPEvidence(OpGobletOfFire.ID, UserCho.ID, "seed_dance", "Advertising for the Triwizard Dance", "image", 0, &timeNow)
View Source
var FindingBook2CGI = newHPFinding(OpChamberOfSecrets.ID, "find-uuid-cgi", &SomeOtherFindingCategory.ID, "this looks fake", "I'm not entirely sure this is all above board", &noLink)
View Source
var FindingBook2Magic = newHPFinding(OpChamberOfSecrets.ID, "find-uuid-b2magic", &SomeFindingCategory.ID, "lots o' magic", "Magic plagues Harry's life", nil)
View Source
var FindingBook2Robes = newHPFinding(OpChamberOfSecrets.ID, "find-uuid-robes", nil, "Robes for all seasons", "Turns out there's only one kind of robe.", &spiderLink)
View Source
var FindingBook2SpiderFear = newHPFinding(OpChamberOfSecrets.ID, "find-uuid-spider", &SomeFindingCategory.ID, "how to scare spiders", "Who would have thought?", &spiderLink)
View Source
var HarryPotterSeedData = Seeder{
	FindingCategories: []models.FindingCategory{
		ProductFindingCategory, NetworkFindingCategory, EnterpriseFindingCategory, VendorFindingCategory, BehavioralFindingCategory, DetectionGapFindingCategory,
		DeletedCategory, SomeFindingCategory, SomeOtherFindingCategory,
	},
	Users: []models.User{UserHarry, UserRon, UserGinny, UserHermione, UserNeville, UserSeamus, UserDraco, UserSnape, UserDumbledore, UserHagrid, UserTomRiddle, UserHeadlessNick,
		UserCedric, UserFleur, UserViktor, UserAlastor, UserMinerva, UserLucius, UserSirius, UserPeter, UserParvati, UserPadma, UserCho,
	},
	UserGroups: []models.UserGroup{
		UserGroupGryffindor, UserGroupHufflepuff, UserGroupRavenclaw, UserGroupSlytherin, UserGroupOtherHouse,
	},
	UserGroupMaps: []models.UserGroupMap{
		AddHarryToGryffindor, AddRonToGryffindor, AddGinnyToGryffindor, AddHermioneToGryffindor,
		AddMalfoyToSlytherin, AddSnapeToSlytherin, AddLuciusToSlytherin,
		AddCedricToHufflepuff, AddFleurToHufflepuff,
		AddChoToRavenclaw, AddViktorToRavenclaw,
	},
	Operations: []models.Operation{OpSorcerersStone, OpChamberOfSecrets, OpPrisonerOfAzkaban, OpGobletOfFire, OpOrderOfThePhoenix, OpHalfBloodPrince, OpDeathlyHallows},
	Tags: []models.Tag{
		TagFamily, TagFriendship, TagHome, TagLoyalty, TagCourage, TagGoodVsEvil, TagSupernatural,
		TagMercury, TagVenus, TagEarth, TagMars, TagJupiter, TagSaturn, TagNeptune,

		CommonTagWhoSS, CommonTagWhatSS, CommonTagWhereSS, CommonTagWhenSS, CommonTagWhySS,
		CommonTagWhoCoS, CommonTagWhatCoS, CommonTagWhereCoS, CommonTagWhenCoS, CommonTagWhyCoS,
		CommonTagWhoGoF, CommonTagWhatGoF, CommonTagWhereGoF, CommonTagWhenGoF, CommonTagWhyGoF,
	},
	DefaultTags: []models.DefaultTag{
		DefaultTagWho, DefaultTagWhat, DefaultTagWhere, DefaultTagWhen, DefaultTagWhy,
	},
	APIKeys: []models.APIKey{
		APIKeyHarry1, APIKeyHarry2,
		APIKeyRon1, APIKeyRon2,
		APIKeyNick,
	},
	UserOpPrefMap: []models.UserOperationPreferences{
		newUserOperationPreferences(UserRon, OpChamberOfSecrets, true),
		newUserOperationPreferences(UserDumbledore, OpGobletOfFire, true),

		newUserOperationPreferences(UserDraco, OpChamberOfSecrets, true),
	},
	UserOpMap: []models.UserOperationPermission{

		newUserOpPermission(UserHarry, OpSorcerersStone, policy.OperationRoleAdmin),
		newUserOpPermission(UserRon, OpSorcerersStone, policy.OperationRoleWrite),
		newUserOpPermission(UserSeamus, OpSorcerersStone, policy.OperationRoleWrite),
		newUserOpPermission(UserHermione, OpSorcerersStone, policy.OperationRoleRead),
		newUserOpPermission(UserNeville, OpSorcerersStone, policy.OperationRoleWrite),

		newUserOpPermission(UserRon, OpChamberOfSecrets, policy.OperationRoleAdmin),
		newUserOpPermission(UserHarry, OpChamberOfSecrets, policy.OperationRoleWrite),
		newUserOpPermission(UserHermione, OpChamberOfSecrets, policy.OperationRoleWrite),
		newUserOpPermission(UserSeamus, OpChamberOfSecrets, policy.OperationRoleRead),
		newUserOpPermission(UserGinny, OpChamberOfSecrets, policy.OperationRoleWrite),

		newUserOpPermission(UserHarry, OpGobletOfFire, policy.OperationRoleAdmin),
		newUserOpPermission(UserRon, OpGobletOfFire, policy.OperationRoleWrite),
		newUserOpPermission(UserGinny, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserHermione, OpGobletOfFire, policy.OperationRoleWrite),
		newUserOpPermission(UserNeville, OpGobletOfFire, policy.OperationRoleWrite),
		newUserOpPermission(UserSeamus, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserDraco, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserSnape, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserHagrid, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserHeadlessNick, OpGobletOfFire, policy.OperationRoleWrite),
		newUserOpPermission(UserCedric, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserFleur, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserViktor, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserAlastor, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserMinerva, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserLucius, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserSirius, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserPeter, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserParvati, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserPadma, OpGobletOfFire, policy.OperationRoleRead),
		newUserOpPermission(UserCho, OpGobletOfFire, policy.OperationRoleRead),

		newUserOpPermission(UserDumbledore, OpSorcerersStone, policy.OperationRoleAdmin),
		newUserOpPermission(UserDumbledore, OpChamberOfSecrets, policy.OperationRoleAdmin),
		newUserOpPermission(UserDumbledore, OpGobletOfFire, policy.OperationRoleAdmin),
	},
	UserGroupOpMap: []models.UserGroupOperationPermission{
		newUserGroupOpPermission(UserGroupGryffindor, OpSorcerersStone, policy.OperationRoleRead),
		newUserGroupOpPermission(UserGroupHufflepuff, OpSorcerersStone, policy.OperationRoleWrite),
		newUserGroupOpPermission(UserGroupSlytherin, OpSorcerersStone, policy.OperationRoleAdmin),
	},
	Findings: []models.Finding{
		FindingBook2Magic, FindingBook2CGI, FindingBook2SpiderFear, FindingBook2Robes,
	},
	Evidences: []models.Evidence{
		EviDursleys, EviMirrorOfErised, EviLevitateSpell, EviRulesForQuidditch,
		EviFlyingCar, EviDobby, EviSpiderAragog, EviMoaningMyrtle, EviWhompingWillow, EviTomRiddlesDiary, EviPetrifiedHermione, EviHeadlessHuntApplication,
		EviTristateTrophy, EviEntryForm, EviWizardDance, EviPolyjuice, EviWarewolf,
	},
	EvidenceMetadatas: []models.EvidenceMetadata{
		EviMetaDursleys, EviMetaMirrorOfErised, EviMetaLevitateSpell, EviMetaRulesForQuidditch, EviMetaRulesForQuidditchTwo,
		EviMetaFlyingCar, EviMetaDobby, EviMetaSpiderAragog, EviMetaMoaningMyrtle, EviMetaWhompingWillow, EviMetaTomRiddlesDiary, EviMetaTomRiddlesDiaryTwo, EviMetaPetrifiedHermione, EviMetaHeadlessHuntApplication,
		EviMetaTristateTrophy, EviMetaEntryForm, EviMetaWizardDance, EviMetaPolyjuice, EviMetaEntryFormTwo, EviMetaWarewolf, EviMetaWarewolfOther,
	},
	TagEviMap: unionTagEviMap(
		associateTagsToEvidence(EviDursleys, TagFamily, TagHome),
		associateTagsToEvidence(EviFlyingCar, TagEarth, TagSaturn),
		associateTagsToEvidence(EviDobby, TagMars, TagJupiter, TagMercury),
		associateTagsToEvidence(EviPetrifiedHermione, TagMars, CommonTagWhatCoS, CommonTagWhoCoS),

		associateTagsToEvidence(EviTristateTrophy, CommonTagWhoGoF, CommonTagWhereGoF, CommonTagWhyGoF),
		associateTagsToEvidence(EviEntryForm, CommonTagWhatGoF, CommonTagWhereGoF, CommonTagWhenGoF),
		associateTagsToEvidence(EviWizardDance, CommonTagWhereGoF, CommonTagWhenGoF),
		associateTagsToEvidence(EviPolyjuice, CommonTagWhatGoF, CommonTagWhereGoF, CommonTagWhenGoF, CommonTagWhyGoF),
		associateTagsToEvidence(EviWarewolf, CommonTagWhoGoF, CommonTagWhereGoF, CommonTagWhyGoF),
	),
	EviFindingsMap: unionEviFindingMap(
		associateEvidenceToFinding(FindingBook2Magic, EviDobby, EviFlyingCar, EviWhompingWillow),
		associateEvidenceToFinding(FindingBook2CGI, EviDobby, EviSpiderAragog),
	),
	Queries: []models.Query{
		QuerySalazarsHier,
		QueryWhereIsTheChamberOfSecrets,
	},
	ServiceWorkers: []models.ServiceWorker{
		DemoServiceWorker,
	},
	GlobalVars: []models.GlobalVar{
		VarExpelliarmus, VarAlohomora, VarAscendio, VarImperio, VarLumos, VarObliviate,
	},
	OperationVars: []models.OperationVar{
		OpVarImmobulus, OpVarObscuro, OpVarProtego, OpVarReparo, OpVarStupefy, OpVarWingardiumLeviosa,
	},
	VarOperationMap: unionVarOperationMap(
		associateVarsToOperation(OpSorcerersStone, OpVarImmobulus, OpVarObscuro),
		associateVarsToOperation(OpChamberOfSecrets, OpVarProtego, OpVarReparo),
		associateVarsToOperation(OpGobletOfFire, OpVarStupefy, OpVarWingardiumLeviosa),
	),
}
View Source
var NetworkFindingCategory = newHpFindingCategory("Network", false)
View Source
var OpChamberOfSecrets = newHPOp("HPCoS", "Harry Potter and The Chamber Of Secrets")

OpChamberOfSecrets is reserved to test permission issues. Also used with OpSorcerersStone

View Source
var OpDeathlyHallows = newHPOp("HPDH", "Harry Potter and The Deathly Hallows")

OpDeathlyHallows is a vailable for use

View Source
var OpGobletOfFire = newHPOp("HPGoF", "Harry Potter and The Goblet Of Fire")

OpGobletOfFire is reserved for a common-operation for all users

View Source
var OpHalfBloodPrince = newHPOp("HPHBP", "Harry Potter and The Half Blood Prince")

OpHalfBloodPrince is available for use

View Source
var OpOrderOfThePhoenix = newHPOp("HPOotP", "Harry Potter and The Order Of The Phoenix")

OpOrderOfThePhoenix is available for use

View Source
var OpPrisonerOfAzkaban = newHPOp("HPPoA", "Harry Potter and The Prisoner Of Azkaban")

OpPrisonerOfAzkaban is reserved as a no-user (orphaned) operation

View Source
var OpSorcerersStone = newHPOp("HPSS", "Harry Potter and The Sorcerer's Stone")

OpSorcerersStone is reserved to test permission issues. Also used with OpChamberOfSecrets

View Source
var OpVarImmobulus = newOperationVar("immobulus", "IMMOBULUS", "freezes objects")
View Source
var OpVarObscuro = newOperationVar("obscuro", "OBSCURO", "blindfolds the victim")
View Source
var OpVarProtego = newOperationVar("protego", "PROTEGO", "shield charm")
View Source
var OpVarReparo = newOperationVar("reparo", "REPARO", "repairs broken objects")
View Source
var OpVarStupefy = newOperationVar("stupefy", "STUPEFY", "knocks out opponent")
View Source
var OpVarWingardiumLeviosa = newOperationVar("wingardium_leviosa", "WINGARDIUM_LEVIOSA", "levitates objects")
View Source
var ProductFindingCategory = newHpFindingCategory("Product", false)
View Source
var QuerySalazarsHier = newHPQuery(OpChamberOfSecrets.ID, "Find Heir", "Magic Query String", "findings")
View Source
var QueryWhereIsTheChamberOfSecrets = newHPQuery(OpChamberOfSecrets.ID, "Locate Chamber", "Fancy Query", "evidence")
View Source
var SomeFindingCategory = newHpFindingCategory("some-category", false)
View Source
var SomeOtherFindingCategory = newHpFindingCategory("alt-category", false)
View Source
var TagCourage = newHPTag(OpSorcerersStone.ID, "Courage", "blue")
View Source
var TagEarth = newHPTag(OpChamberOfSecrets.ID, "Earth", "orange")
View Source
var TagFamily = newHPTag(OpSorcerersStone.ID, "Family", "red")
View Source
var TagFriendship = newHPTag(OpSorcerersStone.ID, "Friendship", "orange")
View Source
var TagGoodVsEvil = newHPTag(OpSorcerersStone.ID, "Good vs. Evil", "indigo")
View Source
var TagHome = newHPTag(OpSorcerersStone.ID, "Home", "yellow")
View Source
var TagJupiter = newHPTag(OpChamberOfSecrets.ID, "Jupiter", "green")
View Source
var TagLoyalty = newHPTag(OpSorcerersStone.ID, "Loyalty", "green")
View Source
var TagMars = newHPTag(OpChamberOfSecrets.ID, "Mars", "yellow")
View Source
var TagMercury = newHPTag(OpChamberOfSecrets.ID, "Mercury", "violet")
View Source
var TagNeptune = newHPTag(OpChamberOfSecrets.ID, "Neptune", "indigo")
View Source
var TagSaturn = newHPTag(OpChamberOfSecrets.ID, "Saturn", "blue")
View Source
var TagSupernatural = newHPTag(OpSorcerersStone.ID, "Super Natural", "violet")
View Source
var TagVenus = newHPTag(OpChamberOfSecrets.ID, "Venus", "red")
View Source
var TinyCodeblock []byte = []byte(`{"contentSubtype": "python", "content": "print(\"Hello World!\")"}`)

TinyCodeblock is a minimal codeblock. Used for testing.

View Source
var TinyImg []byte = []byte{
	0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52,
	0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, 0xC4,
	0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00,
	0x05, 0x00, 0x01, 0x0D, 0x0A, 0x2D, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE,
	0x42, 0x60, 0x82,
}

TinyImg is the smallest png. Used for testing. Reference: https://github.com/mathiasbynens/small

View Source
var TinyTermRec []byte = []byte(
	`{"version":2,"width":75,"height":18,"timestamp":1593020879,"title":"1593020879","env":{"SHELL":"/bin/bash","TERM":"xterm-256color"}}` +
		"\n" + `[0.188801409,"o","\u001b]0;user@localhost:~\u0007"]` +
		"\n" + `[0.189032775,"o","[user@localhost ~]$ "]` +
		"\n" + `[0.716089612,"o","ll\r\n"]` +
		"\n" + `[1.061539838,"o","total 10652\r\n"]` +
		"\n" + `[1.061654704,"o","-rwxrwxr-x. 1 user user 10905365 Jun 24 10:41 \u001b[0m\u001b[38;5;40mtermrec\u001b[0m\r\n"]` +
		"\n" + `[1.062881589,"o","\u001b]0;user@localhost:~\u0007"]` +
		"\n" + `[1.063084503,"o","[user@localhost ~]$ "]` +
		"\n" + `[1.517546751,"o","exit\r\n"]` +
		"\n" + `[2.129344227,"o","exit\r\n"]`,
)

TinyTermRec is a minimal terminal recording. Used for testing.

View Source
var UserAlastor = newHPUser(newUserInput{FirstName: "Alastor", LastName: "Moody", Birthday: date(1980, 1, 1), SetLastUpdated: true})
View Source
var UserCedric = newHPUser(newUserInput{FirstName: "Cedric", LastName: "Digory", Birthday: date(1980, 1, 1), SetLastUpdated: true})
View Source
var UserCho = newHPUser(newUserInput{FirstName: "Cho", LastName: "Chang", Birthday: date(1980, 1, 1), SetLastUpdated: true})
View Source
var UserDraco = newHPUser(newUserInput{FirstName: "Draco", LastName: "Malfoy", Birthday: date(1980, 6, 5), SetLastUpdated: true})
View Source
var UserDumbledore = newHPUser(newUserInput{FirstName: "Albus", LastName: "Dumbledore", Birthday: date(1970, 8, 1), SetLastUpdated: true, IsAdmin: true}) // birthday should be in 1881, but timestamp range is 1970-2038

UserDumbledore is reserved to be a super admin.

View Source
var UserFleur = newHPUser(newUserInput{FirstName: "Fleur", LastName: "Delacour", Birthday: date(1980, 1, 1), SetLastUpdated: true})
View Source
var UserGinny = newHPUser(newUserInput{FirstName: "Ginny", LastName: "Weasley", Birthday: date(1981, 3, 1), SetLastUpdated: true})
View Source
var UserGroupGryffindor = newUserGroup("Gryffindor", false)
View Source
var UserGroupHufflepuff = newUserGroup("Hufflepuff", false)
View Source
var UserGroupOtherHouse = newUserGroup("Other House", true)

UserGroupOtherHouse is reserved to test deleted user groups

View Source
var UserGroupRavenclaw = newUserGroup("Ravenclaw", false)
View Source
var UserGroupSlytherin = newUserGroup("Slytherin", false)
View Source
var UserHagrid = newHPUser(newUserInput{FirstName: "Rubeus", LastName: "Hagrid", Birthday: date(1980, 1, 1), SetLastUpdated: true, Disabled: true})

UserHagrid is reserved to test disabled users

View Source
var UserHarry = newHPUser(newUserInput{FirstName: "Harry", LastName: "Potter", Birthday: date(1980, 7, 31), SetLastUpdated: true})
View Source
var UserHeadlessNick = newHPUser(newUserInput{FirstName: "Nicholas", LastName: "de Mimsy-Porpington", Birthday: date(1980, 1, 1), SetLastUpdated: true, Headless: true})

UserHeadlessNick is reserved to test api-only access/"headless" users

View Source
var UserHermione = newHPUser(newUserInput{FirstName: "Hermione", LastName: "Granger", Birthday: date(1979, 9, 19), SetLastUpdated: true})
View Source
var UserLucius = newHPUser(newUserInput{FirstName: "Lucius", LastName: "Malfoy", Birthday: date(1980, 1, 1), SetLastUpdated: true})
View Source
var UserMinerva = newHPUser(newUserInput{FirstName: "Minerva", LastName: "McGonagall", Birthday: date(1980, 1, 1), SetLastUpdated: true})
View Source
var UserNeville = newHPUser(newUserInput{FirstName: "Neville", LastName: "Longbottom", Birthday: date(1979, 9, 19), SetLastUpdated: true})
View Source
var UserPadma = newHPUser(newUserInput{FirstName: "Padma", LastName: "Patil", Birthday: date(1980, 1, 1), SetLastUpdated: true})
View Source
var UserParvati = newHPUser(newUserInput{FirstName: "Parvati", LastName: "Patil", Birthday: date(1980, 1, 1), SetLastUpdated: true})
View Source
var UserPeter = newHPUser(newUserInput{FirstName: "Peter", LastName: "Pettigrew", Birthday: date(1980, 1, 1), SetLastUpdated: true})
View Source
var UserRon = newHPUser(newUserInput{FirstName: "Ron", LastName: "Weasley", Birthday: date(1980, 3, 1), SetLastUpdated: true})
View Source
var UserSeamus = newHPUser(newUserInput{FirstName: "Seamus", LastName: "Finnigan", Birthday: date(1980, 9, 1), SetLastUpdated: true})
View Source
var UserSirius = newHPUser(newUserInput{FirstName: "Sirius", LastName: "Black", Birthday: date(1980, 1, 1), SetLastUpdated: true})
View Source
var UserSnape = newHPUser(newUserInput{FirstName: "Serverus", LastName: "Snape", Birthday: date(1980, 1, 1), SetLastUpdated: true})
View Source
var UserTomRiddle = newHPUser(newUserInput{FirstName: "Tom", LastName: "Riddle", Birthday: date(1980, 1, 1), SetLastUpdated: true, Deleted: true})

UserTomRiddle is reserved to test deleted users

View Source
var UserViktor = newHPUser(newUserInput{FirstName: "Viktor", LastName: "Krum", Birthday: date(1980, 1, 1), SetLastUpdated: true})
View Source
var VarAlohomora = newGlobalVar("ALOHOMORA", "unlock doors")
View Source
var VarAscendio = newGlobalVar("ASCENDIO", "lifts the caster high into the air")
View Source
var VarExpelliarmus = newGlobalVar("EXPELLIARMUS", "disarm an opponent")
View Source
var VarImperio = newGlobalVar("IMPERIO", "control another person")
View Source
var VarLumos = newGlobalVar("LUMOS", "creates a narrow beam of light")
View Source
var VarObliviate = newGlobalVar("PETRIFICUS_TOTALUS", "paralyzes someone")
View Source
var VendorFindingCategory = newHpFindingCategory("Vendor", false)

Functions

func ApplySeeding

func ApplySeeding(t *testing.T, seed Seeder, db *database.Connection)

func ClearDB

func ClearDB(db *database.Connection) error

ClearDB empties the database of all values. This leaves behind small residue: IDs are already taken, so, auto-incremented values will use the next value, not re-use values. However, this is easily overcome by specifying what the ID should be -- which is part of each seed anyway.

Note: this should only be done in a testing environment.

func ContextForUser

func ContextForUser(my models.User, db *database.Connection) context.Context

ContextForUser genereates a user's context as if they had just logged in. All settings are set, except for NeedsReset, which is always false

func CountRows

func CountRows(t *testing.T, db *database.Connection, tablename, where string, values ...interface{}) int64

func CreatePopulatedMemStore

func CreatePopulatedMemStore(seed Seeder) *contentstore.MemStore

CreatePopulatedMemStore generates an in-memory content store with all evidence of the given seed populated with tiny versions (see TinyTermRec, TinyImg, and TinyCodeblock). Useful for delete tests

func DefaultTagIDsFromTags

func DefaultTagIDsFromTags(tags ...models.DefaultTag) []int64

DefaultTagIDsFromTags maps over models.DefaultTags to come up with a collection of IDs for those tags equivalent js: tags.map( i => i.ID)

func FillEvidenceWithTags

func FillEvidenceWithTags(t *testing.T, db *database.Connection, evidence *[]FullEvidence)

func GetAPIKeysForUserID

func GetAPIKeysForUserID(t *testing.T, db *database.Connection, userID int64) []models.APIKey

db queries

func GetAllDeletedUsers

func GetAllDeletedUsers(t *testing.T, db *database.Connection) []models.User

func GetAllUsers

func GetAllUsers(t *testing.T, db *database.Connection) []models.User

func GetAuthsForUser

func GetAuthsForUser(t *testing.T, db *database.Connection, userID int64) []models.AuthSchemeData

func GetDefaultTagByID

func GetDefaultTagByID(t *testing.T, db *database.Connection, id int64) models.DefaultTag

func GetDefaultTags

func GetDefaultTags(t *testing.T, db *database.Connection) []models.DefaultTag

func GetEvidenceByID

func GetEvidenceByID(t *testing.T, db *database.Connection, id int64) models.Evidence

func GetEvidenceByUUID

func GetEvidenceByUUID(t *testing.T, db *database.Connection, uuid string) models.Evidence

func GetEvidenceForOperation

func GetEvidenceForOperation(t *testing.T, db *database.Connection, operationID int64) []models.Evidence

func GetEvidenceIDsFromFinding

func GetEvidenceIDsFromFinding(t *testing.T, db *database.Connection, findingID int64) []int64

func GetEvidenceMetadataByEvidenceID

func GetEvidenceMetadataByEvidenceID(t *testing.T, db *database.Connection, id int64) []models.EvidenceMetadata

func GetFavoriteForOperation

func GetFavoriteForOperation(t *testing.T, db *database.Connection, slug string, id int64) bool

func GetFindingByUUID

func GetFindingByUUID(t *testing.T, db *database.Connection, uuid string) models.Finding

func GetFindingsByOperationID

func GetFindingsByOperationID(t *testing.T, db *database.Connection, id int64) []models.Finding

func GetFullEvidenceViaSelectBuilder

func GetFullEvidenceViaSelectBuilder(t *testing.T, db *database.Connection, condition sq.Eq) models.Evidence

func GetGlobalVarFromName

func GetGlobalVarFromName(t *testing.T, db *database.Connection, name string) models.GlobalVar

func GetOperationFromSlug

func GetOperationFromSlug(t *testing.T, db *database.Connection, slug string) models.Operation

func GetOperationVarFromSlug

func GetOperationVarFromSlug(t *testing.T, db *database.Connection, slug string) models.OperationVar

func GetOperations

func GetOperations(t *testing.T, db *database.Connection) []services.OperationWithID

func GetOperationsForUser

func GetOperationsForUser(t *testing.T, db *database.Connection, user models.User) []*dtos.Operation

TODO this is too close to what ListOperations does. We can leave it like this, but should have a a test to verify the intial case (matches the seed data), plus a minor addition

func GetQueriesForOperationID

func GetQueriesForOperationID(t *testing.T, db *database.Connection, id int64) []models.Query

func GetQueryByID

func GetQueryByID(t *testing.T, db *database.Connection, id int64) models.Query

func GetRealUsers

func GetRealUsers(t *testing.T, db *database.Connection) []models.User

func GetServiceWorkerByID

func GetServiceWorkerByID(t *testing.T, db *database.Connection, id int64) models.ServiceWorker

func GetServiceWorkerByName

func GetServiceWorkerByName(t *testing.T, db *database.Connection, name string) models.ServiceWorker

func GetTagByID

func GetTagByID(t *testing.T, db *database.Connection, id int64) models.Tag

func GetTagFromOperationID

func GetTagFromOperationID(t *testing.T, db *database.Connection, id int64) []models.Tag

func GetTagIDsFromEvidenceID

func GetTagIDsFromEvidenceID(t *testing.T, db *database.Connection, evidenceID int64) []int64

func GetTagUsage

func GetTagUsage(t *testing.T, db *database.Connection, tagID int64) int64

func GetUserBySlug

func GetUserBySlug(t *testing.T, db *database.Connection, slug string) models.User

func GetUserGroupFromSlug

func GetUserGroupFromSlug(t *testing.T, db *database.Connection, slug string) models.UserGroup

func GetUserProfile

func GetUserProfile(t *testing.T, db *database.Connection, id int64) models.User

func GetUserRolesForOperationByOperationID

func GetUserRolesForOperationByOperationID(t *testing.T, db *database.Connection, id int64) []models.UserOperationPermission

func GetUsersForAuth

func GetUsersForAuth(t *testing.T, db *database.Connection, authName string) []models.User

func InitTest

func InitTest(t *testing.T) *database.Connection

InitTest creates a connection to the database and provides an established, but otherwise empty database. The database is named "service-test-db"

func InitTestWithName

func InitTestWithName(t *testing.T, dbname string) *database.Connection

InitTestWithName creates a connection to the database with an established, but otherwise empty database _of the given name_.

func InitTestWithOptions

func InitTestWithOptions(t *testing.T, options TestOptions) *database.Connection

InitTestWithOptions creates a connection to the database with an established, but otherwise empty database, configured with.

func IsSeeded

func IsSeeded(db *database.Connection) (bool, error)

IsSeeded does a check against the database to see if any users are registered. if no users are registered, then it is assumed that the database has not been seeded.

func ListServiceWorkers

func ListServiceWorkers(t *testing.T, db *database.Connection) []models.ServiceWorker

func MkDBRowCounter

func MkDBRowCounter(t *testing.T, db *database.Connection, tablename, where string, values ...interface{}) func() int64

func SimpleFullContext

func SimpleFullContext(my models.User) context.Context

SimpleFullContext returns back a context with a proper authenticated policy

func Sorted

func Sorted(slice []int64) []int64

Sorted orders an int slice in asc order, then returns back a copy of the sorted list note: underlying list is unedited

func TagIDsFromTags

func TagIDsFromTags(tags ...models.Tag) []int64

TagIDsFromTags maps over models.Tags to come up with a collection of IDs for those tags equivalent js: tags.map( i => i.ID)

Types

type FullEvidence

type FullEvidence struct {
	models.Evidence
	// copied from models.User
	Slug      string `db:"slug"`
	FirstName string `db:"first_name"`
	LastName  string `db:"last_name"`
	Tags      []models.Tag
}

func GetFullEvidenceByFindingID

func GetFullEvidenceByFindingID(t *testing.T, db *database.Connection, findingID int64) []FullEvidence

func GetFullEvidenceByOperationID

func GetFullEvidenceByOperationID(t *testing.T, db *database.Connection, operationID int64) []FullEvidence

type PreferencesOperations

type PreferencesOperations struct {
	models.UserOperationPreferences
	Slug string `db:"slug"`
}

func GetFavoritesByUserID

func GetFavoritesByUserID(t *testing.T, db *database.Connection, id int64) []PreferencesOperations

type Seeder

type Seeder struct {
	FindingCategories []models.FindingCategory
	APIKeys           []models.APIKey
	Findings          []models.Finding
	Evidences         []models.Evidence
	EvidenceMetadatas []models.EvidenceMetadata
	Users             []models.User
	UserGroups        []models.UserGroup
	UserGroupMaps     []models.UserGroupMap
	Operations        []models.Operation
	DefaultTags       []models.DefaultTag
	Tags              []models.Tag
	UserOpMap         []models.UserOperationPermission
	UserGroupOpMap    []models.UserGroupOperationPermission
	UserOpPrefMap     []models.UserOperationPreferences
	TagEviMap         []models.TagEvidenceMap
	EviFindingsMap    []models.EvidenceFindingMap
	Queries           []models.Query
	ServiceWorkers    []models.ServiceWorker
	GlobalVars        []models.GlobalVar
	OperationVars     []models.OperationVar
	VarOperationMap   []models.VarOperationMap
}

Seeder is designed to allow a database-to-structure mapping. This is useful either for populating/seeding the database (see ApplyTo method), or alternatively, as acting as a source of truth for post-db operations.

func (Seeder) AllInitialDefaultTagIds

func (seed Seeder) AllInitialDefaultTagIds() []int64

AllInitialDefaultTagIds is a (convenience) method version of the function DefaultTagIDsFromTags

func (Seeder) AllInitialTagIds

func (seed Seeder) AllInitialTagIds() []int64

AllInitialTagIds is a (convenience) method version of the function TagIDsFromTags

func (Seeder) ApplyTo

func (seed Seeder) ApplyTo(db *database.Connection) error

ApplyTo takes the configured Seeder and writes these values to the database.

func (Seeder) CategoryForFinding

func (seed Seeder) CategoryForFinding(finding models.Finding) string

func (Seeder) EvidenceForOperation

func (seed Seeder) EvidenceForOperation(opID int64) []models.Evidence

func (Seeder) EvidenceIDsForFinding

func (seed Seeder) EvidenceIDsForFinding(finding models.Finding) []int64

func (Seeder) GetTagFromID

func (seed Seeder) GetTagFromID(id int64) models.Tag

func (Seeder) GetUserFromID

func (seed Seeder) GetUserFromID(id int64) models.User

func (Seeder) GetUserGroupFromID

func (seed Seeder) GetUserGroupFromID(id int64) models.UserGroup

func (Seeder) OperationForEvidence

func (seed Seeder) OperationForEvidence(evidence models.Evidence) *models.Operation

func (Seeder) Reset

func (seed Seeder) Reset(db *database.Connection) error

func (Seeder) TagIDsUsageByDate

func (seed Seeder) TagIDsUsageByDate(opID int64) map[int64][]time.Time

func (Seeder) TagsForEvidence

func (seed Seeder) TagsForEvidence(evidence models.Evidence) []models.Tag

func (Seeder) TagsForFinding

func (seed Seeder) TagsForFinding(finding models.Finding) []models.Tag

func (Seeder) UserGroupRoleForOp

func (seed Seeder) UserGroupRoleForOp(userGroup models.UserGroup, op models.Operation) policy.OperationRole

func (Seeder) UserGroupsForOp

func (seed Seeder) UserGroupsForOp(op models.Operation) []models.UserGroup

func (Seeder) UserRoleForOp

func (seed Seeder) UserRoleForOp(user models.User, op models.Operation) policy.OperationRole

func (Seeder) UsersForOp

func (seed Seeder) UsersForOp(op models.Operation) []models.User

type TestOptions

type TestOptions struct {
	DatabasePath *string
	DatabaseName *string
}

type UserGroupOpPermJoinUser

type UserGroupOpPermJoinUser struct {
	models.UserGroup
	Role policy.OperationRole `db:"role"`
}

func GetUserGroupsWithRoleForOperationByOperationID

func GetUserGroupsWithRoleForOperationByOperationID(t *testing.T, db *database.Connection, id int64) []UserGroupOpPermJoinUser

type UserOpPermJoinUser

type UserOpPermJoinUser struct {
	models.User
	Role policy.OperationRole `db:"role"`
}

func GetUsersWithRoleForOperationByOperationID

func GetUsersWithRoleForOperationByOperationID(t *testing.T, db *database.Connection, id int64) []UserOpPermJoinUser

Jump to

Keyboard shortcuts

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