nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: coreos/dex
Pull request #537 (2016-08-03 22:11:37)

server: when registering a user, set user name if OIDC identity contains one
When automatically registering a user from an IP that provides
a `DisplayName`, set it on the created user so that JWT we create
contain a meaningful `name` field.

Added new test and ran existing ones.


Patch:
diff --git a/server/server.go b/server/server.go
index 49611149..48ff8dc8 100644
--- a/server/server.go
+++ b/server/server.go
@@ -416,6 +416,13 @@ func (s *Server) Login(ident oidc.Identity, key string) (string, error) {
 		if err != nil {
 			return "", fmt.Errorf("getting created user: %v", err)
 		}
+
+		if ses.Identity.Name != "" && ses.Identity.Name != usr.DisplayName {
+			err = s.UserManager.SetDisplayName(usr, ses.Identity.Name)
+			if err != nil {
+				return "", fmt.Errorf("couldn't set display name for user: %v", err)
+			}
+		}
 	} else if err != nil {
 		return "", fmt.Errorf("getting user: %v", err)
 	}
diff --git a/user/manager/manager.go b/user/manager/manager.go
index b77b7b15..c70e7a30 100644
--- a/user/manager/manager.go
+++ b/user/manager/manager.go
@@ -120,6 +120,25 @@ func (m *UserManager) Disable(userID string, disabled bool) error {
 	return nil
 }
 
+func (m *UserManager) SetDisplayName(usr user.User, displayName string) error {
+	tx, err := m.begin()
+	if err != nil {
+		return err
+	}
+	defer rollback(tx)
+
+	usr.DisplayName = displayName
+	if err = m.userRepo.Update(tx, usr); err != nil {
+		return err
+	}
+
+	if err = tx.Commit(); err != nil {
+		return err
+	}
+
+	return nil
+}
+
 // RegisterWithRemoteIdentity creates new user and attaches the given remote identity.
 func (m *UserManager) RegisterWithRemoteIdentity(email string, emailVerified bool, rid user.RemoteIdentity) (string, error) {
 	tx, err := m.begin()


Test patch:
diff --git a/server/server_test.go b/server/server_test.go
index 1cad4b9c..f724a260 100644
--- a/server/server_test.go
+++ b/server/server_test.go
@@ -358,6 +358,42 @@ func TestServerLoginDisabledUser(t *testing.T) {
 	}
 }
 
+func TestServerLoginDisplayName(t *testing.T) {
+	f, err := makeTestFixtures()
+	if err != nil {
+		t.Fatalf("error making test fixtures: %v", err)
+	}
+
+	sm := f.sessionManager
+	sessionID, err := sm.NewSession(testConnectorIDOpenID, testClientID, "bogus", testRedirectURL, "", false, []string{"openid"})
+	if err != nil {
+		t.Fatalf("Unexpected error: %v", err)
+	}
+
+	key, err := sm.NewSessionKey(sessionID)
+	if err != nil {
+		t.Errorf("new session key: %v", err)
+	}
+
+	f.srv.RegisterOnFirstLogin = true
+
+	ident := oidc.Identity{ID: testUserRemoteID1, Name: "elroy", Email: "elroy@example.com"}
+	_, err = f.srv.Login(ident, key)
+	if err != nil {
+		t.Fatalf("Unexpected error: %v", err)
+	}
+
+	usr, err := f.srv.UserRepo.GetByEmail(nil, ident.Email)
+	if err != nil {
+		t.Fatalf("Couldn't retrieve user we just created: %v", err)
+	}
+
+	if usr.DisplayName != ident.Name {
+		t.Fatalf("User display name (%s) did not match name on identity (%s)",
+			usr.DisplayName, ident.Name)
+	}
+}
+
 func TestServerCodeToken(t *testing.T) {
 	f, err := makeTestFixtures()
 	if err != nil {
Repository: coreos/dex
Pull request #601 (2016-10-12 22:34:31)

server: allow extra spaces in scopes
go-oidc sends an extra space before the list of scopes. This is bad
but we have to support it, so we'll be more lenient and ignore
duplicated whitespace.


Patch:
diff --git a/server/handlers.go b/server/handlers.go
index 02c1881b..ff9444fe 100644
--- a/server/handlers.go
+++ b/server/handlers.go
@@ -537,7 +537,7 @@ func (s *Server) handleRefreshToken(w http.ResponseWriter, r *http.Request, clie
 
 	scopes := refresh.Scopes
 	if scope != "" {
-		requestedScopes := strings.Split(scope, " ")
+		requestedScopes := strings.Fields(scope)
 		var unauthorizedScopes []string
 
 		for _, s := range requestedScopes {
diff --git a/server/oauth2.go b/server/oauth2.go
index 61f6a923..e8ace97d 100644
--- a/server/oauth2.go
+++ b/server/oauth2.go
@@ -213,7 +213,7 @@ func parseAuthorizationRequest(s storage.Storage, supportedResponseTypes map[str
 		return &authErr{state, redirectURI, typ, fmt.Sprintf(format, a...)}
 	}
 
-	scopes := strings.Split(r.Form.Get("scope"), " ")
+	scopes := strings.Fields(r.Form.Get("scope"))
 
 	var (
 		unrecognized  []string


Test patch:
diff --git a/server/server_test.go b/server/server_test.go
index 13f46ac1..35bcf8a3 100644
--- a/server/server_test.go
+++ b/server/server_test.go
@@ -195,6 +195,34 @@ func TestOAuth2CodeFlow(t *testing.T) {
 				return nil
 			},
 		},
+		{
+			name: "refresh with extra spaces",
+			handleToken: func(ctx context.Context, p *oidc.Provider, config *oauth2.Config, token *oauth2.Token) error {
+				v := url.Values{}
+				v.Add("client_id", clientID)
+				v.Add("client_secret", clientSecret)
+				v.Add("grant_type", "refresh_token")
+				v.Add("refresh_token", token.RefreshToken)
+
+				// go-oidc adds an additional space before scopes when refreshing.
+				// Since we support that client we choose to be more relaxed about
+				// scope parsing, disregarding extra whitespace.
+				v.Add("scope", " "+strings.Join(requestedScopes, " "))
+				resp, err := http.PostForm(p.TokenURL, v)
+				if err != nil {
+					return err
+				}
+				defer resp.Body.Close()
+				if resp.StatusCode != http.StatusOK {
+					dump, err := httputil.DumpResponse(resp, true)
+					if err != nil {
+						panic(err)
+					}
+					return fmt.Errorf("unexpected response: %s", dump)
+				}
+				return nil
+			},
+		},
 		{
 			name: "refresh with unauthorized scopes",
 			handleToken: func(ctx context.Context, p *oidc.Provider, config *oauth2.Config, token *oauth2.Token) error {
Repository: coreos/dex
Pull request #969 (2017-06-14 23:06:19)

[cherry pick] server: fix localhost redirect validation for public clients


Patch:
diff --git a/server/oauth2.go b/server/oauth2.go
index b10609c9..528b25a6 100644
--- a/server/oauth2.go
+++ b/server/oauth2.go
@@ -12,6 +12,7 @@ import (
 	"fmt"
 	"hash"
 	"io"
+	"net"
 	"net/http"
 	"net/url"
 	"strconv"
@@ -518,9 +519,18 @@ func validateRedirectURI(client storage.Client, redirectURI string) bool {
 	if redirectURI == redirectURIOOB {
 		return true
 	}
-	if !strings.HasPrefix(redirectURI, "http://localhost:") {
+
+	// verify that the host is of form "http://localhost:(port)(path)" or "http://localhost(path)"
+	u, err := url.Parse(redirectURI)
+	if err != nil {
+		return false
+	}
+	if u.Scheme != "http" {
 		return false
 	}
-	n, err := strconv.Atoi(strings.TrimPrefix(redirectURI, "https://localhost:"))
-	return err == nil && n <= 0
+	if u.Host == "localhost" {
+		return true
+	}
+	host, _, err := net.SplitHostPort(u.Host)
+	return err == nil && host == "localhost"
 }


Test patch:
diff --git a/server/oauth2_test.go b/server/oauth2_test.go
index 83de2256..dcf4947b 100644
--- a/server/oauth2_test.go
+++ b/server/oauth2_test.go
@@ -195,3 +195,67 @@ func TestAccessTokenHash(t *testing.T) {
 		t.Errorf("expected %q got %q", googleAccessTokenHash, atHash)
 	}
 }
+
+func TestValidRedirectURI(t *testing.T) {
+	tests := []struct {
+		client      storage.Client
+		redirectURI string
+		wantValid   bool
+	}{
+		{
+			client: storage.Client{
+				RedirectURIs: []string{"http://foo.com/bar"},
+			},
+			redirectURI: "http://foo.com/bar",
+			wantValid:   true,
+		},
+		{
+			client: storage.Client{
+				RedirectURIs: []string{"http://foo.com/bar"},
+			},
+			redirectURI: "http://foo.com/bar/baz",
+		},
+		{
+			client: storage.Client{
+				Public: true,
+			},
+			redirectURI: "urn:ietf:wg:oauth:2.0:oob",
+			wantValid:   true,
+		},
+		{
+			client: storage.Client{
+				Public: true,
+			},
+			redirectURI: "http://localhost:8080/",
+			wantValid:   true,
+		},
+		{
+			client: storage.Client{
+				Public: true,
+			},
+			redirectURI: "http://localhost:991/bar",
+			wantValid:   true,
+		},
+		{
+			client: storage.Client{
+				Public: true,
+			},
+			redirectURI: "http://localhost",
+			wantValid:   true,
+		},
+		{
+			client: storage.Client{
+				Public: true,
+			},
+			redirectURI: "http://localhost.localhost:8080/",
+			wantValid:   false,
+		},
+	}
+	for _, test := range tests {
+		got := validateRedirectURI(test.client, test.redirectURI)
+		if got != test.wantValid {
+			t.Errorf("client=%#v, redirectURI=%q, wanted valid=%t, got=%t",
+				test.client, test.redirectURI, test.wantValid, got)
+		}
+	}
+}
Repository: gimli-rs/addr2line
Pull request #289 (2024-04-11 08:55:10)

Release 0.22.0


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8754c71..0167966 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,14 @@
 
 --------------------------------------------------------------------------------
 
+## 0.22.0 (2024/04/11)
+
+### Breaking changes
+
+* Updated `gimli` and `object` dependencies.
+
+--------------------------------------------------------------------------------
+
 ## 0.21.0 (2023/08/12)
 
 ### Breaking changes
diff --git a/Cargo.toml b/Cargo.toml
index 9e525c8..8eddc91 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "addr2line"
-version = "0.21.0"
+version = "0.22.0"
 description = "A cross-platform symbolication library written in Rust, using `gimli`"
 documentation = "https://docs.rs/addr2line"
 exclude = ["/benches/*", "/fixtures/*", ".github", "*.sh", "*.r"]
@@ -13,7 +13,7 @@ edition = "2018"
 rust-version = "1.65"
 
 [dependencies]
-gimli = { version = "0.28.0", default-features = false, features = ["read"] }
+gimli = { version = "0.29.0", default-features = false, features = ["read"] }
 fallible-iterator = { version = "0.3.0", default-features = false, optional = true }
 memmap2 = { version = "0.9.4", optional = true }
 object = { version = "0.35.0", default-features = false, features = ["read"], optional = true }
@@ -31,7 +31,7 @@ compiler_builtins = { version = '0.1.2', optional = true }
 clap = { version = "4.3.21", features = ["wrap_help"] }
 backtrace = "0.3.13"
 findshlibs = "0.10"
-libtest-mimic = "0.6.1"
+libtest-mimic = "0.7.2"
 auxiliary = { path = "tests/auxiliary" }
 typed-arena = "2"
 


Test patch:
diff --git a/tests/parse.rs b/tests/parse.rs
index 4dafe38..2e0c328 100644
--- a/tests/parse.rs
+++ b/tests/parse.rs
@@ -26,7 +26,7 @@ fn with_file<F: FnOnce(&object::File<'_>)>(target: &path::Path, f: F) {
     f(&file)
 }
 
-fn dwarf_load<'a>(object: &object::File<'a>) -> gimli::Dwarf<Cow<'a, [u8]>> {
+fn dwarf_load<'a>(object: &object::File<'a>) -> gimli::DwarfSections<Cow<'a, [u8]>> {
     let load_section = |id: gimli::SectionId| -> Result<Cow<'a, [u8]>, gimli::Error> {
         use object::ObjectSection;
 
@@ -36,11 +36,11 @@ fn dwarf_load<'a>(object: &object::File<'a>) -> gimli::Dwarf<Cow<'a, [u8]>> {
             .unwrap_or(&[][..]);
         Ok(Cow::Borrowed(data))
     };
-    gimli::Dwarf::load(&load_section).unwrap()
+    gimli::DwarfSections::load(&load_section).unwrap()
 }
 
 fn dwarf_borrow<'a>(
-    dwarf: &'a gimli::Dwarf<Cow<'_, [u8]>>,
+    dwarf: &'a gimli::DwarfSections<Cow<'_, [u8]>>,
 ) -> gimli::Dwarf<gimli::EndianSlice<'a, gimli::LittleEndian>> {
     let borrow_section: &dyn for<'b> Fn(
         &'b Cow<'_, [u8]>,
Repository: clusternet/clusternet
Pull request #63 (2021-08-11 11:42:06)

fix wrapper on group names with dot
<!--  Thanks for sending a pull request!

-->

#### What type of PR is this?
kind/bug

#### What this PR does / why we need it:

#### Which issue(s) this PR fixes:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:



Patch:
diff --git a/pkg/wrappers/clientgo/wrapper.go b/pkg/wrappers/clientgo/wrapper.go
index 2a7bc6d..5c7becc 100644
--- a/pkg/wrappers/clientgo/wrapper.go
+++ b/pkg/wrappers/clientgo/wrapper.go
@@ -31,7 +31,7 @@ var (
 	// regex matches '/api/v1/{path}'
 	apiv1Regex = regexp.MustCompile(`^(/api/v1)/(.*)`)
 	// regex matches "/apis/{group}/{version}/{path}"
-	apisRegex = regexp.MustCompile(`^(/apis/\w*/v\w*.)/(.*)`)
+	apisRegex = regexp.MustCompile(`^(/apis/.*/v\w*.)/(.*)`)
 	// regex matches "/apis/xxx.clusternet.io/{version}/{path}"
 	clusternetAPIsRegex = regexp.MustCompile(`^(/apis/\w*\.clusternet\.io/v\w*.)/(.*)`)
 


Test patch:
diff --git a/pkg/wrappers/clientgo/wrapper_test.go b/pkg/wrappers/clientgo/wrapper_test.go
index c6d6638..f3ec8fa 100644
--- a/pkg/wrappers/clientgo/wrapper_test.go
+++ b/pkg/wrappers/clientgo/wrapper_test.go
@@ -157,6 +157,18 @@ func TestNormalizeLocation(t *testing.T) {
 			requestURL:    "https://my.k8s.io/apis/far.clusternet.io/v1bar/namespaces/boo/foos/abc?fieldSelector=metadata.name%3Dabc&resourceVersion=0&watch=true",
 			normalizedURL: "https://my.k8s.io/apis/far.clusternet.io/v1bar/namespaces/boo/foos/abc?fieldSelector=metadata.name%3Dabc&resourceVersion=0&watch=true",
 		},
+		{
+			name:          "clusternet - support crd with group samplecontroller.k8s.io",
+			host:          "https://my.k8s.io",
+			requestURL:    "https://my.k8s.io/apis/samplecontroller.k8s.io/v1alpha1/namespaces/default/foos",
+			normalizedURL: "https://my.k8s.io/apis/shadow/v1alpha1/namespaces/default/foos",
+		},
+		{
+			name:          "clusternet - support crd with group a.foo",
+			host:          "https://my.k8s.io",
+			requestURL:    "https://my.k8s.io/apis/a.foo/v1alpha1/namespaces/default/foos?fieldSelector=metadata.name%3Dabc&resourceVersion=0&watch=true",
+			normalizedURL: "https://my.k8s.io/apis/shadow/v1alpha1/namespaces/default/foos?fieldSelector=metadata.name%3Dabc&resourceVersion=0&watch=true",
+		},
 
 		{
 			name:          "apiv1 - host with trailing slash",
Repository: clusternet/clusternet
Pull request #408 (2022-07-07 09:39:06)

removing Manifest finalizer in shadow api
<!--  Thanks for sending a pull request!

-->

#### What type of PR is this?

#### What this PR does / why we need it:

#### Which issue(s) this PR fixes:
<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->
Fixes #

#### Special notes for your reviewer:



Patch:
diff --git a/pkg/registry/shadow/template/transformer.go b/pkg/registry/shadow/template/transformer.go
index 65f95b8..a178bf9 100644
--- a/pkg/registry/shadow/template/transformer.go
+++ b/pkg/registry/shadow/template/transformer.go
@@ -37,7 +37,6 @@ func transformManifest(manifest *appsapi.Manifest) (*unstructured.Unstructured,
 	result.SetUID(manifest.UID)
 	result.SetDeletionGracePeriodSeconds(manifest.DeletionGracePeriodSeconds)
 	result.SetDeletionTimestamp(manifest.DeletionTimestamp)
-	result.SetFinalizers(manifest.Finalizers)
 
 	annotations := result.GetAnnotations()
 	if val, ok := manifest.Annotations[known.FeedProtectionAnnotation]; ok {


Test patch:
diff --git a/pkg/registry/shadow/template/transformer_test.go b/pkg/registry/shadow/template/transformer_test.go
index d15c30b..b8ea3b1 100644
--- a/pkg/registry/shadow/template/transformer_test.go
+++ b/pkg/registry/shadow/template/transformer_test.go
@@ -49,6 +49,7 @@ func TestTransformManifest(t *testing.T) {
 						known.ConfigNameLabel:      "boo",
 						known.ConfigNamespaceLabel: "ns1",
 					},
+					Finalizers:      []string{"apps.clusternet.io/finalizer"},
 					Namespace:       known.ClusternetReservedNamespace,
 					Name:            "bars-boo",
 					ResourceVersion: "1860247",