Skip to content

Commit

Permalink
incorporated the review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
patilpankaj212 committed Dec 15, 2020
1 parent 305a8e2 commit 49562fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
23 changes: 3 additions & 20 deletions pkg/results/types.go
Expand Up @@ -18,8 +18,6 @@ package results

import (
"time"

"github.com/accurics/terrascan/pkg/utils"
)

// Violation Contains data for each violation
Expand Down Expand Up @@ -73,24 +71,9 @@ func (vs ViolationStore) Add(extra ViolationStore) ViolationStore {
}

// AddSummary will update the summary with remaining details
func (vs *ViolationStore) AddSummary(iacType, iacFilePath, iacDirPath string) {
if iacType == "" {
// the default scan type is terraform
vs.Summary.IacType = "terraform"
} else {
vs.Summary.IacType = iacType
}
func (vs *ViolationStore) AddSummary(iacType, iacResourcePath string) {

if iacFilePath != "" {
// can skip the error as the file validation is already done
// while executor is initialized
filePath, _ := utils.GetAbsPath(iacFilePath)
vs.Summary.ResourcePath = filePath
} else {
// can skip the error as the directory validation is already done
// while executor is initialized
dirPath, _ := utils.GetAbsPath(iacDirPath)
vs.Summary.ResourcePath = dirPath
}
vs.Summary.IacType = iacType
vs.Summary.ResourcePath = iacResourcePath
vs.Summary.Timestamp = time.Now().UTC().String()
}
7 changes: 6 additions & 1 deletion pkg/runtime/executor.go
Expand Up @@ -123,8 +123,13 @@ func (e *Executor) Execute() (results Output, err error) {

results.Violations = policy.EngineOutputFromViolationStore(&violations)

resourcePath := e.filePath
if resourcePath == "" {
resourcePath = e.dirPath
}

// add other summary details after policies are evaluated
results.Violations.ViolationStore.AddSummary(e.iacType, e.filePath, e.dirPath)
results.Violations.ViolationStore.AddSummary(e.iacType, resourcePath)

// send notifications, if configured
if err = e.SendNotifications(results); err != nil {
Expand Down

0 comments on commit 49562fe

Please sign in to comment.