Skip to content

G705 false finding when no guard can be resolved #1553

@leonnicolas

Description

@leonnicolas

This simple test case is raising a G705.

package main

import (
	"fmt"
	"os"
)

func main() {
	fmt.Fprint(os.Stdout, os.Args[1])
}

The guard is skipped because the http.ResponseWriter type is not resolved.
Does it make sense to not satisfy the guards when all (or even any) guard types cannot be resolved?

When adding the type

package main

import (
	"fmt"
	"os"
	"net/http"
)

func main() {
	_ = http.ResponseWriter(nil)
	fmt.Fprint(os.Stdout, os.Args[1])
}

gosec does not find anything.

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