-
Notifications
You must be signed in to change notification settings - Fork 0
/
repository.go
77 lines (67 loc) · 3.53 KB
/
repository.go
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
// Package stix is the parent package to the Notion STIX integration, API, and CLI.
//
//go:generate goapi-gen -generate types,server,spec -package api --out internal/api/api.gen.go ./internal/api/openapi.yaml
package notionstix
import (
"context"
"github.com/TcM1911/stix2"
"github.com/dstotijn/go-notion"
)
// Repository defines the interface for interacting with the Notion database.
type Repository interface {
CollectionRepository
AttackPatternRepository
CampaignRepository
MalwareRepository
IntrusionSetRepository
}
// Store is the interface that defines the methods for a key-value store.
type Store interface {
Get(key string) ([]byte, error)
Set(key string, value []byte) error
Cleanup()
}
type AttackPatternRepository interface {
// ListAttackPatterns returns a slice of AttackPattern objects.
ListAttackPatterns(collection *stix2.Collection) []*stix2.AttackPattern
// CreateAttackPatternsDatabase creates a new Notion database for AttackPatterns.
CreateAttackPatternsDatabase(ctx context.Context, client *notion.Client, parentPageID string) (notion.Database, error)
// CreateAttackPatternPage creates a new Notion page for a specific AttackPattern.
CreateAttackPatternPage(ctx context.Context, client *notion.Client, databaseID string, attackPattern *stix2.AttackPattern) (notion.Page, error)
}
type IntrusionSetRepository interface {
// ListIntrusionSets returns a slice of Group objects.
ListIntrusionSets(collection *stix2.Collection) []*stix2.IntrusionSet
// CreateIntrusionSetsDatabase creates a new Notion database for IntrusionSets.
CreateIntrusionSetsDatabase(ctx context.Context, client *notion.Client, parentPageID string) (notion.Database, error)
// CreateIntrusionSetPage creates a new Notion page for a specific Group.
CreateIntrusionSetPage(ctx context.Context, client *notion.Client, databaseID string, group *stix2.IntrusionSet) (notion.Page, error)
}
type CampaignRepository interface {
// ListCampaigns returns a slice of Campaign objects.
ListCampaigns() []*stix2.Campaign
// CreateCampaignsDatabase creates a new Notion database for Campaigns.
CreateCampaignsDatabase(ctx context.Context, client *notion.Client, parentPageID string) (notion.Database, error)
// CreateCampaignPage creates a new Notion page for a specific Campaign.
CreateCampaignPage(ctx context.Context, client *notion.Client, db notion.Database, campaign *stix2.Campaign) (notion.Page, error)
}
type IndicatorRepository interface {
// ListIndicators returns a slice of Indicator objects.
ListIndicators() []*stix2.Indicator
// CreateIndicatorsDatabase creates a new Notion database for Indicators.
CreateIndicatorsDatabase(ctx context.Context, client *notion.Client, parentPageID string) (notion.Database, error)
// CreateIndicatorPage creates a new Notion page for a specific Indicator.
CreateIndicatorPage(ctx context.Context, client *notion.Client, db notion.Database, indicator *stix2.Indicator) (notion.Page, error)
}
type MalwareRepository interface {
// ListMalware returns a slice of Malware objects.
ListMalware() []*stix2.Malware
// CreateMalwareDatabase creates a new Notion database for Malware.
CreateMalwareDatabase(ctx context.Context, client *notion.Client, parentPageID string) (notion.Database, error)
// CreateMalwarePage creates a new Notion page for a specific Malware.
CreateMalwarePage(ctx context.Context, client *notion.Client, db notion.Database, malware *stix2.Malware) (notion.Page, error)
}
type CollectionRepository interface {
// ListCollection returns the entire collection of STIX objects.
ListCollection() *stix2.Collection
}