Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore low severity malwares #113

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading