Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Change Artifactory credential to AccessToken (#387)
Miccahc6b537feb308
diff --git a/pkg/pb/credentialspb/credentials.pb.go b/pkg/pb/credentialspb/credentials.pb.goindex 52ec174b3..b40d1a454 100644--- a/pkg/pb/credentialspb/credentials.pb.go+++ b/pkg/pb/credentialspb/credentials.pb.go@@ -647,6 +647,53 @@ func (x *GitHubApp) GetAppId() string {return ""}+type AccessToken struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`+}++func (x *AccessToken) Reset() {+ *x = AccessToken{}+ if protoimpl.UnsafeEnabled {+ mi := &file_credentials_proto_msgTypes[11]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *AccessToken) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*AccessToken) ProtoMessage() {}++func (x *AccessToken) ProtoReflect() protoreflect.Message {+ mi := &file_credentials_proto_msgTypes[11]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use AccessToken.ProtoReflect.Descriptor instead.+func (*AccessToken) Descriptor() ([]byte, []int) {+ return file_credentials_proto_rawDescGZIP(), []int{11}+}++func (x *AccessToken) GetToken() string {+ if x != nil {+ return x.Token+ }+ return ""+}+var File_credentials_proto protoreflect.FileDescriptorvar file_credentials_proto_rawDesc = []byte{@@ -708,11 +755,14 @@ var file_credentials_proto_rawDesc = []byte{0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,0x0e, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12,0x15, 0x0a, 0x06, 0x61, 0x70, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,- 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62,- 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x73, 0x65, 0x63, 0x75,- 0x72, 0x69, 0x74, 0x79, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x68, 0x6f, 0x67, 0x2f,- 0x76, 0x33, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e,- 0x74, 0x69, 0x61, 0x6c, 0x73, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,+ 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x22, 0x23, 0x0a, 0x0b, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73,+ 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01,+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x42, 0x3f, 0x5a, 0x3d, 0x67,+ 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c,+ 0x65, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c,+ 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x63,+ 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,+ 0x6f, 0x74, 0x6f, 0x33,}var (@@ -727,7 +777,7 @@ func file_credentials_proto_rawDescGZIP() []byte {return file_credentials_proto_rawDescData}-var file_credentials_proto_msgTypes = make([]protoimpl.MessageInfo, 11)+var file_credentials_proto_msgTypes = make([]protoimpl.MessageInfo, 12)var file_credentials_proto_goTypes = []interface{}{(*Unauthenticated)(nil), // 0: credentials.Unauthenticated(*CloudEnvironment)(nil), // 1: credentials.CloudEnvironment@@ -740,6 +790,7 @@ var file_credentials_proto_goTypes = []interface{}{(*AWS)(nil), // 8: credentials.AWS(*SES)(nil), // 9: credentials.SES(*GitHubApp)(nil), // 10: credentials.GitHubApp+ (*AccessToken)(nil), // 11: credentials.AccessToken}var file_credentials_proto_depIdxs = []int32{8, // 0: credentials.SES.creds:type_name -> credentials.AWS@@ -888,6 +939,18 @@ func file_credentials_proto_init() {return nil}}+ file_credentials_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*AccessToken); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }}type x struct{}out := protoimpl.TypeBuilder{@@ -895,7 +958,7 @@ func file_credentials_proto_init() {GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: file_credentials_proto_rawDesc,NumEnums: 0,- NumMessages: 11,+ NumMessages: 12,NumExtensions: 0,NumServices: 0,},diff --git a/pkg/pb/credentialspb/credentials.pb.validate.go b/pkg/pb/credentialspb/credentials.pb.validate.goindex 221e0e4b3..8ef315c8e 100644--- a/pkg/pb/credentialspb/credentials.pb.validate.go+++ b/pkg/pb/credentialspb/credentials.pb.validate.go@@ -1202,3 +1202,104 @@ var _ interface {Cause() errorErrorName() string} = GitHubAppValidationError{}++// Validate checks the field values on AccessToken with the rules defined in+// the proto definition for this message. If any rules are violated, the first+// error encountered is returned, or nil if there are no violations.+func (m *AccessToken) Validate() error {+ return m.validate(false)+}++// ValidateAll checks the field values on AccessToken with the rules defined in+// the proto definition for this message. If any rules are violated, the+// result is a list of violation errors wrapped in AccessTokenMultiError, or+// nil if none found.+func (m *AccessToken) ValidateAll() error {+ return m.validate(true)+}++func (m *AccessToken) validate(all bool) error {+ if m == nil {+ return nil+ }++ var errors []error++ // no validation rules for Token++ if len(errors) > 0 {+ return AccessTokenMultiError(errors)+ }++ return nil+}++// AccessTokenMultiError is an error wrapping multiple validation errors+// returned by AccessToken.ValidateAll() if the designated constraints aren't met.+type AccessTokenMultiError []error++// Error returns a concatenation of all the error messages it wraps.+func (m AccessTokenMultiError) Error() string {+ var msgs []string+ for _, err := range m {+ msgs = append(msgs, err.Error())+ }+ return strings.Join(msgs, "; ")+}++// AllErrors returns a list of validation violation errors.+func (m AccessTokenMultiError) AllErrors() []error { return m }++// AccessTokenValidationError is the validation error returned by+// AccessToken.Validate if the designated constraints aren't met.+type AccessTokenValidationError struct {+ field string+ reason string+ cause error+ key bool+}++// Field function returns field value.+func (e AccessTokenValidationError) Field() string { return e.field }++// Reason function returns reason value.+func (e AccessTokenValidationError) Reason() string { return e.reason }++// Cause function returns cause value.+func (e AccessTokenValidationError) Cause() error { return e.cause }++// Key function returns key value.+func (e AccessTokenValidationError) Key() bool { return e.key }++// ErrorName returns error name.+func (e AccessTokenValidationError) ErrorName() string { return "AccessTokenValidationError" }++// Error satisfies the builtin error interface+func (e AccessTokenValidationError) Error() string {+ cause := ""+ if e.cause != nil {+ cause = fmt.Sprintf(" | caused by: %v", e.cause)+ }++ key := ""+ if e.key {+ key = "key for "+ }++ return fmt.Sprintf(+ "invalid %sAccessToken.%s: %s%s",+ key,+ e.field,+ e.reason,+ cause)+}++var _ error = AccessTokenValidationError{}++var _ interface {+ Field() string+ Reason() string+ Key() bool+ Cause() error+ ErrorName() string+} = AccessTokenValidationError{}diff --git a/pkg/pb/sourcespb/sources.pb.go b/pkg/pb/sourcespb/sources.pb.goindex 0ae98825a..548a8dddc 100644--- a/pkg/pb/sourcespb/sources.pb.go+++ b/pkg/pb/sourcespb/sources.pb.go@@ -2123,7 +2123,7 @@ type Artifactory struct {Endpoint string `protobuf:"bytes,1,opt,name=endpoint,proto3" json:"endpoint,omitempty"`// Types that are assignable to Credential:// *Artifactory_BasicAuth- // *Artifactory_Header+ // *Artifactory_AccessTokenCredential isArtifactory_Credential `protobuf_oneof:"credential"`Repositories []string `protobuf:"bytes,4,rep,name=repositories,proto3" json:"repositories,omitempty"`}@@ -2181,9 +2181,9 @@ func (x *Artifactory) GetBasicAuth() *credentialspb.BasicAuth {return nil}-func (x *Artifactory) GetHeader() *credentialspb.Header {- if x, ok := x.GetCredential().(*Artifactory_Header); ok {- return x.Header+func (x *Artifactory) GetAccessToken() *credentialspb.AccessToken {+ if x, ok := x.GetCredential().(*Artifactory_AccessToken); ok {+ return x.AccessToken}return nil}@@ -2203,13 +2203,13 @@ type Artifactory_BasicAuth struct {BasicAuth *credentialspb.BasicAuth `protobuf:"bytes,2,opt,name=basic_auth,json=basicAuth,proto3,oneof"`}-type Artifactory_Header struct {- Header *credentialspb.Header `protobuf:"bytes,3,opt,name=header,proto3,oneof"`+type Artifactory_AccessToken struct {+ AccessToken *credentialspb.AccessToken `protobuf:"bytes,3,opt,name=access_token,json=accessToken,proto3,oneof"`}func (*Artifactory_BasicAuth) isArtifactory_Credential() {}-func (*Artifactory_Header) isArtifactory_Credential() {}+func (*Artifactory_AccessToken) isArtifactory_Credential() {}var File_sources_proto protoreflect.FileDescriptor@@ -2467,17 +2467,18 @@ var file_sources_proto_rawDesc = []byte{0x03, 0x28, 0x09, 0x52, 0x08, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x73, 0x12, 0x1e, 0x0a,0x0a, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x18, 0x04, 0x20, 0x03, 0x28,0x09, 0x52, 0x0a, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x0c, 0x0a,- 0x0a, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x22, 0xcd, 0x01, 0x0a, 0x0b,+ 0x0a, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x22, 0xdd, 0x01, 0x0a, 0x0b,0x41, 0x72, 0x74, 0x69, 0x66, 0x61, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x24, 0x0a, 0x08, 0x65,0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x08, 0xfa,0x42, 0x05, 0x72, 0x03, 0x90, 0x01, 0x01, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e,0x74, 0x12, 0x37, 0x0a, 0x0a, 0x62, 0x61, 0x73, 0x69, 0x63, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x18,0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69,0x61, 0x6c, 0x73, 0x2e, 0x42, 0x61, 0x73, 0x69, 0x63, 0x41, 0x75, 0x74, 0x68, 0x48, 0x00, 0x52,- 0x09, 0x62, 0x61, 0x73, 0x69, 0x63, 0x41, 0x75, 0x74, 0x68, 0x12, 0x2d, 0x0a, 0x06, 0x68, 0x65,- 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x63, 0x72, 0x65,- 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48,- 0x00, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x70,+ 0x09, 0x62, 0x61, 0x73, 0x69, 0x63, 0x41, 0x75, 0x74, 0x68, 0x12, 0x3d, 0x0a, 0x0c, 0x61, 0x63,+ 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b,+ 0x32, 0x18, 0x2e, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x2e, 0x41,+ 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x48, 0x00, 0x52, 0x0b, 0x61, 0x63,+ 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x72, 0x65, 0x70,0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52,0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x42, 0x0c, 0x0a,0x0a, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x2a, 0xb8, 0x05, 0x0a, 0x0a,@@ -2581,6 +2582,7 @@ var file_sources_proto_goTypes = []interface{}{(*credentialspb.CloudEnvironment)(nil), // 32: credentials.CloudEnvironment(*credentialspb.Header)(nil), // 33: credentials.Header(*credentialspb.ClientCredentials)(nil), // 34: credentials.ClientCredentials+ (*credentialspb.AccessToken)(nil), // 35: credentials.AccessToken}var file_sources_proto_depIdxs = []int32{25, // 0: sources.LocalSource.scan_interval:type_name -> google.protobuf.Duration@@ -2614,7 +2616,7 @@ var file_sources_proto_depIdxs = []int32{33, // 28: sources.Jenkins.header:type_name -> credentials.Header34, // 29: sources.Teams.authenticated:type_name -> credentials.ClientCredentials27, // 30: sources.Artifactory.basic_auth:type_name -> credentials.BasicAuth- 33, // 31: sources.Artifactory.header:type_name -> credentials.Header+ 35, // 31: sources.Artifactory.access_token:type_name -> credentials.AccessToken32, // [32:32] is the sub-list for method output_type32, // [32:32] is the sub-list for method input_type32, // [32:32] is the sub-list for extension type_name@@ -2982,7 +2984,7 @@ func file_sources_proto_init() {}file_sources_proto_msgTypes[22].OneofWrappers = []interface{}{(*Artifactory_BasicAuth)(nil),- (*Artifactory_Header)(nil),+ (*Artifactory_AccessToken)(nil),}type x struct{}out := protoimpl.TypeBuilder{diff --git a/pkg/pb/sourcespb/sources.pb.validate.go b/pkg/pb/sourcespb/sources.pb.validate.goindex e86a2d3e7..d64532ee0 100644--- a/pkg/pb/sourcespb/sources.pb.validate.go+++ b/pkg/pb/sourcespb/sources.pb.validate.go@@ -3411,14 +3411,14 @@ func (m *Artifactory) validate(all bool) error {}}- case *Artifactory_Header:+ case *Artifactory_AccessToken:if all {- switch v := interface{}(m.GetHeader()).(type) {+ switch v := interface{}(m.GetAccessToken()).(type) {case interface{ ValidateAll() error }:if err := v.ValidateAll(); err != nil {errors = append(errors, ArtifactoryValidationError{- field: "Header",+ field: "AccessToken",reason: "embedded message failed validation",cause: err,})@@ -3426,16 +3426,16 @@ func (m *Artifactory) validate(all bool) error {case interface{ Validate() error }:if err := v.Validate(); err != nil {errors = append(errors, ArtifactoryValidationError{- field: "Header",+ field: "AccessToken",reason: "embedded message failed validation",cause: err,})}}- } else if v, ok := interface{}(m.GetHeader()).(interface{ Validate() error }); ok {+ } else if v, ok := interface{}(m.GetAccessToken()).(interface{ Validate() error }); ok {if err := v.Validate(); err != nil {return ArtifactoryValidationError{- field: "Header",+ field: "AccessToken",reason: "embedded message failed validation",cause: err,}diff --git a/proto/credentials.proto b/proto/credentials.protoindex a804c3f0a..ce2df5d61 100644--- a/proto/credentials.proto+++ b/proto/credentials.proto@@ -59,3 +59,7 @@ message GitHubApp {string installation_id = 2;string app_id = 3;}++message AccessToken {+ string token = 1;+}diff --git a/proto/sources.proto b/proto/sources.protoindex a595e0ab6..c87fd9c3e 100644--- a/proto/sources.proto+++ b/proto/sources.proto@@ -230,7 +230,7 @@ message Artifactory {string endpoint = 1 [(validate.rules).string.uri_ref = true];oneof credential {credentials.BasicAuth basic_auth = 2;- credentials.Header header = 3;+ credentials.AccessToken access_token = 3;}repeated string repositories = 4;}