@@ -2,28 +2,28 @@ package graphkb
2
2
3
3
import (
4
4
"fmt"
5
+
5
6
"github.com/clems4ever/go-graphkb/internal/knowledge"
7
+ "github.com/clems4ever/go-graphkb/internal/schema"
6
8
"github.com/clems4ever/go-graphkb/internal/sources"
7
- "github.com/spf13/viper"
8
9
)
9
10
10
11
type ImporterOptions struct {
11
- CacheGraph bool
12
+ URL string
13
+ AuthToken string
14
+ SkipVerify bool
12
15
}
13
16
14
- func Start (source sources.Source , options * ImporterOptions ) error {
15
- url := viper .GetString ("graphkb.url" )
16
- if url == "" {
17
+ func Start (source sources.Source , options ImporterOptions ) error {
18
+ if options .URL == "" {
17
19
return fmt .Errorf ("Please provide graphkb URL in configuration file" )
18
20
}
19
-
20
- authToken := viper .GetString ("graphkb.auth_token" )
21
- if authToken == "" {
21
+ if options .AuthToken == "" {
22
22
return fmt .Errorf ("Please provide a graphkb auth token to communicate with GraphKB" )
23
23
}
24
24
25
25
observableSource := sources .NewObservableSource (source )
26
- api := knowledge .NewGraphAPI (url , authToken )
26
+ api := knowledge .NewGraphAPI (options . URL , options . AuthToken , options . SkipVerify )
27
27
graphImporter := knowledge .NewGraphImporter (api )
28
28
29
29
if err := observableSource .Start (graphImporter ); err != nil {
@@ -32,3 +32,15 @@ func Start(source sources.Source, options *ImporterOptions) error {
32
32
33
33
return nil
34
34
}
35
+
36
+ func CreateRelation (fromType schema.AssetType , relation , toType schema.AssetType ) RelationType {
37
+ return schema.RelationType {
38
+ FromType : fromType ,
39
+ Type : RelationKeyType (relation ),
40
+ ToType : toType ,
41
+ }
42
+ }
43
+
44
+ func CreateAsset (fromType string ) AssetType {
45
+ return schema .AssetType (fromType )
46
+ }
0 commit comments