github.com/prebid/prebid-server/v2@v2.18.0/.semgrep/adapter/builder-struct-name.yml (about) 1 rules: 2 - id: builder-struct-name-check 3 languages: 4 - go 5 message: | 6 You can call this simply "adapter", the `$BUILDER` identification is already supplied by the package name. As you have it, referencing your adapter from outside the package would be `$BUILDER.$BUILDER` which looks a little redundant. See example below: 7 8 ``` 9 package foo 10 11 type adapter struct { 12 endpoint string 13 } 14 15 func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { 16 return &adapter{endpoint: "https://www.foo.com"}, nil 17 } 18 ``` 19 severity: ERROR 20 patterns: 21 - pattern-either: 22 - pattern-inside: > 23 func Builder($BIDDER_NAME openrtb_ext.BidderName, $CONFIG config.Adapter, $SERVER config.Server) (adapters.Bidder, error) { 24 ... 25 $BUILDER_OBJ := &$BUILDER{...} 26 ... 27 return $BUILDER_OBJ, nil 28 } 29 - pattern-inside: > 30 func Builder($BIDDER_NAME openrtb_ext.BidderName, $CONFIG config.Adapter, $SERVER config.Server) (adapters.Bidder, error) { 31 ... 32 $BUILDER_OBJ := $BUILDER{...} 33 ... 34 return &$BUILDER_OBJ, nil 35 } 36 - pattern-inside: > 37 func Builder($BIDDER_NAME openrtb_ext.BidderName, $CONFIG config.Adapter, $SERVER config.Server) (adapters.Bidder, error) { 38 ... 39 return &$BUILDER{...}, ... 40 } 41 - pattern-inside: > 42 func Builder($BIDDER_NAME openrtb_ext.BidderName, $CONFIG config.Adapter, $SERVER config.Server) (adapters.Bidder, error) { 43 ... 44 var $BUILDER_OBJ $BUILDER 45 ... 46 return &$BUILDER_OBJ, ... 47 } 48 - pattern-inside: > 49 func Builder($BIDDER_NAME openrtb_ext.BidderName, $CONFIG config.Adapter, $SERVER config.Server) (adapters.Bidder, error) { 50 ... 51 var $BUILDER_OBJ *$BUILDER 52 ... 53 return $BUILDER_OBJ, ... 54 } 55 - focus-metavariable: $BUILDER 56 - metavariable-regex: 57 metavariable: $BUILDER 58 regex: (?!adapter$)