diff --git a/rules/unsafe.go b/rules/unsafe.go index 1d89ea9..d3d55c9 100644 --- a/rules/unsafe.go +++ b/rules/unsafe.go @@ -35,7 +35,7 @@ func (r *UsingUnsafe) Match(n ast.Node, c *gas.Context) (gi *gas.Issue, err erro func NewUsingUnsafe(conf map[string]interface{}) (r gas.Rule, n ast.Node) { r = &UsingUnsafe{ - pattern: regexp.MustCompile(`unsafe.*`), + pattern: regexp.MustCompile(`unsafe\..*`), MetaData: gas.MetaData{ What: "Use of unsafe calls should be audited", Severity: gas.Low, diff --git a/rules/unsafe_test.go b/rules/unsafe_test.go index 7714901..2b4f5c3 100644 --- a/rules/unsafe_test.go +++ b/rules/unsafe_test.go @@ -33,7 +33,13 @@ func TestUnsafe(t *testing.T) { "unsafe" ) + type Fake struct{} + + func (Fake) Good() {} + func main() { + unsafeM := Fake{} + unsafeM.Good() intArray := [...]int{1, 2} fmt.Printf("\nintArray: %v\n", intArray) intPtr := &intArray[0]