diff --git a/NOTICE.txt b/NOTICE.txt index 0c501bc8d85..ce00bd5f00a 100644 --- a/NOTICE.txt +++ b/NOTICE.txt @@ -17540,25 +17540,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------- -Dependency : github.com/golang-jwt/jwt/v5 -Version: v5.0.0 -Licence type (autodetected): MIT --------------------------------------------------------------------------------- - -Contents of probable licence file $GOMODCACHE/github.com/golang-jwt/jwt/v5@v5.0.0/LICENSE: - -Copyright (c) 2012 Dave Grijalva -Copyright (c) 2021 golang-jwt maintainers - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - -------------------------------------------------------------------------------- Dependency : github.com/golang/mock Version: v1.6.0 @@ -40825,6 +40806,25 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI +-------------------------------------------------------------------------------- +Dependency : github.com/golang-jwt/jwt/v5 +Version: v5.0.0 +Licence type (autodetected): MIT +-------------------------------------------------------------------------------- + +Contents of probable licence file $GOMODCACHE/github.com/golang-jwt/jwt/v5@v5.0.0/LICENSE: + +Copyright (c) 2012 Dave Grijalva +Copyright (c) 2021 golang-jwt maintainers + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + -------------------------------------------------------------------------------- Dependency : github.com/golang-sql/civil Version: v0.0.0-20190719163853-cb61b32ac6fe diff --git a/go.mod b/go.mod index 9552997c4c3..b1e917ccd17 100644 --- a/go.mod +++ b/go.mod @@ -215,7 +215,6 @@ require ( github.com/foxcpp/go-mockdns v0.0.0-20201212160233-ede2f9158d15 github.com/g8rswimmer/go-sfdc v0.0.0-00010101000000-000000000000 github.com/go-ldap/ldap/v3 v3.4.6 - github.com/golang-jwt/jwt/v5 v5.0.0 github.com/google/cel-go v0.19.0 github.com/googleapis/gax-go/v2 v2.12.0 github.com/gorilla/handlers v1.5.1 @@ -307,6 +306,7 @@ require ( github.com/goccy/go-json v0.10.2 // indirect github.com/godror/knownpb v0.1.0 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect diff --git a/x-pack/filebeat/input/salesforce/input.go b/x-pack/filebeat/input/salesforce/input.go index f2f8ef15c68..8b18cd89ab2 100644 --- a/x-pack/filebeat/input/salesforce/input.go +++ b/x-pack/filebeat/input/salesforce/input.go @@ -7,8 +7,11 @@ package salesforce import ( "bytes" "context" + "crypto/rsa" + "crypto/x509" "encoding/csv" "encoding/json" + "encoding/pem" "errors" "fmt" "io" @@ -20,7 +23,6 @@ import ( "github.com/g8rswimmer/go-sfdc/credentials" "github.com/g8rswimmer/go-sfdc/session" "github.com/g8rswimmer/go-sfdc/soql" - "github.com/golang-jwt/jwt/v5" "github.com/hashicorp/go-retryablehttp" "go.uber.org/zap" "golang.org/x/exp/slices" @@ -409,7 +411,7 @@ func (s *salesforceInput) getSFDCConfig(cfg *config) (*sfdc.Configuration, error return nil, fmt.Errorf("problem with client key path for JWT auth: %w", err) } - signKey, err := jwt.ParseRSAPrivateKeyFromPEM(pemBytes) + signKey, err := parseRSAPrivateKeyFromPEM(pemBytes) if err != nil { return nil, fmt.Errorf("problem with client key for JWT auth: %w", err) } @@ -454,6 +456,27 @@ func (s *salesforceInput) getSFDCConfig(cfg *config) (*sfdc.Configuration, error }, nil } +func parseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error) { + // Parse PEM block + var block *pem.Block + if block, _ = pem.Decode(key); block == nil { + return nil, errors.New("Invalid Key: Key must be a PEM encoded PKCS1 or PKCS8 key") + } + + if parsedKey, err := x509.ParsePKCS1PrivateKey(block.Bytes); err == nil { + return parsedKey, nil + } + + if parsedKey, err := x509.ParsePKCS8PrivateKey(block.Bytes); err == nil { + if pkey, ok := parsedKey.(*rsa.PrivateKey); ok { + return pkey, nil + } + + } + + return nil, errors.New("Key is not a valid RSA private key") +} + // retryLog is a shim for the retryablehttp.Client.Logger. type retryLog struct{ log *logp.Logger }