-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added new 'reconcile' command (skeleton only)
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
Copyright © 2020 SAP | ||
*/ | ||
|
||
package cmd | ||
|
||
import ( | ||
"github.com/sap/project-kb/kaybee/internal/tasks" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// var vulnerabilityID string | ||
|
||
// reconcileCmd represents the reconcile command | ||
var reconcileCmd = &cobra.Command{ | ||
Use: "reconcile", | ||
Short: "Manually reconcile conflicting statements", | ||
Long: ``, | ||
Run: doReconcile, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(reconcileCmd) | ||
// reconcileCmd.Flags().StringVarP(&vulnerabilityID, "reconcile", "r", "", "Vulnerability to reconcile") | ||
} | ||
|
||
func doReconcile(cmd *cobra.Command, args []string) { | ||
var vulnerabilityID string = args[0] | ||
|
||
t := tasks.ReconcileTask{ | ||
Sources: configuration.Sources(), | ||
VulnerabilityID: vulnerabilityID, | ||
} | ||
|
||
t.Verbose(verbose) | ||
t.Execute() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package tasks | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/sap/project-kb/kaybee/internal/conf" | ||
) | ||
|
||
// ReconcileTask is the task that performs merging of statements, reconciling any | ||
// conflicts using a set of pre-defined policies. | ||
type ReconcileTask struct { | ||
BaseTask | ||
Sources []conf.Source | ||
VulnerabilityID string | ||
} | ||
|
||
// NewReconcileTask constructs a new ReconcileTask | ||
func NewReconcileTask() (mergeTask *ReconcileTask) { | ||
|
||
mt := ReconcileTask{} | ||
return &mt | ||
} | ||
|
||
func (t *ReconcileTask) validate() (ok bool) { | ||
|
||
return true | ||
} | ||
|
||
// Execute performs the actual task and returns true on success | ||
func (t *ReconcileTask) Execute() (success bool) { | ||
|
||
if t.verbose { | ||
fmt.Println("Reconciling statements for vulnerability ID: " + t.VulnerabilityID) | ||
fmt.Println("Using sources:") | ||
for _, s := range t.Sources { | ||
fmt.Println(s) | ||
} | ||
} | ||
|
||
t.validate() | ||
|
||
fmt.Println("WARNING: Reconcile task not implemented yet!") | ||
|
||
return true | ||
} |