github.com/prebid/prebid-server/v2@v2.18.0/.semgrep/adapter/builder-struct-name.go (about) 1 /* 2 builder-struct-name tests 3 https://semgrep.dev/docs/writing-rules/testing-rules 4 "ruleid" prefix in comment indicates patterns that should be flagged by semgrep 5 "ok" prefix in comment indidcates patterns that should not be flagged by the semgrep 6 */ 7 8 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 9 foo1 := foo{} 10 // ruleid: builder-struct-name-check 11 return &fooadapter{foo: foo1}, nil 12 } 13 14 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 15 // ruleid: builder-struct-name-check 16 return &adapterbar{}, nil 17 } 18 19 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 20 // ruleid: builder-struct-name-check 21 return &fooadapterbar{}, nil 22 } 23 24 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 25 // ruleid: builder-struct-name-check 26 return &FooAdapter{}, nil 27 } 28 29 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 30 // ruleid: builder-struct-name-check 31 return &AdapterBar{}, nil 32 } 33 34 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 35 // ruleid: builder-struct-name-check 36 return &AdapterBar{}, nil 37 } 38 39 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 40 // ruleid: builder-struct-name-check 41 return &FooAdapterBar{}, nil 42 } 43 44 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 45 foo2 := foo{} 46 //ruleid: builder-struct-name-check 47 adpt1 := Adapter{foo: foo2} 48 return &adpt1, nil 49 } 50 51 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 52 //ruleid: builder-struct-name-check 53 builder := &Adapter{foo{}} 54 return builder, nil 55 } 56 57 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 58 foo3 := foo{} 59 if foo3.bar == "" { 60 foo3.bar = "bar" 61 } 62 //ruleid: builder-struct-name-check 63 adpt2 := Adapter{} 64 adpt2.foo = foo3 65 return &adpt2, nil 66 } 67 68 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 69 //ruleid: builder-struct-name-check 70 return &foo{}, nil 71 } 72 73 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 74 //ruleid: builder-struct-name-check 75 var obj Adapter 76 obj.Foo = "foo" 77 if obj.Bar == "" { 78 obj.Bar = "bar" 79 } 80 return &obj, nil 81 } 82 83 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 84 //ruleid: builder-struct-name-check 85 var obj *FooAdapterBar 86 obj.Foo = "foo" 87 if obj.Bar == "" { 88 obj.Bar = "bar" 89 } 90 return obj, nil 91 } 92 93 func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { 94 // ok: builder-struct-name-check 95 return &adapter{endpoint: "www.foo.com"}, nil 96 } 97 98 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 99 builder := &adapter{} 100 builder.endpoint = "www.foo.com" 101 // ok: builder-struct-name-check 102 return builder, nil 103 } 104 105 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 106 builder := adapter{} 107 builder.endpoint = "www.foo.com" 108 // ok: builder-struct-name-check 109 return &builder, nil 110 } 111 112 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 113 var builder adapter 114 builder.endpoint = "www.foo.com" 115 // ok: builder-struct-name-check 116 return &builder, nil 117 } 118 119 func Builder(_ openrtb_ext.BidderName, config config.Adapter, _ config.Server) (adapters.Bidder, error) { 120 var builder *adapter 121 builder.endpoint = "www.foo.com" 122 // ok: builder-struct-name-check 123 return builder, nil 124 }