Skip to content

Commit

Permalink
Fix empty testdata file diff; fix simple diff bug (chainguard-dev#350)
Browse files Browse the repository at this point in the history
Signed-off-by: egibs <[email protected]>
  • Loading branch information
egibs authored Jul 10, 2024
1 parent cc54df7 commit 2f158fb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion pkg/render/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ func matchFragmentLink(s string) string {
}

func (r Markdown) File(ctx context.Context, fr *bincapz.FileReport) error {
markdownTable(ctx, fr, r.w, tableConfig{Title: fmt.Sprintf("## %s [%s]", fr.Path, mdRisk(fr.RiskScore, fr.RiskLevel))})
if len(fr.Behaviors) != 0 {
markdownTable(ctx, fr, r.w, tableConfig{Title: fmt.Sprintf("## %s [%s]", fr.Path, mdRisk(fr.RiskScore, fr.RiskLevel))})
}
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/render/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (r Simple) File(_ context.Context, fr *bincapz.FileReport) error {
return nil
}

if fr.Behaviors != nil {
if len(fr.Behaviors) != 0 {
fmt.Fprintf(r.w, "# %s\n", fr.Path)
}

Expand Down Expand Up @@ -63,7 +63,7 @@ func (r Simple) Full(_ context.Context, rep *bincapz.Report) error {
}
}

for f, fr := range rep.Diff.Removed {
for f, fr := range rep.Diff.Added {
fmt.Fprintf(r.w, "++++ added: %s\n", f)

var bs []*bincapz.Behavior
Expand Down
12 changes: 7 additions & 5 deletions pkg/render/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ func ShortRisk(s string) string {
}

func (r Terminal) File(ctx context.Context, fr *bincapz.FileReport) error {
renderTable(ctx, fr, r.w,
tableConfig{
Title: fmt.Sprintf("%s %s", fr.Path, darkBrackets(decorativeRisk(fr.RiskScore, fr.RiskLevel))),
},
)
if len(fr.Behaviors) != 0 {
renderTable(ctx, fr, r.w,
tableConfig{
Title: fmt.Sprintf("%s %s", fr.Path, darkBrackets(decorativeRisk(fr.RiskScore, fr.RiskLevel))),
},
)
}
return nil
}

Expand Down
Empty file.

0 comments on commit 2f158fb

Please sign in to comment.