# HG changeset patch # User Sandu Turcan # Date 1651628670 14400 # Node ID 6b10151b962108f65bfa12b3918b1021ca334f73 # Parent 2012228499872760d17c07d2014ccd2daa0292bc narrow_widen_acl: enforce narrowacl in narrow_widen (SEC) Reviewer note: this was sent by the author as a simple bugfix, but can be considered a security patch, since it allows users to access things outside of the ACL, hence the (SEC) prefix. However, this affects the `narrow` extention which is still marked as experimental and has relatively few users aside from large companies with their own security layers on top from what we can gather. We feel (Alphare: or at least, I feel) like pinging the packaging list is enough in this case. diff -r 201222849987 -r 6b10151b9621 hgext/narrow/narrowwirepeer.py --- a/hgext/narrow/narrowwirepeer.py Mon May 30 11:52:31 2022 +0200 +++ b/hgext/narrow/narrowwirepeer.py Tue May 03 21:44:30 2022 -0400 @@ -10,6 +10,7 @@ from mercurial import ( bundle2, error, + exchange, extensions, hg, narrowspec, @@ -86,6 +87,11 @@ newincludes = splitpaths(newincludes) oldexcludes = splitpaths(oldexcludes) newexcludes = splitpaths(newexcludes) + + # enforce narrow acl if set + if repo.ui.has_section(exchange._NARROWACL_SECTION): + exchange.applynarrowacl(repo, {'includepats': newincludes}) + # validate the patterns narrowspec.validatepatterns(set(oldincludes)) narrowspec.validatepatterns(set(newincludes)) diff -r 201222849987 -r 6b10151b9621 tests/test-narrow-acl.t --- a/tests/test-narrow-acl.t Mon May 30 11:52:31 2022 +0200 +++ b/tests/test-narrow-acl.t Tue May 03 21:44:30 2022 -0400 @@ -41,3 +41,39 @@ $ hg -R narrowclone1 tracked I path:f1 I path:f2 + +Narrow should not be able to widen to include f3 + $ hg -R narrowclone1 tracked --addinclude f3 + comparing with http://localhost:$HGPORT1/ + searching for changes + abort: The following includes are not accessible for test: ['path:f3'] + [255] + $ ls -A -1 narrowclone1 | sort + .hg + f1 + f2 + $ hg -R narrowclone1 tracked + I path:f1 + I path:f2 + +Narrow should allow widen to include f2 + $ hg -R narrowclone1 tracked --removeinclude f2 > /dev/null + $ hg -R narrowclone1 tracked + I path:f1 + $ ls -A -1 narrowclone1 | sort + .hg + f1 + $ hg -R narrowclone1 tracked --addinclude f2 + comparing with http://localhost:$HGPORT1/ + searching for changes + adding changesets + adding manifests + adding file changes + added 0 changesets with 1 changes to 1 files + $ hg -R narrowclone1 tracked + I path:f1 + I path:f2 + $ ls -A -1 narrowclone1 | sort + .hg + f1 + f2