Added azure COSMOSDB detector#3951
Conversation
|
|
||
| dbKeyPattern = regexp.MustCompile(`([A-Za-z0-9+/=]{88})`) | ||
| // account name can contain only lowercase letters, numbers and the `-` character, must be between 3 and 44 characters long. | ||
| accountUrlPattern = regexp.MustCompile(`(https://[a-z0-9-]{3,44}.documents\.azure\.com:[0-9]{3})`) |
There was a problem hiding this comment.
@kashifkhan0771 Does Azure Cosmos db only supports 3 digits port number ? As per my knowledge, A port number can be between 0 to 65535, includes reserved and general use port numbers.
There was a problem hiding this comment.
Apologies for that. The port is fixed at 443, and there doesn't seem to be an option to specify a custom port when creating a Cosmos NoSQL database. I will change this.
| var _ detectors.Detector = (*Scanner)(nil) | ||
|
|
||
| func (s Scanner) Type() detectorspb.DetectorType { | ||
| return detectorspb.DetectorType_AzureCosmosDB |
There was a problem hiding this comment.
Can you check how this detector is different than already CosmosDBKey one
There was a problem hiding this comment.
This one does not exist. The entry only exist in Proto file somehow.
There was a problem hiding this comment.
Deprecated the old one.
There was a problem hiding this comment.
Does it make sense to create a new entry when there's an existing (unused) one?
There was a problem hiding this comment.
I'm not sure why this old entry was added. Was there a detector for it, or was it added by mistake? We can reuse the old entry for the new detector, but I want to deprecate it to keep a record that this key existed.
Anyway I'll update it 😃
|
|
||
| s1 := detectors.Result{ | ||
| DetectorType: detectorspb.DetectorType_AzureCosmosDB, | ||
| Raw: []byte(key), |
pkg/detectors/azure_cosmosdb/azure_cosmosdb_integration_test.go
Outdated
Show resolved
Hide resolved
| }{ | ||
| { | ||
| name: "valid document db pattern", | ||
| input: validDocumentDBPattern, |
There was a problem hiding this comment.
For better code readability, can we keep the inputs inline instead of assigning them to separate variables?
abmussani
left a comment
There was a problem hiding this comment.
Added inline comment about caching.
|
Finally 🥳 - Thanks @abmussani and @rgmz for detailed review. |
Description:
This PR adds a new detector for azure cosmosdb.

Note: This for now only work for
documents.azure.com&table.cosmos.azure.comaccount urls.Checklist:
make test-community)?make lintthis requires golangci-lint)?