Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/generate/config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func main() {
rules.KubernetesSecret(),
rules.KucoinAccessToken(),
rules.KucoinSecretKey(),
rules.LangsmithApiKey(),
rules.LaunchDarklyAccessToken(),
rules.LinearAPIToken(),
rules.LinearClientSecret(),
Expand Down Expand Up @@ -179,6 +180,7 @@ func main() {
rules.OpenAI(),
rules.OpenshiftUserToken(),
rules.PerplexityAPIKey(),
rules.PineconeApiKey(),
rules.PlaidAccessID(),
rules.PlaidSecretKey(),
rules.PlaidAccessToken(),
Expand Down
39 changes: 39 additions & 0 deletions cmd/generate/config/rules/langsmith.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package rules

import (
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
)

func LangsmithApiKey() *config.Rule {
// define rule
r := config.Rule{
RuleID: "langsmith-api-key",
Description: "Detected a LangSmith API Key (personal access token or service key), which may expose LangChain/LangSmith tracing data, prompts, and connected LLM workloads.",
// LangSmith keys carry a distinctive `lsv2_pt_` (personal access token)
// or `lsv2_sk_` (service key) prefix followed by a hex body and checksum.
Regex: utils.GenerateUniqueTokenRegex(`lsv2_(?:pt|sk)_[a-z0-9]{32}_[a-z0-9]{10}`, false),
Entropy: 3,
Keywords: []string{
"lsv2_pt_",
"lsv2_sk_",
},
}

// validate
tps := []string{
utils.GenerateSampleSecret("langsmith",
"lsv2_pt_"+secrets.NewSecret(utils.AlphaNumeric("32"))+"_"+secrets.NewSecret(utils.AlphaNumeric("10"))),
utils.GenerateSampleSecret("langchain",
"lsv2_sk_"+secrets.NewSecret(utils.AlphaNumeric("32"))+"_"+secrets.NewSecret(utils.AlphaNumeric("10"))),
`LANGCHAIN_API_KEY=lsv2_pt_` + secrets.NewSecret(utils.AlphaNumeric("32")) + "_" + secrets.NewSecret(utils.AlphaNumeric("10")),
}
fps := []string{
// Legacy `ls__` keys (unsupported since 2024-10-22) and unrelated prefixes.
`LANGCHAIN_API_KEY=ls__0123456789abcdef0123456789abcdef`,
// Wrong key type segment.
`lsv2_xx_0123456789abcdef0123456789abcdef_0123456789`,
}
return utils.Validate(r, tps, fps)
}
31 changes: 31 additions & 0 deletions cmd/generate/config/rules/pinecone.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package rules

import (
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
"github.com/zricethezav/gitleaks/v8/config"
)

func PineconeApiKey() *config.Rule {
// define rule
r := config.Rule{
RuleID: "pinecone-api-key",
Description: "Identified a Pinecone API Key, which may grant access to vector database indexes backing RAG and AI applications, risking exfiltration of embedded data.",
Regex: utils.GenerateUniqueTokenRegex(`pcsk_[A-Za-z0-9]{5,6}_[A-Za-z0-9]{63}`, false),
Entropy: 3,
Keywords: []string{
"pcsk_",
},
}

// validate
tps := utils.GenerateSampleSecrets("pinecone",
"pcsk_"+secrets.NewSecret(`[A-Za-z0-9]{5}`)+"_"+secrets.NewSecret(utils.AlphaNumeric("63")))
fps := []string{
// Too short body.
`pinecone_api_key = "pcsk_abcde_tooShort"`,
// Wrong prefix.
`pccm_abcde_0123456789012345678901234567890123456789012345678901234567890123`,
}
return utils.Validate(r, tps, fps)
}
17 changes: 17 additions & 0 deletions config/gitleaks.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2468,6 +2468,16 @@ description = "Discovered a Kucoin Secret Key, which could lead to compromised c
regex = '''(?i)[\w.-]{0,50}?(?:kucoin)(?:[ \t\w.-]{0,20})[\s'"]{0,3}(?:=|>|:{1,3}=|\|\||:|=>|\?=|,)[\x60'"\s=]{0,5}([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:[\x60'"\s;]|\\[nr]|$)'''
keywords = ["kucoin"]

[[rules]]
id = "langsmith-api-key"
description = "Detected a LangSmith API Key (personal access token or service key), which may expose LangChain/LangSmith tracing data, prompts, and connected LLM workloads."
regex = '''\b(lsv2_(?:pt|sk)_[a-z0-9]{32}_[a-z0-9]{10})(?:[\x60'"\s;]|\\[nr]|$)'''
entropy = 3
keywords = [
"lsv2_pt_",
"lsv2_sk_",
]

[[rules]]
id = "launchdarkly-access-token"
description = "Uncovered a Launchdarkly Access Token, potentially compromising feature flag management and application functionality."
Expand Down Expand Up @@ -2721,6 +2731,13 @@ regex = '''\b(pplx-[a-zA-Z0-9]{48})(?:[\x60'"\s;]|\\[nr]|$|\b)'''
entropy = 4
keywords = ["pplx-"]

[[rules]]
id = "pinecone-api-key"
description = "Identified a Pinecone API Key, which may grant access to vector database indexes backing RAG and AI applications, risking exfiltration of embedded data."
regex = '''\b(pcsk_[A-Za-z0-9]{5,6}_[A-Za-z0-9]{63})(?:[\x60'"\s;]|\\[nr]|$)'''
entropy = 3
keywords = ["pcsk_"]

[[rules]]
id = "pkcs12-file"
description = "Found a PKCS #12 file, which commonly contain bundled private keys."
Expand Down