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

Add risk levels to simple output #516

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 4 additions & 4 deletions pkg/render/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ func (r Simple) Full(_ context.Context, rep *malcontent.Report) error {
}

func maxLength(bs []*malcontent.Behavior) int {
max := 0
m := 0
for _, b := range bs {
if len(b.ID) > max {
max = len(b.ID)
if len(b.ID) > m {
m = len(b.ID)
}
}

return max
return m
}
13 changes: 7 additions & 6 deletions test_data/samples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,13 @@ func TestSimple(t *testing.T) {
}

mc := malcontent.Config{
Concurrency: runtime.NumCPU(),
IgnoreSelf: false,
IgnoreTags: []string{"harmless"},
Renderer: simple,
RuleFS: []fs.FS{rules.FS, thirdparty.FS},
ScanPaths: []string{binPath},
Concurrency: runtime.NumCPU(),
IgnoreSelf: false,
IgnoreTags: []string{"harmless"},
QuantityIncreasesRisk: true,
Copy link
Member Author

@egibs egibs Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tstromberg -- without this, some of our known malicious samples are registering as high instead of critical. I guess we never noticed since the risk level was never displayed in the simple reports.

make refresh-sample-testdata calls malcontent where QuantityIncreasesRisk defaults to true which explains the discrepancy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, we do use QuantityIncreasesRisk: true for the markdown tests but not the diff or JSON tests.

Renderer: simple,
RuleFS: []fs.FS{rules.FS, thirdparty.FS},
ScanPaths: []string{binPath},
}

tcLogger := clog.FromContext(ctx).With("test", name)
Expand Down