Skip to content

Commit

Permalink
Ignore low severity malwares (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramanan-ravi authored Dec 4, 2024
1 parent 1b00031 commit a7e570a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
9 changes: 4 additions & 5 deletions pkg/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@ package output
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"strings"
"time"
"unicode/utf8"

"github.com/deepfence/YaraHunter/utils"
pb "github.com/deepfence/agent-plugins-grpc/srcgo"
log "github.com/sirupsen/logrus"

// "github.com/fatih/color"

"os"
"strings"
"time"
"unicode/utf8"

tw "github.com/olekukonko/tablewriter"
)

Expand Down
19 changes: 5 additions & 14 deletions pkg/scan/process_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package scan
import (
"bytes"
"errors"
"fmt"
"io"
"math"
"os/exec"
Expand All @@ -11,8 +12,6 @@ import (
"syscall"
"unsafe"

"fmt"

"github.com/gabriel-vasile/mimetype"

"github.com/deepfence/YaraHunter/pkg/output"
Expand All @@ -34,13 +33,6 @@ type manifestItem struct {
LayerIds []string `json:",omitempty"`
}

type fileMatches struct {
fileName string
iocs []output.IOCFound
updatedScore float64
updatedSeverity string
}

func calculateSeverity(lenMatch int, severity string, severityScore float64) (string, float64) {

updatedSeverity := "low"
Expand Down Expand Up @@ -214,12 +206,11 @@ func ScanFile(s *Scanner, fileName string, f io.ReadSeeker, fsize int, iocs *[]o
Matches: matches,
})
}
var fileMat fileMatches
fileMat.fileName = fileName
fileMat.iocs = iocsFound
updatedSeverity, updatedScore := calculateSeverity(totalMatches, "low", 0)
fileMat.updatedSeverity = updatedSeverity
fileMat.updatedScore = updatedScore
if updatedSeverity == "low" {
// Ignore low severity malwares
return nil
}
if len(matches) > 0 {
for _, m := range iocsFound {
m.FileSeverity = updatedSeverity
Expand Down

0 comments on commit a7e570a

Please sign in to comment.