Skip to content

Commit 7ddf541

Browse files
committed
Send permission denied error
Do not send a neutral error message so an unauthorized user wouldn't even know that method exists
1 parent 6f7acc6 commit 7ddf541

2 files changed

Lines changed: 12 additions & 16 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "shvclient"
33
description = "A Rust framework for Silicon Heaven RPC devices"
44
license = "MIT"
55
repository = "https://github.com/silicon-heaven/libshvclient-rs"
6-
version = "5.0.0"
6+
version = "5.0.1"
77
edition = "2024"
88

99
[lib]

src/clientnode.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -479,22 +479,18 @@ fn check_request_access_for_method(rq: &RpcMessage, mount_path: impl AsRef<str>,
479479
if rq_level >= method.access as i32 {
480480
Ok(())
481481
} else {
482-
// Send a neutral error message so an unauthorized user wouldn't even know
483-
// that this path:method exists.
484482
let path = full_shv_path(mount_path.as_ref(), rq.shv_path().unwrap_or_default());
485-
Err(rpc_error_unknown_method_on_path(path, &method.name))
486-
487-
// Err(RpcError::new(
488-
// RpcErrorCode::PermissionDenied,
489-
// format!("Insufficient permissions. \
490-
// Method '{full_path}:{method}()' \
491-
// called with access level {:?}, required {} ({:?})",
492-
// rq_level,
493-
// method.access as i32,
494-
// method.access,
495-
// )
496-
// )
497-
// )
483+
Err(RpcError::new(
484+
RpcErrorCode::PermissionDenied,
485+
format!("Insufficient permissions. \
486+
Method '{path}:{}()' \
487+
called with access level {:?}, required {} ({:?})",
488+
method.name,
489+
rq_level,
490+
method.access as i32,
491+
method.access,
492+
)
493+
))
498494
}
499495
}
500496

0 commit comments

Comments
 (0)