Skip to content

Commit 91fc03c

Browse files
committed
feat: Added new 'reconcile' command (skeleton only)
1 parent 5634e46 commit 91fc03c

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ all: $(SUBDIRS) build-docs
2929
$(SUBDIRS):
3030
$(MAKE) -C $@
3131

32+
build:
33+
$(MAKE) --directory=kaybee build
34+
35+
test:
36+
$(MAKE) --directory=kaybee test
37+
3238
deploy-docs:
3339
mkdocs gh-deploy
3440

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRn
421421
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
422422
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
423423
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
424+
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a h1:Ob5/580gVHBJZgXnff1cZDbG+xLtMVE5mDRTe+nIsX4=
424425
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
425426
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
426427
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=

kaybee/cmd/reconcile.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright © 2020 SAP
3+
*/
4+
5+
package cmd
6+
7+
import (
8+
"github.com/sap/project-kb/kaybee/internal/tasks"
9+
"github.com/spf13/cobra"
10+
)
11+
12+
// var vulnerabilityID string
13+
14+
// reconcileCmd represents the reconcile command
15+
var reconcileCmd = &cobra.Command{
16+
Use: "reconcile",
17+
Short: "Manually reconcile conflicting statements",
18+
Long: ``,
19+
Run: doReconcile,
20+
}
21+
22+
func init() {
23+
rootCmd.AddCommand(reconcileCmd)
24+
// reconcileCmd.Flags().StringVarP(&vulnerabilityID, "reconcile", "r", "", "Vulnerability to reconcile")
25+
}
26+
27+
func doReconcile(cmd *cobra.Command, args []string) {
28+
var vulnerabilityID string = args[0]
29+
30+
t := tasks.ReconcileTask{
31+
Sources: configuration.Sources(),
32+
VulnerabilityID: vulnerabilityID,
33+
}
34+
35+
t.Verbose(verbose)
36+
t.Execute()
37+
}

kaybee/internal/tasks/reconcile.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package tasks
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/sap/project-kb/kaybee/internal/conf"
7+
)
8+
9+
// ReconcileTask is the task that performs merging of statements, reconciling any
10+
// conflicts using a set of pre-defined policies.
11+
type ReconcileTask struct {
12+
BaseTask
13+
Sources []conf.Source
14+
VulnerabilityID string
15+
}
16+
17+
// NewReconcileTask constructs a new ReconcileTask
18+
func NewReconcileTask() (mergeTask *ReconcileTask) {
19+
20+
mt := ReconcileTask{}
21+
return &mt
22+
}
23+
24+
func (t *ReconcileTask) validate() (ok bool) {
25+
26+
return true
27+
}
28+
29+
// Execute performs the actual task and returns true on success
30+
func (t *ReconcileTask) Execute() (success bool) {
31+
32+
if t.verbose {
33+
fmt.Println("Reconciling statements for vulnerability ID: " + t.VulnerabilityID)
34+
fmt.Println("Using sources:")
35+
for _, s := range t.Sources {
36+
fmt.Println(s)
37+
}
38+
}
39+
40+
t.validate()
41+
42+
fmt.Println("WARNING: Reconcile task not implemented yet!")
43+
44+
return true
45+
}

0 commit comments

Comments
 (0)