Skip to content

Commit 9dbbba8

Browse files
gustavoavenameta-codesync[bot]
authored andcommitted
restricted_paths: rename path presence API
Summary: ## This stack This stack adds AclManifest shadow comparison logging for restricted_paths while keeping config-backed behavior authoritative in the first stack. ## This diff Renames `has_restricted_paths` to `may_have_restricted_paths` before the shadow path logging diff changes its behavior, making the public method name match the fact that AclManifest-backed restrictions can be discovered dynamically. ___ overriding_review_checks_triggers_an_audit_and_retroactive_review Oncall Short Name: source_control Differential Revision: D104035670 fbshipit-source-id: a4de731cadad8621be5434a9543a004ae6bff2dc
1 parent aa67220 commit 9dbbba8

5 files changed

Lines changed: 13 additions & 13 deletions

File tree

eden/mononoke/jobs/cas_sync/src/re_cas_sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub async fn try_sync<'a>(
109109
ctx: &'a CoreContext,
110110
bcs_id: ChangesetId,
111111
) -> Result<UploadStats, Error> {
112-
let restricted_path_roots = if repo.restricted_paths().has_restricted_paths() {
112+
let restricted_path_roots = if repo.restricted_paths().may_have_restricted_paths() {
113113
let bonsai: mononoke_types::BonsaiChangeset =
114114
bcs_id.load(ctx, &repo.repo_blobstore()).await?;
115115
let changed_paths: Vec<NonRootMPath> = bonsai

eden/mononoke/mononoke_api/src/changeset.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,11 +2136,11 @@ impl<R: MononokeRepo> ChangesetContext<R> {
21362136
Ok(RestrictedPathsChangesInfo { restricted_changes })
21372137
}
21382138

2139-
/// Check if the repository has any restricted paths configured.
2140-
pub fn has_restricted_paths(&self) -> bool {
2139+
/// Check if the repository may have restricted paths.
2140+
pub fn may_have_restricted_paths(&self) -> bool {
21412141
self.repo_ctx()
21422142
.repo()
21432143
.restricted_paths_arc()
2144-
.has_restricted_paths()
2144+
.may_have_restricted_paths()
21452145
}
21462146
}

eden/mononoke/mononoke_api_hg/src/tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ impl<R: MononokeRepo> HgAugmentedTreeRestrictionContext<R> {
351351

352352
let restricted_paths = self.repo_ctx.repo().restricted_paths_arc();
353353

354-
if !restricted_paths.has_restricted_paths() {
354+
if !restricted_paths.may_have_restricted_paths() {
355355
return Ok(None);
356356
}
357357

eden/mononoke/repo_attributes/restricted_paths/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ impl RestrictedPaths {
128128
self.config_based.config()
129129
}
130130

131-
/// Returns whether any restricted paths are configured for this repository.
131+
/// Returns whether this repository may have restricted paths.
132132
/// When `use_acl_manifest` is true, restrictions are discovered dynamically
133-
/// from `.slacl` files in the repo, so we cannot short-circuit based on
134-
/// the config-based `path_acls` alone.
135-
pub fn has_restricted_paths(&self) -> bool {
133+
/// from `.slacl` files in the repo, so callers cannot treat a false
134+
/// config-only lookup as proof that no restricted paths exist.
135+
pub fn may_have_restricted_paths(&self) -> bool {
136136
self.use_acl_manifest || self.config_based.has_restricted_paths()
137137
}
138138

@@ -657,7 +657,7 @@ mod tests {
657657
let repo_restricted_paths =
658658
build_test_restricted_paths(fb, RestrictedPathsConfig::default()).await?;
659659

660-
assert!(!repo_restricted_paths.has_restricted_paths());
660+
assert!(!repo_restricted_paths.may_have_restricted_paths());
661661

662662
let ctx = CoreContext::test_mock(fb);
663663
let cs_id = ChangesetId::new(mononoke_types::hash::Blake2::from_byte_array([0u8; 32]));
@@ -700,7 +700,7 @@ mod tests {
700700

701701
let repo_restricted_paths = build_test_restricted_paths(fb, config).await?;
702702

703-
assert!(repo_restricted_paths.has_restricted_paths());
703+
assert!(repo_restricted_paths.may_have_restricted_paths());
704704
Ok(())
705705
}
706706

@@ -794,7 +794,7 @@ mod tests {
794794
)
795795
.await?;
796796

797-
assert!(!_restricted_paths.has_restricted_paths());
797+
assert!(!_restricted_paths.may_have_restricted_paths());
798798
Ok(())
799799
}
800800

eden/mononoke/servers/scs/scs_methods/src/methods/commit_restricted_paths.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(crate) async fn restricted_paths_access_impl(
2525
check_permissions: bool,
2626
) -> Result<thrift::CommitRestrictedPathsAccessResponse, scs_errors::ServiceError> {
2727
// If no restricted paths configured, return empty response
28-
if !cs_ctx.has_restricted_paths() {
28+
if !cs_ctx.may_have_restricted_paths() {
2929
return Ok(thrift::CommitRestrictedPathsAccessResponse {
3030
are_restricted: thrift::PathCoverage::NONE,
3131
has_access: thrift::PathCoverage::ALL,

0 commit comments

Comments
 (0)