| 1 |
package slack |
| 2 |
|
| 3 |
import ( |
| 4 |
"github.com/DefangLabs/secret-detector/pkg/detectors/helpers" |
| 5 |
"github.com/DefangLabs/secret-detector/pkg/secrets" |
| 6 |
) |
| 7 |
|
| 8 |
const ( |
| 9 |
Name = "slack" |
| 10 |
secretType = "Slack token" |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
tokensRegex = `(?:(?:xoxe\.)?xox[bp]|xox[aeosr]|xapp)-\d+-[-a-zA-Z0-9]+` |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
webhookRegex = `https://hooks\.slack\.com/services/T[a-zA-Z0-9_]+/B[a-zA-Z0-9_]+/[a-zA-Z0-9_]+` |
| 32 |
) |
| 33 |
|
| 34 |
func init() { |
| 35 |
secrets.GetDetectorFactory().Register(Name, NewDetector) |
| 36 |
} |
| 37 |
|
| 38 |
type detector struct { |
| 39 |
secrets.Detector |
| 40 |
} |
| 41 |
|
| 42 |
func NewDetector(config ...string) secrets.Detector { |
| 43 |
return &detector{ |
| 44 |
Detector: helpers.NewRegexDetectorBuilder(secretType, tokensRegex, webhookRegex).Build(), |
| 45 |
} |
| 46 |
} |