🌱 Fixed field alignment (#3799)

- Fixed field alignment

Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
This commit is contained in:
Naveen 2024-01-17 13:10:33 -06:00 committed by GitHub
parent 4a2dfa96be
commit f1d7a62059
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 31 additions and 42 deletions

View File

@ -45,14 +45,12 @@ const (
)
// Location represents the location of a finding.
//
//nolint:govet
type Location struct {
Type FileType `json:"type"`
Path string `json:"path"`
LineStart *uint `json:"lineStart,omitempty"`
LineEnd *uint `json:"lineEnd,omitempty"`
Snippet *string `json:"snippet,omitempty"`
Path string `json:"path"`
Type FileType `json:"type"`
}
// Outcome is the result of a finding.
@ -96,23 +94,19 @@ const (
)
// Finding represents a finding.
//
//nolint:govet
type Finding struct {
Probe string `json:"probe"`
Outcome Outcome `json:"outcome"`
Message string `json:"message"`
Location *Location `json:"location,omitempty"`
Remediation *probe.Remediation `json:"remediation,omitempty"`
Values map[string]int `json:"values,omitempty"`
Probe string `json:"probe"`
Message string `json:"message"`
Outcome Outcome `json:"outcome"`
}
// AnonymousFinding is a finding without a corerpsonding probe ID.
type AnonymousFinding struct {
Finding
// Remove the probe ID from
// the structure until the probes are GA.
Probe string `json:"probe,omitempty"`
Finding
}
var errInvalid = errors.New("invalid")

View File

@ -38,15 +38,14 @@ func Test_FromBytes(t *testing.T) {
positiveOutcome := OutcomePositive
negativeOutcome := OutcomeNegative
t.Parallel()
//nolint:govet
tests := []struct {
err error
outcome *Outcome
metadata map[string]string
finding *Finding
name string
id string
path string
outcome *Outcome
err error
metadata map[string]string
finding *Finding
}{
{
name: "effort low",
@ -205,10 +204,10 @@ func TestOutcome_UnmarshalYAML(t *testing.T) {
type args struct {
n *yaml.Node
}
tests := []struct { //nolint:govet
tests := []struct {
args args
name string
wantOutcome Outcome
args args
wantErr bool
}{
{

View File

@ -74,11 +74,10 @@ func (s stubDigester) Digest(name string) (string, error) {
func TestCreateDockerfilePinningRemediation(t *testing.T) {
t.Parallel()
//nolint:govet
tests := []struct {
name string
dep checker.Dependency
expected *rule.Remediation
dep checker.Dependency
name string
}{
{
name: "no depdendency",
@ -143,12 +142,12 @@ func TestCreateDockerfilePinningRemediation(t *testing.T) {
func TestCreateWorkflowPinningRemediation(t *testing.T) {
t.Parallel()
tests := []struct { //nolint:govet
tests := []struct {
expected *rule.Remediation
name string
branch string
repo string
filepath string
expected *rule.Remediation
}{
{
name: "valid input",

View File

@ -55,14 +55,13 @@ type jsonRemediation struct {
Effort RemediationEffort `yaml:"effort"`
}
//nolint:govet
type jsonRule struct {
Short string `yaml:"short"`
Desc string `yaml:"desc"`
Motivation string `yaml:"motivation"`
Implementation string `yaml:"implementation"`
Risk Risk `yaml:"risk"`
Remediation jsonRemediation `yaml:"remediation"`
Risk Risk `yaml:"risk"`
}
// Risk indicates a risk.
@ -81,14 +80,13 @@ const (
RiskCritical
)
//nolint:govet
type Rule struct {
Remediation *Remediation
Name string
Short string
Desc string
Motivation string
Risk Risk
Remediation *Remediation
}
var errInvalid = errors.New("invalid")

View File

@ -34,12 +34,11 @@ var testfs embed.FS
func Test_New(t *testing.T) {
t.Parallel()
//nolint:govet
tests := []struct {
name string
id string
err error
rule *Rule
name string
id string
}{
{
name: "all fields set",
@ -131,10 +130,10 @@ func TestRisk_GreaterThan(t *testing.T) {
func TestRisk_String(t *testing.T) {
t.Parallel()
tests := []struct { //nolint:govet
tests := []struct {
name string
r Risk
want string
r Risk
}{
{
name: "RiskNone",
@ -182,10 +181,10 @@ func TestRisk_String(t *testing.T) {
func TestRemediationEffort_String(t *testing.T) {
t.Parallel()
tests := []struct { //nolint:govet
tests := []struct {
name string
effort RemediationEffort
want string
effort RemediationEffort
}{
{
name: "RemediationEffortNone",
@ -228,10 +227,10 @@ func TestRemediationEffort_String(t *testing.T) {
func TestRisk_UnmarshalYAML(t *testing.T) {
t.Parallel()
tests := []struct { //nolint:govet
tests := []struct {
wantErr error
name string
input string
wantErr error
want Risk
}{
{
@ -283,10 +282,10 @@ func TestRisk_UnmarshalYAML(t *testing.T) {
func TestRemediationEffort_UnmarshalYAML(t *testing.T) {
t.Parallel()
tests := []struct { //nolint:govet
tests := []struct {
wantErr error
name string
input string
wantErr error
want RemediationEffort
}{
{
@ -328,10 +327,10 @@ func TestRemediationEffort_UnmarshalYAML(t *testing.T) {
func Test_validate(t *testing.T) {
t.Parallel()
tests := []struct { //nolint:govet
name string
rule *jsonRule
tests := []struct {
wantErr error
rule *jsonRule
name string
}{
{
name: "valid",