Skip to content

Rule G601 does not recognize a pointer to a struct field #966

@futuretea

Description

@futuretea

Summary

Steps to reproduce the behavior

The following code is currently not recognized by Rule G601

package main

import (
	"fmt"
)

type sampleStruct struct {
	name string
}

func main() {
	samples := []sampleStruct{
		{name: "a"},
		{name: "b"},
	}
	for _, sample := range samples {
		fmt.Println(&sample.name)
	}
}

gosec version

master

Go version (output of 'go version')

Operating system / Environment

Expected behavior

For the above code, G601 should prompt a warning

Actual behavior

For the above code, G601 does not have any warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions