34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
package classify
|
|||
|
|
|
||
|
|
import "tea.karlcom.de/karl/bucketeer/internal/model"
|
||
|
|
|
||
|
|
// classifyR2 handles <account-id>.r2.cloudflarestorage.com.
|
||
|
|
func classifyR2(s *scanner) (model.Match, bool) {
|
||
|
|
n := s.n
|
||
|
|
if n < 4 || s.label(n-1) != "com" || s.label(n-2) != "cloudflarestorage" || s.label(n-3) != "r2" {
|
||
|
|
return model.Match{}, false
|
||
|
|
}
|
||
|
|
return model.Match{
|
||
|
|
Provider: model.ProviderCloudflare,
|
||
|
|
Service: model.ServiceObjectStorage,
|
||
|
|
ResourceSpecific: true,
|
||
|
|
Resource: s.label(0),
|
||
|
|
}, true
|
||
|
|
}
|
||
|
|
|
||
|
|
// classifyR2Dev handles <account>.r2.dev. The hostname form is explicitly a
|
||
|
|
// public development/public URL, which is why it carries PublicSemanticPublicURL
|
||
|
|
// while still not asserting that data is readable.
|
||
|
|
func classifyR2Dev(s *scanner) (model.Match, bool) {
|
||
|
|
n := s.n
|
||
|
|
if n < 3 || s.label(n-1) != "dev" || s.label(n-2) != "r2" {
|
||
|
|
return model.Match{}, false
|
||
|
|
}
|
||
|
|
return model.Match{
|
||
|
|
Provider: model.ProviderCloudflare,
|
||
|
|
Service: model.ServiceObjectStorage,
|
||
|
|
ResourceSpecific: true,
|
||
|
|
PublicSemantic: model.PublicSemanticPublicURL,
|
||
|
|
Resource: s.label(0),
|
||
|
|
}, true
|
||
|
|
}
|