-
Notifications
You must be signed in to change notification settings - Fork 185
Conversation
110288b
to
8acd3c4
Compare
8acd3c4
to
84b4e25
Compare
84b4e25
to
fc49af1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think err
vs jsonError
is worth fixing.
Other comments stem from me not fully understanding what Metadata
will contain, and so getting paranoid about edge cases. Those are safe to ignore!
Co-authored-by: Pete Wagner <1559510+thepwagner@users.noreply.github.com>
3e8bb1e
to
c5f3234
Compare
c5f3234
to
2ad506d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No blockers, just an optimization idea.
internal/sarif/sarif.go
Outdated
formattedMap[k] = v | ||
} | ||
|
||
metadata, jsonErr := json.Marshal(formattedMap) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we don't use this value if len(formattedMap) > 0
below.
While it's pretty cheap to render {}
, we could just skip that by moving the map construction and JSON serialization to be within the guard.
I checked and kubeaudit.Metadata
is a typedef of map[string]string
- could we just use that directly to skip all of the map construction?
var metadataTxt string
if len(result.Metadata) > 0 {
metadata, jsonErr := json.Marshal(result.Metadata)
...
metadataTxt = fmt.Sprintf("Metadata: %s\n", string(metadata))
}
Nobody will notice the like 8 bytes of memory that we save, but we will know. 😎
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah! excellent point! applied here
This is to add the Metadata field/info to the sarif. We currently display this info on the CLI. but it was missing on the sarif. Here's an example of what it will look like on Github UI: