eabea43a28
If any project on a server inherited explicitly from All-Projects using its project.config, for example: [access] inheritFrom = All-Projects and this project's permissions were evaluated early in the lifetime of a server's process, it could poison the permission_sort cache to include access sections from All-Projects twice, while ignoring an identically named section from a child project that inherits from All-Projects indirectly by not having an explicitly declared parent. A unit test has been added to RefControlTest that sets up this case, and thereby poisons the permission_sort cache during the first test of isVisible(). A second test with an unrelated project would fail to consider the READ permission on refs/* for group devs. Without fixes to ProjectState or SectionSortCache this test would fail. ProjectState incorrectly added All-Projects twice, because it did not consider after the loop exited that the project may have been added inside of the loop through an explicit parent reference. Fix this by tracking the All-Projects name in the seen collection just like any other parent reference. SectionSortCache can be poisoned by being fed an input List where the same AccessSection reference exists in multiple positions. If this happens, consider the cache entry to be poison and do not put the sorted result into the cache. Instead always sort these lists on the fly. Change-Id: I2c9d9ccd6b4fb991d317f9709428e681e5bde104