mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 21:24:21 +01:00
reduce telegram... todo url and xml for later
This commit is contained in:
1 parent
9a4538c4d6
commit
db63fc1bf4
2 files changed
+18
-18
No files matched your search
@@ -1,6 +1,8 @@
|
|||||||
package rules
|
package rules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
@@ -13,40 +15,38 @@ func TelegramBotToken() *config.Rule {
|
|||||||
Description: "Detected a Telegram Bot API Token, risking unauthorized bot operations and message interception on Telegram.",
|
Description: "Detected a Telegram Bot API Token, risking unauthorized bot operations and message interception on Telegram.",
|
||||||
RuleID: "telegram-bot-api-token",
|
RuleID: "telegram-bot-api-token",
|
||||||
|
|
||||||
Regex: regexp.MustCompile(`(?i)(?:^|\b|bot)([0-9]{5,16}:A[a-z0-9_\-]{34})(?:$|\b[^_\-])`),
|
Regex: regexp.MustCompile(`(?i:(?:telegr)(?:[0-9a-z\(-_\t .\\]{0,40})(?:[\s|']|[\s|"]){0,3})(?:=|\|\|:|<=|=>|:|\?=|\()(?:'|\"|\s|=|\x60){0,5}([0-9]{5,16}:A[a-z0-9_\-]{34})(?:['|\"|\n|\r|\s|\x60|;|\\]|$)`),
|
||||||
Keywords: []string{
|
Keywords: []string{
|
||||||
"telegram",
|
"telegr",
|
||||||
"api",
|
|
||||||
"bot",
|
|
||||||
"token",
|
|
||||||
"url",
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
fmt.Println("r: ", r.Regex.String())
|
||||||
|
|
||||||
|
// https://regex101.com/r/7fFAhS/1
|
||||||
// validate
|
// validate
|
||||||
var (
|
var (
|
||||||
validToken = secrets.NewSecret(numeric("8") + ":A" + alphaNumericExtendedShort("34"))
|
validToken = secrets.NewSecret(numeric("8") + ":A" + alphaNumericExtendedShort("34"))
|
||||||
minToken = secrets.NewSecret(numeric("5") + ":A" + alphaNumericExtendedShort("34"))
|
minToken = secrets.NewSecret(numeric("5") + ":A" + alphaNumericExtendedShort("34"))
|
||||||
maxToken = secrets.NewSecret(numeric("16") + ":A" + alphaNumericExtendedShort("34"))
|
maxToken = secrets.NewSecret(numeric("16") + ":A" + alphaNumericExtendedShort("34"))
|
||||||
xsdWithToken = secrets.NewSecret(`<xsd:element name="AgencyIdentificationCode" type="` + numeric("5") + `:A` + alphaNumericExtendedShort("34") + `"/>`)
|
// xsdWithToken = secrets.NewSecret(`<xsd:element name="AgencyIdentificationCode" type="` + numeric("5") + `:A` + alphaNumericExtendedShort("34") + `"/>`)
|
||||||
)
|
)
|
||||||
tps := []string{
|
tps := []string{
|
||||||
// variable assignment
|
// variable assignment
|
||||||
generateSampleSecret("telegram", validToken),
|
generateSampleSecret("telegram", validToken),
|
||||||
// URL containing token
|
// URL containing token TODO add another url based rule
|
||||||
generateSampleSecret("url", "https://api.telegram.org/bot"+validToken+"/sendMessage"),
|
// generateSampleSecret("url", "https://api.telegram.org/bot"+validToken+"/sendMessage"),
|
||||||
// object constructor
|
// object constructor
|
||||||
`const bot = new Telegraf("` + validToken + `")`,
|
`const bot = new Telegraf("` + validToken + `")`,
|
||||||
// .env
|
// .env
|
||||||
`API_TOKEN = ` + validToken,
|
`TELEGRAM_API_TOKEN = ` + validToken,
|
||||||
// YAML
|
// YAML
|
||||||
`bot: ` + validToken,
|
`telegram bot: ` + validToken,
|
||||||
// Token with min bot_id
|
// Token with min bot_id
|
||||||
generateSampleSecret("telegram", minToken),
|
generateSampleSecret("telegram", minToken),
|
||||||
// Token with max bot_id
|
// Token with max bot_id
|
||||||
generateSampleSecret("telegram", maxToken),
|
generateSampleSecret("telegram", maxToken),
|
||||||
// Valid token in XSD document
|
// Valid token in XSD document TODO separate rule for this
|
||||||
generateSampleSecret("telegram", xsdWithToken),
|
// generateSampleSecret("telegram", xsdWithToken),
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -2774,9 +2774,9 @@ keywords = [
|
|||||||
[[rules]]
|
[[rules]]
|
||||||
id = "telegram-bot-api-token"
|
id = "telegram-bot-api-token"
|
||||||
description = "Detected a Telegram Bot API Token, risking unauthorized bot operations and message interception on Telegram."
|
description = "Detected a Telegram Bot API Token, risking unauthorized bot operations and message interception on Telegram."
|
||||||
regex = '''(?i)(?:^|\b|bot)([0-9]{5,16}:A[a-z0-9_\-]{34})(?:$|\b[^_\-])'''
|
regex = '''(?i:(?:telegr)(?:[0-9a-z\(-_\t .\\]{0,40})(?:[\s|']|[\s|"]){0,3})(?:=|\|\|:|<=|=>|:|\?=|\()(?:'|\"|\s|=|\x60){0,5}([0-9]{5,16}:A[a-z0-9_\-]{34})(?:['|\"|\n|\r|\s|\x60|;|\\]|$)'''
|
||||||
keywords = [
|
keywords = [
|
||||||
"telegram","api","bot","token","url",
|
"telegr",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
|
|||||||
Reference in new issue
Block a user