-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathentity.go
More file actions
2103 lines (1974 loc) · 79 KB
/
Copy pathentity.go
File metadata and controls
2103 lines (1974 loc) · 79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by ent, DO NOT EDIT.
package generated
import (
"encoding/json"
"fmt"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"github.com/theopenlane/core/common/enums"
"github.com/theopenlane/core/common/models"
"github.com/theopenlane/core/internal/ent/generated/customtypeenum"
"github.com/theopenlane/core/internal/ent/generated/entity"
"github.com/theopenlane/core/internal/ent/generated/entitytype"
"github.com/theopenlane/core/internal/ent/generated/file"
"github.com/theopenlane/core/internal/ent/generated/group"
"github.com/theopenlane/core/internal/ent/generated/organization"
"github.com/theopenlane/core/internal/ent/generated/user"
)
// Entity is the model entity for the Entity schema.
type Entity struct {
config `json:"-"`
// ID of the ent.
ID string `json:"id,omitempty"`
// CreatedAt holds the value of the "created_at" field.
CreatedAt time.Time `json:"created_at,omitempty"`
// UpdatedAt holds the value of the "updated_at" field.
UpdatedAt time.Time `json:"updated_at,omitempty"`
// CreatedBy holds the value of the "created_by" field.
CreatedBy string `json:"created_by,omitempty"`
// UpdatedBy holds the value of the "updated_by" field.
UpdatedBy string `json:"updated_by,omitempty"`
// DeletedAt holds the value of the "deleted_at" field.
DeletedAt time.Time `json:"deleted_at,omitempty"`
// DeletedBy holds the value of the "deleted_by" field.
DeletedBy string `json:"deleted_by,omitempty"`
// tags associated with the object
Tags []string `json:"tags,omitempty"`
// the ID of the organization owner of the object
OwnerID string `json:"owner_id,omitempty"`
// the internal owner for the entity when no user or group is linked
InternalOwner string `json:"internal_owner,omitempty"`
// the internal owner user id for the entity
InternalOwnerUserID string `json:"internal_owner_user_id,omitempty"`
// the internal owner group id for the entity
InternalOwnerGroupID string `json:"internal_owner_group_id,omitempty"`
// who reviewed the entity when no user or group is linked
ReviewedBy string `json:"reviewed_by,omitempty"`
// the user id that reviewed the entity
ReviewedByUserID string `json:"reviewed_by_user_id,omitempty"`
// the group id that reviewed the entity
ReviewedByGroupID string `json:"reviewed_by_group_id,omitempty"`
// when the entity was last reviewed
LastReviewedAt *models.DateTime `json:"last_reviewed_at,omitempty"`
// indicates if the record is owned by the the openlane system and not by an organization
SystemOwned bool `json:"system_owned,omitempty"`
// internal notes about the object creation, this field is only available to system admins
InternalNotes *string `json:"internal_notes,omitempty"`
// an internal identifier for the mapping, this field is only available to system admins
SystemInternalID *string `json:"system_internal_id,omitempty"`
// the relationship_state of the entity
EntityRelationshipStateName string `json:"entity_relationship_state_name,omitempty"`
// the relationship_state of the entity
EntityRelationshipStateID string `json:"entity_relationship_state_id,omitempty"`
// the security_questionnaire_status of the entity
EntitySecurityQuestionnaireStatusName string `json:"entity_security_questionnaire_status_name,omitempty"`
// the security_questionnaire_status of the entity
EntitySecurityQuestionnaireStatusID string `json:"entity_security_questionnaire_status_id,omitempty"`
// the source_type of the entity
EntitySourceTypeName string `json:"entity_source_type_name,omitempty"`
// the source_type of the entity
EntitySourceTypeID string `json:"entity_source_type_id,omitempty"`
// the environment of the entity
EnvironmentName string `json:"environment_name,omitempty"`
// the environment of the entity
EnvironmentID string `json:"environment_id,omitempty"`
// the scope of the entity
ScopeName string `json:"scope_name,omitempty"`
// the scope of the entity
ScopeID string `json:"scope_id,omitempty"`
// the name of the entity
Name string `json:"name,omitempty"`
// The entity's displayed 'friendly' name
DisplayName string `json:"display_name,omitempty"`
// An optional description of the entity
Description string `json:"description,omitempty"`
// domains associated with the entity
Domains []string `json:"domains,omitempty"`
// The type of the entity
EntityTypeID string `json:"entity_type_id,omitempty"`
// status of the entity
Status enums.EntityStatus `json:"status,omitempty"`
// whether the entity is approved for use
ApprovedForUse bool `json:"approved_for_use,omitempty"`
// asset identifiers linked to the entity
LinkedAssetIds []string `json:"linked_asset_ids,omitempty"`
// whether the entity has an active SOC 2 report
HasSoc2 bool `json:"has_soc2,omitempty"`
// SOC 2 reporting period end date
Soc2PeriodEnd *models.DateTime `json:"soc2_period_end,omitempty"`
// start date for the entity contract
ContractStartDate *models.DateTime `json:"contract_start_date,omitempty"`
// end date for the entity contract
ContractEndDate *models.DateTime `json:"contract_end_date,omitempty"`
// whether the contract auto-renews
AutoRenews bool `json:"auto_renews,omitempty"`
// number of days required for termination notice
TerminationNoticeDays int `json:"termination_notice_days,omitempty"`
// annual spend associated with the entity
AnnualSpend float64 `json:"annual_spend,omitempty"`
// the currency of the annual spend
SpendCurrency string `json:"spend_currency,omitempty"`
// billing model for the entity relationship
BillingModel string `json:"billing_model,omitempty"`
// renewal risk rating for the entity
RenewalRisk string `json:"renewal_risk,omitempty"`
// whether SSO is enforced for the entity
SSOEnforced bool `json:"sso_enforced,omitempty"`
// whether MFA is supported by the entity
MfaSupported bool `json:"mfa_supported,omitempty"`
// whether MFA is enforced by the entity
MfaEnforced bool `json:"mfa_enforced,omitempty"`
// status page URL for the entity
StatusPageURL string `json:"status_page_url,omitempty"`
// services provided by the entity
ProvidedServices []string `json:"provided_services,omitempty"`
// external links associated with the entity
Links []string `json:"links,omitempty"`
// the risk rating label for the entity
RiskRating string `json:"risk_rating,omitempty"`
// the risk score for the entity
RiskScore int `json:"risk_score,omitempty"`
// number of scoring questions answered for the current risk score; used to contextualize partial assessments
RiskScoreCoverage int `json:"risk_score_coverage,omitempty"`
// the vendor risk tier classification, used to determine the depth of TPRM assessment required
Tier enums.VendorTier `json:"tier,omitempty"`
// the cadence for reviewing the entity
ReviewFrequency enums.Frequency `json:"review_frequency,omitempty"`
// when the entity is due for review
NextReviewAt *models.DateTime `json:"next_review_at,omitempty"`
// when the entity contract is up for renewal
ContractRenewalAt *models.DateTime `json:"contract_renewal_at,omitempty"`
// vendor metadata such as additional enrichment info, company size, public, etc.
VendorMetadata map[string]interface{} `json:"vendor_metadata,omitempty"`
// URL of the logo for the entity
LogoRemoteURL *string `json:"logo_remote_url,omitempty"`
// The logo file id for the entity
LogoFileID *string `json:"logo_file_id,omitempty"`
// stable identifier assigned by the source system, used for integration ingest deduplication
ExternalID string `json:"external_id,omitempty"`
// time when this entity was last observed by the source integration
ObservedAt *models.DateTime `json:"observed_at,omitempty"`
// Edges holds the relations/edges for other nodes in the graph.
// The values are being populated by the EntityQuery when eager-loading is set.
Edges EntityEdges `json:"edges"`
entity_type_entities *string
finding_entities *string
remediation_entities *string
review_entities *string
risk_entities *string
scan_entities *string
vulnerability_entities *string
selectValues sql.SelectValues
}
// EntityEdges holds the relations/edges for other nodes in the graph.
type EntityEdges struct {
// Owner holds the value of the owner edge.
Owner *Organization `json:"owner,omitempty"`
// groups that are blocked from viewing or editing the risk
BlockedGroups []*Group `json:"blocked_groups,omitempty"`
// provides edit access to the risk to members of the group
Editors []*Group `json:"editors,omitempty"`
// provides view access to the risk to members of the group
Viewers []*Group `json:"viewers,omitempty"`
// InternalOwnerUser holds the value of the internal_owner_user edge.
InternalOwnerUser *User `json:"internal_owner_user,omitempty"`
// InternalOwnerGroup holds the value of the internal_owner_group edge.
InternalOwnerGroup *Group `json:"internal_owner_group,omitempty"`
// ReviewedByUser holds the value of the reviewed_by_user edge.
ReviewedByUser *User `json:"reviewed_by_user,omitempty"`
// ReviewedByGroup holds the value of the reviewed_by_group edge.
ReviewedByGroup *Group `json:"reviewed_by_group,omitempty"`
// EntityRelationshipState holds the value of the entity_relationship_state edge.
EntityRelationshipState *CustomTypeEnum `json:"entity_relationship_state,omitempty"`
// EntitySecurityQuestionnaireStatus holds the value of the entity_security_questionnaire_status edge.
EntitySecurityQuestionnaireStatus *CustomTypeEnum `json:"entity_security_questionnaire_status,omitempty"`
// EntitySourceType holds the value of the entity_source_type edge.
EntitySourceType *CustomTypeEnum `json:"entity_source_type,omitempty"`
// Environment holds the value of the environment edge.
Environment *CustomTypeEnum `json:"environment,omitempty"`
// Scope holds the value of the scope edge.
Scope *CustomTypeEnum `json:"scope,omitempty"`
// Contacts holds the value of the contacts edge.
Contacts []*Contact `json:"contacts,omitempty"`
// Documents holds the value of the documents edge.
Documents []*DocumentData `json:"documents,omitempty"`
// Notes holds the value of the notes edge.
Notes []*Note `json:"notes,omitempty"`
// Files holds the value of the files edge.
Files []*File `json:"files,omitempty"`
// Assets holds the value of the assets edge.
Assets []*Asset `json:"assets,omitempty"`
// Scans holds the value of the scans edge.
Scans []*Scan `json:"scans,omitempty"`
// Campaigns holds the value of the campaigns edge.
Campaigns []*Campaign `json:"campaigns,omitempty"`
// AssessmentResponses holds the value of the assessment_responses edge.
AssessmentResponses []*AssessmentResponse `json:"assessment_responses,omitempty"`
// VendorRiskScores holds the value of the vendor_risk_scores edge.
VendorRiskScores []*VendorRiskScore `json:"vendor_risk_scores,omitempty"`
// Integrations holds the value of the integrations edge.
Integrations []*Integration `json:"integrations,omitempty"`
// Subprocessors holds the value of the subprocessors edge.
Subprocessors []*Subprocessor `json:"subprocessors,omitempty"`
// AuthMethods holds the value of the auth_methods edge.
AuthMethods []*CustomTypeEnum `json:"auth_methods,omitempty"`
// EmployerIdentityHolders holds the value of the employer_identity_holders edge.
EmployerIdentityHolders []*IdentityHolder `json:"employer_identity_holders,omitempty"`
// IdentityHolders holds the value of the identity_holders edge.
IdentityHolders []*IdentityHolder `json:"identity_holders,omitempty"`
// Controls holds the value of the controls edge.
Controls []*Control `json:"controls,omitempty"`
// Subcontrols holds the value of the subcontrols edge.
Subcontrols []*Subcontrol `json:"subcontrols,omitempty"`
// Platforms holds the value of the platforms edge.
Platforms []*Platform `json:"platforms,omitempty"`
// OutOfScopePlatforms holds the value of the out_of_scope_platforms edge.
OutOfScopePlatforms []*Platform `json:"out_of_scope_platforms,omitempty"`
// SourcePlatforms holds the value of the source_platforms edge.
SourcePlatforms []*Platform `json:"source_platforms,omitempty"`
// EntityType holds the value of the entity_type edge.
EntityType *EntityType `json:"entity_type,omitempty"`
// LogoFile holds the value of the logo_file edge.
LogoFile *File `json:"logo_file,omitempty"`
// InternalPolicies holds the value of the internal_policies edge.
InternalPolicies []*InternalPolicy `json:"internal_policies,omitempty"`
// loadedTypes holds the information for reporting if a
// type was loaded (or requested) in eager-loading or not.
loadedTypes [35]bool
// totalCount holds the count of the edges above.
totalCount [35]map[string]int
namedBlockedGroups map[string][]*Group
namedEditors map[string][]*Group
namedViewers map[string][]*Group
namedContacts map[string][]*Contact
namedDocuments map[string][]*DocumentData
namedNotes map[string][]*Note
namedFiles map[string][]*File
namedAssets map[string][]*Asset
namedScans map[string][]*Scan
namedCampaigns map[string][]*Campaign
namedAssessmentResponses map[string][]*AssessmentResponse
namedVendorRiskScores map[string][]*VendorRiskScore
namedIntegrations map[string][]*Integration
namedSubprocessors map[string][]*Subprocessor
namedAuthMethods map[string][]*CustomTypeEnum
namedEmployerIdentityHolders map[string][]*IdentityHolder
namedIdentityHolders map[string][]*IdentityHolder
namedControls map[string][]*Control
namedSubcontrols map[string][]*Subcontrol
namedPlatforms map[string][]*Platform
namedOutOfScopePlatforms map[string][]*Platform
namedSourcePlatforms map[string][]*Platform
namedInternalPolicies map[string][]*InternalPolicy
}
// OwnerOrErr returns the Owner value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) OwnerOrErr() (*Organization, error) {
if e.Owner != nil {
return e.Owner, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: organization.Label}
}
return nil, &NotLoadedError{edge: "owner"}
}
// BlockedGroupsOrErr returns the BlockedGroups value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) BlockedGroupsOrErr() ([]*Group, error) {
if e.loadedTypes[1] {
return e.BlockedGroups, nil
}
return nil, &NotLoadedError{edge: "blocked_groups"}
}
// EditorsOrErr returns the Editors value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) EditorsOrErr() ([]*Group, error) {
if e.loadedTypes[2] {
return e.Editors, nil
}
return nil, &NotLoadedError{edge: "editors"}
}
// ViewersOrErr returns the Viewers value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) ViewersOrErr() ([]*Group, error) {
if e.loadedTypes[3] {
return e.Viewers, nil
}
return nil, &NotLoadedError{edge: "viewers"}
}
// InternalOwnerUserOrErr returns the InternalOwnerUser value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) InternalOwnerUserOrErr() (*User, error) {
if e.InternalOwnerUser != nil {
return e.InternalOwnerUser, nil
} else if e.loadedTypes[4] {
return nil, &NotFoundError{label: user.Label}
}
return nil, &NotLoadedError{edge: "internal_owner_user"}
}
// InternalOwnerGroupOrErr returns the InternalOwnerGroup value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) InternalOwnerGroupOrErr() (*Group, error) {
if e.InternalOwnerGroup != nil {
return e.InternalOwnerGroup, nil
} else if e.loadedTypes[5] {
return nil, &NotFoundError{label: group.Label}
}
return nil, &NotLoadedError{edge: "internal_owner_group"}
}
// ReviewedByUserOrErr returns the ReviewedByUser value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) ReviewedByUserOrErr() (*User, error) {
if e.ReviewedByUser != nil {
return e.ReviewedByUser, nil
} else if e.loadedTypes[6] {
return nil, &NotFoundError{label: user.Label}
}
return nil, &NotLoadedError{edge: "reviewed_by_user"}
}
// ReviewedByGroupOrErr returns the ReviewedByGroup value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) ReviewedByGroupOrErr() (*Group, error) {
if e.ReviewedByGroup != nil {
return e.ReviewedByGroup, nil
} else if e.loadedTypes[7] {
return nil, &NotFoundError{label: group.Label}
}
return nil, &NotLoadedError{edge: "reviewed_by_group"}
}
// EntityRelationshipStateOrErr returns the EntityRelationshipState value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) EntityRelationshipStateOrErr() (*CustomTypeEnum, error) {
if e.EntityRelationshipState != nil {
return e.EntityRelationshipState, nil
} else if e.loadedTypes[8] {
return nil, &NotFoundError{label: customtypeenum.Label}
}
return nil, &NotLoadedError{edge: "entity_relationship_state"}
}
// EntitySecurityQuestionnaireStatusOrErr returns the EntitySecurityQuestionnaireStatus value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) EntitySecurityQuestionnaireStatusOrErr() (*CustomTypeEnum, error) {
if e.EntitySecurityQuestionnaireStatus != nil {
return e.EntitySecurityQuestionnaireStatus, nil
} else if e.loadedTypes[9] {
return nil, &NotFoundError{label: customtypeenum.Label}
}
return nil, &NotLoadedError{edge: "entity_security_questionnaire_status"}
}
// EntitySourceTypeOrErr returns the EntitySourceType value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) EntitySourceTypeOrErr() (*CustomTypeEnum, error) {
if e.EntitySourceType != nil {
return e.EntitySourceType, nil
} else if e.loadedTypes[10] {
return nil, &NotFoundError{label: customtypeenum.Label}
}
return nil, &NotLoadedError{edge: "entity_source_type"}
}
// EnvironmentOrErr returns the Environment value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) EnvironmentOrErr() (*CustomTypeEnum, error) {
if e.Environment != nil {
return e.Environment, nil
} else if e.loadedTypes[11] {
return nil, &NotFoundError{label: customtypeenum.Label}
}
return nil, &NotLoadedError{edge: "environment"}
}
// ScopeOrErr returns the Scope value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) ScopeOrErr() (*CustomTypeEnum, error) {
if e.Scope != nil {
return e.Scope, nil
} else if e.loadedTypes[12] {
return nil, &NotFoundError{label: customtypeenum.Label}
}
return nil, &NotLoadedError{edge: "scope"}
}
// ContactsOrErr returns the Contacts value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) ContactsOrErr() ([]*Contact, error) {
if e.loadedTypes[13] {
return e.Contacts, nil
}
return nil, &NotLoadedError{edge: "contacts"}
}
// DocumentsOrErr returns the Documents value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) DocumentsOrErr() ([]*DocumentData, error) {
if e.loadedTypes[14] {
return e.Documents, nil
}
return nil, &NotLoadedError{edge: "documents"}
}
// NotesOrErr returns the Notes value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) NotesOrErr() ([]*Note, error) {
if e.loadedTypes[15] {
return e.Notes, nil
}
return nil, &NotLoadedError{edge: "notes"}
}
// FilesOrErr returns the Files value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) FilesOrErr() ([]*File, error) {
if e.loadedTypes[16] {
return e.Files, nil
}
return nil, &NotLoadedError{edge: "files"}
}
// AssetsOrErr returns the Assets value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) AssetsOrErr() ([]*Asset, error) {
if e.loadedTypes[17] {
return e.Assets, nil
}
return nil, &NotLoadedError{edge: "assets"}
}
// ScansOrErr returns the Scans value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) ScansOrErr() ([]*Scan, error) {
if e.loadedTypes[18] {
return e.Scans, nil
}
return nil, &NotLoadedError{edge: "scans"}
}
// CampaignsOrErr returns the Campaigns value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) CampaignsOrErr() ([]*Campaign, error) {
if e.loadedTypes[19] {
return e.Campaigns, nil
}
return nil, &NotLoadedError{edge: "campaigns"}
}
// AssessmentResponsesOrErr returns the AssessmentResponses value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) AssessmentResponsesOrErr() ([]*AssessmentResponse, error) {
if e.loadedTypes[20] {
return e.AssessmentResponses, nil
}
return nil, &NotLoadedError{edge: "assessment_responses"}
}
// VendorRiskScoresOrErr returns the VendorRiskScores value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) VendorRiskScoresOrErr() ([]*VendorRiskScore, error) {
if e.loadedTypes[21] {
return e.VendorRiskScores, nil
}
return nil, &NotLoadedError{edge: "vendor_risk_scores"}
}
// IntegrationsOrErr returns the Integrations value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) IntegrationsOrErr() ([]*Integration, error) {
if e.loadedTypes[22] {
return e.Integrations, nil
}
return nil, &NotLoadedError{edge: "integrations"}
}
// SubprocessorsOrErr returns the Subprocessors value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) SubprocessorsOrErr() ([]*Subprocessor, error) {
if e.loadedTypes[23] {
return e.Subprocessors, nil
}
return nil, &NotLoadedError{edge: "subprocessors"}
}
// AuthMethodsOrErr returns the AuthMethods value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) AuthMethodsOrErr() ([]*CustomTypeEnum, error) {
if e.loadedTypes[24] {
return e.AuthMethods, nil
}
return nil, &NotLoadedError{edge: "auth_methods"}
}
// EmployerIdentityHoldersOrErr returns the EmployerIdentityHolders value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) EmployerIdentityHoldersOrErr() ([]*IdentityHolder, error) {
if e.loadedTypes[25] {
return e.EmployerIdentityHolders, nil
}
return nil, &NotLoadedError{edge: "employer_identity_holders"}
}
// IdentityHoldersOrErr returns the IdentityHolders value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) IdentityHoldersOrErr() ([]*IdentityHolder, error) {
if e.loadedTypes[26] {
return e.IdentityHolders, nil
}
return nil, &NotLoadedError{edge: "identity_holders"}
}
// ControlsOrErr returns the Controls value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) ControlsOrErr() ([]*Control, error) {
if e.loadedTypes[27] {
return e.Controls, nil
}
return nil, &NotLoadedError{edge: "controls"}
}
// SubcontrolsOrErr returns the Subcontrols value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) SubcontrolsOrErr() ([]*Subcontrol, error) {
if e.loadedTypes[28] {
return e.Subcontrols, nil
}
return nil, &NotLoadedError{edge: "subcontrols"}
}
// PlatformsOrErr returns the Platforms value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) PlatformsOrErr() ([]*Platform, error) {
if e.loadedTypes[29] {
return e.Platforms, nil
}
return nil, &NotLoadedError{edge: "platforms"}
}
// OutOfScopePlatformsOrErr returns the OutOfScopePlatforms value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) OutOfScopePlatformsOrErr() ([]*Platform, error) {
if e.loadedTypes[30] {
return e.OutOfScopePlatforms, nil
}
return nil, &NotLoadedError{edge: "out_of_scope_platforms"}
}
// SourcePlatformsOrErr returns the SourcePlatforms value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) SourcePlatformsOrErr() ([]*Platform, error) {
if e.loadedTypes[31] {
return e.SourcePlatforms, nil
}
return nil, &NotLoadedError{edge: "source_platforms"}
}
// EntityTypeOrErr returns the EntityType value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) EntityTypeOrErr() (*EntityType, error) {
if e.EntityType != nil {
return e.EntityType, nil
} else if e.loadedTypes[32] {
return nil, &NotFoundError{label: entitytype.Label}
}
return nil, &NotLoadedError{edge: "entity_type"}
}
// LogoFileOrErr returns the LogoFile value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found.
func (e EntityEdges) LogoFileOrErr() (*File, error) {
if e.LogoFile != nil {
return e.LogoFile, nil
} else if e.loadedTypes[33] {
return nil, &NotFoundError{label: file.Label}
}
return nil, &NotLoadedError{edge: "logo_file"}
}
// InternalPoliciesOrErr returns the InternalPolicies value or an error if the edge
// was not loaded in eager-loading.
func (e EntityEdges) InternalPoliciesOrErr() ([]*InternalPolicy, error) {
if e.loadedTypes[34] {
return e.InternalPolicies, nil
}
return nil, &NotLoadedError{edge: "internal_policies"}
}
// scanValues returns the types for scanning values from sql.Rows.
func (*Entity) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case entity.FieldLastReviewedAt, entity.FieldSoc2PeriodEnd, entity.FieldContractStartDate, entity.FieldContractEndDate, entity.FieldNextReviewAt, entity.FieldContractRenewalAt, entity.FieldObservedAt:
values[i] = &sql.NullScanner{S: new(models.DateTime)}
case entity.FieldTags, entity.FieldDomains, entity.FieldLinkedAssetIds, entity.FieldProvidedServices, entity.FieldLinks, entity.FieldVendorMetadata:
values[i] = new([]byte)
case entity.FieldSystemOwned, entity.FieldApprovedForUse, entity.FieldHasSoc2, entity.FieldAutoRenews, entity.FieldSSOEnforced, entity.FieldMfaSupported, entity.FieldMfaEnforced:
values[i] = new(sql.NullBool)
case entity.FieldAnnualSpend:
values[i] = new(sql.NullFloat64)
case entity.FieldTerminationNoticeDays, entity.FieldRiskScore, entity.FieldRiskScoreCoverage:
values[i] = new(sql.NullInt64)
case entity.FieldID, entity.FieldCreatedBy, entity.FieldUpdatedBy, entity.FieldDeletedBy, entity.FieldOwnerID, entity.FieldInternalOwner, entity.FieldInternalOwnerUserID, entity.FieldInternalOwnerGroupID, entity.FieldReviewedBy, entity.FieldReviewedByUserID, entity.FieldReviewedByGroupID, entity.FieldInternalNotes, entity.FieldSystemInternalID, entity.FieldEntityRelationshipStateName, entity.FieldEntityRelationshipStateID, entity.FieldEntitySecurityQuestionnaireStatusName, entity.FieldEntitySecurityQuestionnaireStatusID, entity.FieldEntitySourceTypeName, entity.FieldEntitySourceTypeID, entity.FieldEnvironmentName, entity.FieldEnvironmentID, entity.FieldScopeName, entity.FieldScopeID, entity.FieldName, entity.FieldDisplayName, entity.FieldDescription, entity.FieldEntityTypeID, entity.FieldStatus, entity.FieldSpendCurrency, entity.FieldBillingModel, entity.FieldRenewalRisk, entity.FieldStatusPageURL, entity.FieldRiskRating, entity.FieldTier, entity.FieldReviewFrequency, entity.FieldLogoRemoteURL, entity.FieldLogoFileID, entity.FieldExternalID:
values[i] = new(sql.NullString)
case entity.FieldCreatedAt, entity.FieldUpdatedAt, entity.FieldDeletedAt:
values[i] = new(sql.NullTime)
case entity.ForeignKeys[0]: // entity_type_entities
values[i] = new(sql.NullString)
case entity.ForeignKeys[1]: // finding_entities
values[i] = new(sql.NullString)
case entity.ForeignKeys[2]: // remediation_entities
values[i] = new(sql.NullString)
case entity.ForeignKeys[3]: // review_entities
values[i] = new(sql.NullString)
case entity.ForeignKeys[4]: // risk_entities
values[i] = new(sql.NullString)
case entity.ForeignKeys[5]: // scan_entities
values[i] = new(sql.NullString)
case entity.ForeignKeys[6]: // vulnerability_entities
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
}
}
return values, nil
}
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Entity fields.
func (_m *Entity) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}
for i := range columns {
switch columns[i] {
case entity.FieldID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field id", values[i])
} else if value.Valid {
_m.ID = value.String
}
case entity.FieldCreatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field created_at", values[i])
} else if value.Valid {
_m.CreatedAt = value.Time
}
case entity.FieldUpdatedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field updated_at", values[i])
} else if value.Valid {
_m.UpdatedAt = value.Time
}
case entity.FieldCreatedBy:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field created_by", values[i])
} else if value.Valid {
_m.CreatedBy = value.String
}
case entity.FieldUpdatedBy:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field updated_by", values[i])
} else if value.Valid {
_m.UpdatedBy = value.String
}
case entity.FieldDeletedAt:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
} else if value.Valid {
_m.DeletedAt = value.Time
}
case entity.FieldDeletedBy:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field deleted_by", values[i])
} else if value.Valid {
_m.DeletedBy = value.String
}
case entity.FieldTags:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field tags", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.Tags); err != nil {
return fmt.Errorf("unmarshal field tags: %w", err)
}
}
case entity.FieldOwnerID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field owner_id", values[i])
} else if value.Valid {
_m.OwnerID = value.String
}
case entity.FieldInternalOwner:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field internal_owner", values[i])
} else if value.Valid {
_m.InternalOwner = value.String
}
case entity.FieldInternalOwnerUserID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field internal_owner_user_id", values[i])
} else if value.Valid {
_m.InternalOwnerUserID = value.String
}
case entity.FieldInternalOwnerGroupID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field internal_owner_group_id", values[i])
} else if value.Valid {
_m.InternalOwnerGroupID = value.String
}
case entity.FieldReviewedBy:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field reviewed_by", values[i])
} else if value.Valid {
_m.ReviewedBy = value.String
}
case entity.FieldReviewedByUserID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field reviewed_by_user_id", values[i])
} else if value.Valid {
_m.ReviewedByUserID = value.String
}
case entity.FieldReviewedByGroupID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field reviewed_by_group_id", values[i])
} else if value.Valid {
_m.ReviewedByGroupID = value.String
}
case entity.FieldLastReviewedAt:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field last_reviewed_at", values[i])
} else if value.Valid {
_m.LastReviewedAt = new(models.DateTime)
*_m.LastReviewedAt = *value.S.(*models.DateTime)
}
case entity.FieldSystemOwned:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field system_owned", values[i])
} else if value.Valid {
_m.SystemOwned = value.Bool
}
case entity.FieldInternalNotes:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field internal_notes", values[i])
} else if value.Valid {
_m.InternalNotes = new(string)
*_m.InternalNotes = value.String
}
case entity.FieldSystemInternalID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field system_internal_id", values[i])
} else if value.Valid {
_m.SystemInternalID = new(string)
*_m.SystemInternalID = value.String
}
case entity.FieldEntityRelationshipStateName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field entity_relationship_state_name", values[i])
} else if value.Valid {
_m.EntityRelationshipStateName = value.String
}
case entity.FieldEntityRelationshipStateID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field entity_relationship_state_id", values[i])
} else if value.Valid {
_m.EntityRelationshipStateID = value.String
}
case entity.FieldEntitySecurityQuestionnaireStatusName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field entity_security_questionnaire_status_name", values[i])
} else if value.Valid {
_m.EntitySecurityQuestionnaireStatusName = value.String
}
case entity.FieldEntitySecurityQuestionnaireStatusID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field entity_security_questionnaire_status_id", values[i])
} else if value.Valid {
_m.EntitySecurityQuestionnaireStatusID = value.String
}
case entity.FieldEntitySourceTypeName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field entity_source_type_name", values[i])
} else if value.Valid {
_m.EntitySourceTypeName = value.String
}
case entity.FieldEntitySourceTypeID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field entity_source_type_id", values[i])
} else if value.Valid {
_m.EntitySourceTypeID = value.String
}
case entity.FieldEnvironmentName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field environment_name", values[i])
} else if value.Valid {
_m.EnvironmentName = value.String
}
case entity.FieldEnvironmentID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field environment_id", values[i])
} else if value.Valid {
_m.EnvironmentID = value.String
}
case entity.FieldScopeName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field scope_name", values[i])
} else if value.Valid {
_m.ScopeName = value.String
}
case entity.FieldScopeID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field scope_id", values[i])
} else if value.Valid {
_m.ScopeID = value.String
}
case entity.FieldName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid {
_m.Name = value.String
}
case entity.FieldDisplayName:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field display_name", values[i])
} else if value.Valid {
_m.DisplayName = value.String
}
case entity.FieldDescription:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field description", values[i])
} else if value.Valid {
_m.Description = value.String
}
case entity.FieldDomains:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field domains", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.Domains); err != nil {
return fmt.Errorf("unmarshal field domains: %w", err)
}
}
case entity.FieldEntityTypeID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field entity_type_id", values[i])
} else if value.Valid {
_m.EntityTypeID = value.String
}
case entity.FieldStatus:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
_m.Status = enums.EntityStatus(value.String)
}
case entity.FieldApprovedForUse:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field approved_for_use", values[i])
} else if value.Valid {
_m.ApprovedForUse = value.Bool
}
case entity.FieldLinkedAssetIds:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field linked_asset_ids", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.LinkedAssetIds); err != nil {
return fmt.Errorf("unmarshal field linked_asset_ids: %w", err)
}
}
case entity.FieldHasSoc2:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field has_soc2", values[i])
} else if value.Valid {
_m.HasSoc2 = value.Bool
}
case entity.FieldSoc2PeriodEnd:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field soc2_period_end", values[i])
} else if value.Valid {
_m.Soc2PeriodEnd = new(models.DateTime)
*_m.Soc2PeriodEnd = *value.S.(*models.DateTime)
}
case entity.FieldContractStartDate:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field contract_start_date", values[i])
} else if value.Valid {
_m.ContractStartDate = new(models.DateTime)
*_m.ContractStartDate = *value.S.(*models.DateTime)
}
case entity.FieldContractEndDate:
if value, ok := values[i].(*sql.NullScanner); !ok {
return fmt.Errorf("unexpected type %T for field contract_end_date", values[i])
} else if value.Valid {
_m.ContractEndDate = new(models.DateTime)
*_m.ContractEndDate = *value.S.(*models.DateTime)
}
case entity.FieldAutoRenews:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field auto_renews", values[i])
} else if value.Valid {
_m.AutoRenews = value.Bool
}
case entity.FieldTerminationNoticeDays:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field termination_notice_days", values[i])
} else if value.Valid {
_m.TerminationNoticeDays = int(value.Int64)
}
case entity.FieldAnnualSpend:
if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field annual_spend", values[i])
} else if value.Valid {
_m.AnnualSpend = value.Float64
}
case entity.FieldSpendCurrency:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field spend_currency", values[i])
} else if value.Valid {
_m.SpendCurrency = value.String
}
case entity.FieldBillingModel:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field billing_model", values[i])
} else if value.Valid {
_m.BillingModel = value.String
}
case entity.FieldRenewalRisk:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field renewal_risk", values[i])
} else if value.Valid {
_m.RenewalRisk = value.String
}
case entity.FieldSSOEnforced:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field sso_enforced", values[i])
} else if value.Valid {
_m.SSOEnforced = value.Bool
}
case entity.FieldMfaSupported:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field mfa_supported", values[i])
} else if value.Valid {
_m.MfaSupported = value.Bool
}
case entity.FieldMfaEnforced:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field mfa_enforced", values[i])
} else if value.Valid {
_m.MfaEnforced = value.Bool
}
case entity.FieldStatusPageURL:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field status_page_url", values[i])
} else if value.Valid {
_m.StatusPageURL = value.String
}
case entity.FieldProvidedServices:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field provided_services", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.ProvidedServices); err != nil {
return fmt.Errorf("unmarshal field provided_services: %w", err)
}
}
case entity.FieldLinks:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field links", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.Links); err != nil {
return fmt.Errorf("unmarshal field links: %w", err)
}
}
case entity.FieldRiskRating:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field risk_rating", values[i])
} else if value.Valid {
_m.RiskRating = value.String
}
case entity.FieldRiskScore: