Skip to content
7 changes: 7 additions & 0 deletions binary/proto/scan_result.proto
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ message SecretData {
HashiCorpVaultToken hashicorp_vault_token = 17;
HashiCorpVaultAppRoleCredentials hashicorp_vault_app_role_credentials = 18;
GCPAPIKey gcp_api_key = 19;
HuggingfaceAPIKey hugginface = 20;
}

message GCPSAK {
Expand Down Expand Up @@ -757,6 +758,12 @@ message SecretData {
message GCPAPIKey {
string key = 1;
}

message HuggingfaceAPIKey {
string key = 1;
string role = 2;
repeated string fine_grained_scope = 3;
}
}

message SecretStatus {
Expand Down
134 changes: 110 additions & 24 deletions binary/proto/scan_result_go_proto/scan_result.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions binary/proto/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/google/osv-scalibr/veles/secrets/dockerhubpat"
velesgcpapikey "github.com/google/osv-scalibr/veles/secrets/gcpapikey"
velesgcpsak "github.com/google/osv-scalibr/veles/secrets/gcpsak"
"github.com/google/osv-scalibr/veles/secrets/huggingfaceapikey"
"github.com/google/osv-scalibr/veles/secrets/gitlabpat"
velesgrokxaiapikey "github.com/google/osv-scalibr/veles/secrets/grokxaiapikey"
veleshashicorpvault "github.com/google/osv-scalibr/veles/secrets/hashicorpvault"
Expand Down Expand Up @@ -135,6 +136,8 @@ func velesSecretToProto(s veles.Secret) (*spb.SecretData, error) {
return hashicorpVaultAppRoleCredentialsToProto(t), nil
case velesgcpapikey.GCPAPIKey:
return gcpAPIKeyToProto(t.Key), nil
case huggingfaceapikey.HuggingfaceAPIKey:
return huggingfaceAPIKeyToProto(t), nil
default:
return nil, fmt.Errorf("%w: %T", ErrUnsupportedSecretType, s)
}
Expand Down Expand Up @@ -347,6 +350,18 @@ func hashicorpVaultAppRoleCredentialsToProto(s veleshashicorpvault.AppRoleCreden
}
}

func huggingfaceAPIKeyToProto(s huggingfaceapikey.HuggingfaceAPIKey) *spb.SecretData {
return &spb.SecretData{
Secret: &spb.SecretData_Hugginface{
Hugginface: &spb.SecretData_HuggingfaceAPIKey{
Key: s.Key,
Role: s.Role,
FineGrainedScope: s.FineGrainedScope,
},
},
}
}

func validationResultToProto(r inventory.SecretValidationResult) (*spb.SecretStatus, error) {
status, err := validationStatusToProto(r.Status)
if err != nil {
Expand Down Expand Up @@ -463,6 +478,8 @@ func velesSecretToStruct(s *spb.SecretData) (veles.Secret, error) {
return hashicorpVaultAppRoleCredentialsToStruct(s.GetHashicorpVaultAppRoleCredentials()), nil
case *spb.SecretData_GcpApiKey:
return velesgcpapikey.GCPAPIKey{Key: s.GetGcpApiKey().GetKey()}, nil
case *spb.SecretData_Hugginface:
return huggingfaceAPIKeyToStruct(s.GetHugginface()), nil
default:
return nil, fmt.Errorf("%w: %T", ErrUnsupportedSecretType, s.GetSecret())
}
Expand All @@ -485,6 +502,15 @@ func gitlabPATToStruct(kPB *spb.SecretData_GitlabPat) gitlabpat.GitlabPAT {
Pat: kPB.GetPat(),
}
}

func huggingfaceAPIKeyToStruct(kPB *spb.SecretData_HuggingfaceAPIKey) huggingfaceapikey.HuggingfaceAPIKey {
return huggingfaceapikey.HuggingfaceAPIKey{
Key: kPB.GetKey(),
Role: kPB.GetRole(),
FineGrainedScope: kPB.GetFineGrainedScope(),
}
}

func gcpsakToStruct(sakPB *spb.SecretData_GCPSAK) velesgcpsak.GCPSAK {
sak := velesgcpsak.GCPSAK{
PrivateKeyID: sakPB.GetPrivateKeyId(),
Expand Down
7 changes: 7 additions & 0 deletions enricher/enricherlist/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/google/osv-scalibr/enricher"
"github.com/google/osv-scalibr/enricher/baseimage"
"github.com/google/osv-scalibr/enricher/huggingfacemeta"
"github.com/google/osv-scalibr/enricher/license"
"github.com/google/osv-scalibr/enricher/reachability/java"
"github.com/google/osv-scalibr/enricher/secrets/convert"
Expand Down Expand Up @@ -85,6 +86,11 @@ var (
fromVeles(postmanapikey.NewCollectionValidator(), "secrets/postmancollectiontokenvalidate", 0),
})

// HuggingfaceMeta enricher.
HuggingfaceMeta = InitMap{
huggingfacemeta.Name: {huggingfacemeta.New},
}

// Reachability enrichers.
Reachability = InitMap{
java.Name: {java.NewDefault},
Expand All @@ -104,6 +110,7 @@ var (
VulnMatching,
VEX,
Secrets,
HuggingfaceMeta,
License,
Reachability,
TransitiveDependency,
Expand Down
Loading