Ver Fonte

chore: reduce generic-api-key fps (#1707)

Based on scanning ziglang/zig and oven-sh/bun
Richard Gomez há 1 ano atrás
pai
commit
0e3f4f7abb

+ 1 - 0
cmd/generate/config/base/config.go

@@ -102,6 +102,7 @@ func CreateGlobalConfig() config.Config {
 				//regexp.MustCompile(`vendor`),
 				//regexp.MustCompile(`vendor`),
 			},
 			},
 			StopWords: []string{
 			StopWords: []string{
+				"abcdefghijklmnopqrstuvwxyz", // character range
 				// ----------- Secrets -----------
 				// ----------- Secrets -----------
 				// Checkmarx client secret. (https://github.com/checkmarx-ts/checkmarx-python-sdk/blob/86560f6e2a3e46d16322101294da10d5d190312d/README.md?plain=1#L56)
 				// Checkmarx client secret. (https://github.com/checkmarx-ts/checkmarx-python-sdk/blob/86560f6e2a3e46d16322101294da10d5d190312d/README.md?plain=1#L56)
 				"014df517-39d1-4453-b7b3-9930c563627c",
 				"014df517-39d1-4453-b7b3-9930c563627c",

+ 18 - 4
cmd/generate/config/rules/generic.go

@@ -55,6 +55,7 @@ func GenericCredential() *config.Rule {
 						// Access
 						// Access
 						`accessor` +
 						`accessor` +
 						`|access[_.-]?id` +
 						`|access[_.-]?id` +
+						`|random[_.-]?access` +
 						// API
 						// API
 						`|api[_.-]?(version|id)` + // version/id -> not a secret
 						`|api[_.-]?(version|id)` + // version/id -> not a secret
 						`|rapid|capital` + // common words containing "api"
 						`|rapid|capital` + // common words containing "api"
@@ -66,15 +67,15 @@ func GenericCredential() *config.Rule {
 						// Credentials
 						// Credentials
 						`|(credentials?[_.-]?id|withCredentials)` + // Jenkins plugins
 						`|(credentials?[_.-]?id|withCredentials)` + // Jenkins plugins
 						// Key
 						// Key
-						`|(bucket|foreign|hot|natural|primary|schema|sequence)[_.-]?key` +
-						`|key[_.-]?(alias|board|code|id|name|ring|selector|size|stone|storetype|word|up|down|left|right)` +
+						`|(bucket|foreign|hot|idx|natural|primary|pub(lic)?|schema|sequence)[_.-]?key` +
+						`|key[_.-]?(alias|board|code|frame|id|length|mesh|name|pair|ring|selector|signature|size|stone|storetype|word|up|down|left|right)` +
 						// Azure KeyVault
 						// Azure KeyVault
 						`|key[_.-]?vault[_.-]?(id|name)|keyVaultToStoreSecrets` +
 						`|key[_.-]?vault[_.-]?(id|name)|keyVaultToStoreSecrets` +
 						`|key(store|tab)[_.-]?(file|path)` +
 						`|key(store|tab)[_.-]?(file|path)` +
 						`|issuerkeyhash` + // part of ssl cert
 						`|issuerkeyhash` + // part of ssl cert
 						`|(?-i:[DdMm]onkey|[DM]ONKEY)|keying` + // common words containing "key"
 						`|(?-i:[DdMm]onkey|[DM]ONKEY)|keying` + // common words containing "key"
 						// Secret
 						// Secret
-						`|(secret)[_.-]?name` + // name of e.g. env variable
+						`|(secret)[_.-]?(length|name|size)` + // name of e.g. env variable
 						`|UserSecretsId` + // https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-8.0&tabs=linux
 						`|UserSecretsId` + // https://learn.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-8.0&tabs=linux
 
 
 						// Token
 						// Token
@@ -82,7 +83,7 @@ func GenericCredential() *config.Rule {
 
 
 						// General
 						// General
 						`|(api|credentials|token)[_.-]?(endpoint|ur[il])` +
 						`|(api|credentials|token)[_.-]?(endpoint|ur[il])` +
-						`|public[_.-]?(key|token)` + // public key -> not a secret
+						`|public[_.-]?token` +
 						`|(key|token)[_.-]?file` +
 						`|(key|token)[_.-]?file` +
 						`)`),
 						`)`),
 				},
 				},
@@ -129,6 +130,8 @@ func GenericCredential() *config.Rule {
 		// Access
 		// Access
 		`"accessor":"rA1wk0Y45YCufyfq",`,
 		`"accessor":"rA1wk0Y45YCufyfq",`,
 		`report_access_id: e8e4df51-2054-49b0-ab1c-516ac95c691d`,
 		`report_access_id: e8e4df51-2054-49b0-ab1c-516ac95c691d`,
+		`_RandomAccessIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX11 `,
 
 
 		// API
 		// API
 		`this.ultraPictureBox1.Name = "ultraPictureBox1";`,
 		`this.ultraPictureBox1.Name = "ultraPictureBox1";`,
@@ -160,6 +163,8 @@ func GenericCredential() *config.Rule {
 		// Key
 		// Key
 		`keyword: "Befaehigung_P2"`,
 		`keyword: "Befaehigung_P2"`,
 		`public_key = "9Cnzj4p4WGeKLs1Pt8QuKUpRKfFLfRYC9AIKjbJTWit"`,
 		`public_key = "9Cnzj4p4WGeKLs1Pt8QuKUpRKfFLfRYC9AIKjbJTWit"`,
+		`pub const X509_pubkey_st = struct_X509_pubkey_st;`,
+		`|| pIdxKey->default_rc==0`,
 		`monkeys-audio:mx64-uwp=fail`,
 		`monkeys-audio:mx64-uwp=fail`,
 		`primaryKey=` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
 		`primaryKey=` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
 		`foreignKey=` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
 		`foreignKey=` + newPlausibleSecret(`[a-zA-Z0-9\-_.=]{30}`),
@@ -184,6 +189,13 @@ func GenericCredential() *config.Rule {
 		`	"key_vault_name": "web21prqodx24021",`,
 		`	"key_vault_name": "web21prqodx24021",`,
 		`  keyVaultToStoreSecrets: cmp2-qat-1208358310`, // e.g., https://github.com/2uasimojo/community-operators-prod/blob/9e51e4c8e0b5caaa3087e8e18e6fb918b2c36643/operators/azure-service-operator/1.0.59040/manifests/azure.microsoft.com_cosmosdbs.yaml#L50
 		`  keyVaultToStoreSecrets: cmp2-qat-1208358310`, // e.g., https://github.com/2uasimojo/community-operators-prod/blob/9e51e4c8e0b5caaa3087e8e18e6fb918b2c36643/operators/azure-service-operator/1.0.59040/manifests/azure.microsoft.com_cosmosdbs.yaml#L50
 		`,apiKey:"6fe4476ee5a1832882e326b506d14126",`,
 		`,apiKey:"6fe4476ee5a1832882e326b506d14126",`,
+		`const validKeyChars = "0123456789abcdefghijklmnopqrstuvwxyz_-."`,
+		`const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"`,
+		`key_length = XSalsa20.key_length`,
+		`pub const SN_id_Gost28147_89_None_KeyMeshing = "id-Gost28147-89-None-KeyMeshing"`,
+		`KeyPair = X25519.KeyPair`,
+		`BlindKeySignatures = Ed25519.BlindKeySignatures`,
+		`AVEncVideoMaxKeyframeDistance, "2987123a-ba93-4704-b489-ec1e5f25292c"`,
 		// `<add key="SchemaTable" value="G:\SchemaTable.xml" />`,
 		// `<add key="SchemaTable" value="G:\SchemaTable.xml" />`,
 		//	`secret:
 		//	`secret:
 		// secretName: app-decryption-secret
 		// secretName: app-decryption-secret
@@ -203,6 +215,8 @@ R5: Regulatory--21`,
 		// Secret
 		// Secret
 		`LLM_SECRET_NAME = "NEXUS-GPT4-API-KEY"`,
 		`LLM_SECRET_NAME = "NEXUS-GPT4-API-KEY"`,
 		`  <UserSecretsId>79a3edd0-2092-40a2-a04d-dcb46d5ca9ed</UserSecretsId>`,
 		`  <UserSecretsId>79a3edd0-2092-40a2-a04d-dcb46d5ca9ed</UserSecretsId>`,
+		`secret_length = X25519.secret_length`,
+		`secretSize must be >= XXH3_SECRET_SIZE_MIN`,
 
 
 		// Token
 		// Token
 		`    access_token_url='https://github.com/login/oauth/access_token',`,
 		`    access_token_url='https://github.com/login/oauth/access_token',`,

+ 1 - 1
cmd/generate/config/rules/privatekey.go

@@ -21,7 +21,7 @@ func PrivateKey() *config.Rule {
 anything
 anything
 -----END PRIVATE KEY-----`,
 -----END PRIVATE KEY-----`,
 		`-----BEGIN RSA PRIVATE KEY-----
 		`-----BEGIN RSA PRIVATE KEY-----
-abcdefghijklmnopqrstuvwxyz
+abcdefghijksmnopqrstuvwxyz
 -----END RSA PRIVATE KEY-----
 -----END RSA PRIVATE KEY-----
 `,
 `,
 		`-----BEGIN PRIVATE KEY BLOCK-----
 		`-----BEGIN PRIVATE KEY BLOCK-----

+ 2 - 1
config/gitleaks.toml

@@ -51,6 +51,7 @@ paths = [
     '''Database.refactorlog''',
     '''Database.refactorlog''',
 ]
 ]
 stopwords = [
 stopwords = [
+    "abcdefghijklmnopqrstuvwxyz",
     "014df517-39d1-4453-b7b3-9930c563627c",
     "014df517-39d1-4453-b7b3-9930c563627c",
 ]
 ]
 
 
@@ -583,7 +584,7 @@ regexes = [
 [[rules.allowlists]]
 [[rules.allowlists]]
 regexTarget = "match"
 regexTarget = "match"
 regexes = [
 regexes = [
-    '''(?i)(accessor|access[_.-]?id|api[_.-]?(version|id)|rapid|capital|[a-z0-9-]*?api[a-z0-9-]*?:jar:|author|X-MS-Exchange-Organization-Auth|Authentication-Results|(credentials?[_.-]?id|withCredentials)|(bucket|foreign|hot|natural|primary|schema|sequence)[_.-]?key|key[_.-]?(alias|board|code|id|name|ring|selector|size|stone|storetype|word|up|down|left|right)|key[_.-]?vault[_.-]?(id|name)|keyVaultToStoreSecrets|key(store|tab)[_.-]?(file|path)|issuerkeyhash|(?-i:[DdMm]onkey|[DM]ONKEY)|keying|(secret)[_.-]?name|UserSecretsId|(io\.jsonwebtoken[ \t]?:[ \t]?[\w-]+)|(api|credentials|token)[_.-]?(endpoint|ur[il])|public[_.-]?(key|token)|(key|token)[_.-]?file)''',
+    '''(?i)(accessor|access[_.-]?id|random[_.-]?access|api[_.-]?(version|id)|rapid|capital|[a-z0-9-]*?api[a-z0-9-]*?:jar:|author|X-MS-Exchange-Organization-Auth|Authentication-Results|(credentials?[_.-]?id|withCredentials)|(bucket|foreign|hot|idx|natural|primary|pub(lic)?|schema|sequence)[_.-]?key|key[_.-]?(alias|board|code|frame|id|length|mesh|name|pair|ring|selector|signature|size|stone|storetype|word|up|down|left|right)|key[_.-]?vault[_.-]?(id|name)|keyVaultToStoreSecrets|key(store|tab)[_.-]?(file|path)|issuerkeyhash|(?-i:[DdMm]onkey|[DM]ONKEY)|keying|(secret)[_.-]?(length|name|size)|UserSecretsId|(io\.jsonwebtoken[ \t]?:[ \t]?[\w-]+)|(api|credentials|token)[_.-]?(endpoint|ur[il])|public[_.-]?token|(key|token)[_.-]?file)''',
 ]
 ]
 stopwords = [
 stopwords = [
     "000000",
     "000000",