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

False positive pattern in loop pointer rule #2972

Open
romdr opened this issue Jun 21, 2023 · 1 comment
Open

False positive pattern in loop pointer rule #2972

romdr opened this issue Jun 21, 2023 · 1 comment

Comments

@romdr
Copy link

romdr commented Jun 21, 2023

This pattern seems incorrect:

      - pattern: |
          for _, $VALUE := range $SOURCE {
            <... $ANYTHING(..., <... $VALUE ...>, ...) ...>
          }

This triggers a semgrep warning:

	input := []string{"a", "b", "c"}
	output := []string{}

	for _, val := range input {
		output = append(output, val)
	}

There is no pointer involved here.

Go Playground example here.

Semgrep Playground example:
image

@enncoded
Copy link
Contributor

Hey! Thanks for filing this issue :)

I don't think Semgrep can do that kind of type analysis over contents of a collection in Go right now. I filed an issue to the engine team semgrep/semgrep#8117, so hopefully this should be fixed soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants