Add detection rule for Anthropic API keys
What does this MR do?
Adds rule for Anthropic API keys. Rule was provided by Anthropic.
Click to expand test results of running *regex-scoring manually
~/code/regex-scoring(master) $ cat anthrop.toml
[[rules]]
id = "anthropic_key"
description = "Anthropic keys"
regex = '''\b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$)'''
keywords = [
"sk-ant-",
]
~/code/regex-scoring(master) $ go run main.go -tomlFile=anthrop.toml
File to parse for rules: anthrop.toml
SCORE: 2 / 3 File: negative_scenarios Regex: \b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$) Token: sk-ant-inh09-fFmeKQn8EThQL9WEnHHoorxVGKg4266YlipB8kj4pfccHJjC9_UHtYF43fM7eGLcLaw8Bepz_R9OVDTn3rNzI5-WsDpHaOT}
SCORE: 51 / 52 File: positive_scenarios Regex: \b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$) Token: sk-ant-inh09-fFmeKQn8EThQL9WEnHHoorxVGKg4266YlipB8kj4pfccHJjC9_UHtYF43fM7eGLcLaw8Bepz_R9OVDTn3rNzI5-WsDpHaOT}
~/code/regex-scoring(master) $
~/code/regex-scoring(master) $ go run main.go -tomlFile=anthrop.toml
File to parse for rules: anthrop.toml
SCORE: 3 / 3 File: negative_scenarios Regex: \b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$) Token: sk-ant-hxv86-2tnsgAf5mLCdAgRqa2iBpuTproWdBQ9vWoWBpXbWINjjTayXxniiz-aaSsRZWH2XvTmkoyqsREDOm4yemacoGO-LyJop3Mi
SCORE: 51 / 52 File: positive_scenarios Regex: \b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$) Token: sk-ant-hxv86-2tnsgAf5mLCdAgRqa2iBpuTproWdBQ9vWoWBpXbWINjjTayXxniiz-aaSsRZWH2XvTmkoyqsREDOm4yemacoGO-LyJop3Mi
~/code/regex-scoring(master) $ go run main.go -tomlFile=anthrop.toml
File to parse for rules: anthrop.toml
SCORE: 3 / 3 File: negative_scenarios Regex: \b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$) Token: sk-ant-mhm42-gWkilqiNY_86QkCrMoe8tvhbINtcbkFKk_HKM8UuCDdrZLQloxYUS_HWdPNbdAhXh_vA3GWMhTVjXovim0difM-i07HMpF-
SCORE: 51 / 52 File: positive_scenarios Regex: \b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$) Token: sk-ant-mhm42-gWkilqiNY_86QkCrMoe8tvhbINtcbkFKk_HKM8UuCDdrZLQloxYUS_HWdPNbdAhXh_vA3GWMhTVjXovim0difM-i07HMpF-
~/code/regex-scoring(master) $ go run main.go -tomlFile=anthrop.toml
File to parse for rules: anthrop.toml
SCORE: 3 / 3 File: negative_scenarios Regex: \b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$) Token: sk-ant-pxs93-5FDuZtmUlXURSs_TjuxXfgYCBTgjyF3wVEiCXGTVJIfVhyNUC3IONx-S_0veziE4Bh71a_t51E47rVMw_pHbZu-lm8VOoXK
SCORE: 51 / 52 File: positive_scenarios Regex: \b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$) Token: sk-ant-pxs93-5FDuZtmUlXURSs_TjuxXfgYCBTgjyF3wVEiCXGTVJIfVhyNUC3IONx-S_0veziE4Bh71a_t51E47rVMw_pHbZu-lm8VOoXK
~/code/regex-scoring(master) $ go run main.go -tomlFile=anthrop.toml -debug
File to parse for rules: anthrop.toml
DIDN'T MATCH: aaaask-ant-kdi78-0mwyCwJdeeACpsFVpG4145-DhxDzv6Ca2_PvRIzbp1zsARScyI_Ty6Mu53cV7OOb9tDCZi0tMfR8D9ALBVUd8V-cgQ9htod*
DIDN'T MATCH: aaaask-ant-kdi78-0mwyCwJdeeACpsFVpG4145-DhxDzv6Ca2_PvRIzbp1zsARScyI_Ty6Mu53cV7OOb9tDCZi0tMfR8D9ALBVUd8V-cgQ9htod*aaaa
SCORE: 2 / 3 File: negative_scenarios Regex: \b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$) Token: sk-ant-kdi78-0mwyCwJdeeACpsFVpG4145-DhxDzv6Ca2_PvRIzbp1zsARScyI_Ty6Mu53cV7OOb9tDCZi0tMfR8D9ALBVUd8V-cgQ9htod*
DIDN'T MATCH: _sk-ant-kdi78-0mwyCwJdeeACpsFVpG4145-DhxDzv6Ca2_PvRIzbp1zsARScyI_Ty6Mu53cV7OOb9tDCZi0tMfR8D9ALBVUd8V-cgQ9htod*
SCORE: 51 / 52 File: positive_scenarios Regex: \b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$) Token: sk-ant-kdi78-0mwyCwJdeeACpsFVpG4145-DhxDzv6Ca2_PvRIzbp1zsARScyI_Ty6Mu53cV7OOb9tDCZi0tMfR8D9ALBVUd8V-cgQ9htod*
~/code/regex-scoring(master) $ go run main.go -tomlFile=anthrop.toml -debug
File to parse for rules: anthrop.toml
DIDN'T MATCH: aaaask-ant-gso30-ZTLOjnczGi200Ysvw78umKIQdQsQNDQP8ijchrbTUKZxiNoERhKOyRrGUsPUGpLhhjWP3q3TJ6KemTnbiUTPrW-9WS295gN
DIDN'T MATCH: aaaask-ant-gso30-ZTLOjnczGi200Ysvw78umKIQdQsQNDQP8ijchrbTUKZxiNoERhKOyRrGUsPUGpLhhjWP3q3TJ6KemTnbiUTPrW-9WS295gNaaaa
DIDN'T MATCH: sk-ant-gso30-ZTLOjnczGi200Ysvw78umKIQdQsQNDQP8ijchrbTUKZxiNoERhKOyRrGUsPUGpLhhjWP3q3TJ6KemTnbiUTPrW-9WS295gNaaaa
SCORE: 3 / 3 File: negative_scenarios Regex: \b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$) Token: sk-ant-gso30-ZTLOjnczGi200Ysvw78umKIQdQsQNDQP8ijchrbTUKZxiNoERhKOyRrGUsPUGpLhhjWP3q3TJ6KemTnbiUTPrW-9WS295gN
DIDN'T MATCH: _sk-ant-gso30-ZTLOjnczGi200Ysvw78umKIQdQsQNDQP8ijchrbTUKZxiNoERhKOyRrGUsPUGpLhhjWP3q3TJ6KemTnbiUTPrW-9WS295gN
SCORE: 51 / 52 File: positive_scenarios Regex: \b(sk-ant-[a-z]{3}\d{2}-[A-Za-z0-9\-_]{86}-[A-Za-z0-9\-_]{8})(?:[[:punct:]]|[[:space:]]|[[:blank:]]|$) Token: sk-ant-gso30-ZTLOjnczGi200Ysvw78umKIQdQsQNDQP8ijchrbTUKZxiNoERhKOyRrGUsPUGpLhhjWP3q3TJ6KemTnbiUTPrW-9WS295gN
- Scoring is being ran manually as this has not yet been integrated into https://gitlab.com/gitlab-org/security-products/secret-detection-rules
What are the relevant issue numbers?
Does this MR meet the acceptance criteria?
-
Changelog entry added -
Documentation created/updated for GitLab EE, if necessary -
Documentation created/updated for this project, if necessary -
Documentation reviewed by technical writer or follow-up review issue created -
Tests updated/added for this feature/bug -
Job definition updated, if necessary -
Conforms to the code review guidelines -
Conforms to the Go guidelines -
Security reports checked/validated by reviewer
Edited by rossfuhrman