Skip to content

Commit 8fbc903

Browse files
committed
Send same message for non-existent and non-authorized container
1 parent f17141e commit 8fbc903

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

core/src/org/labkey/core/CoreMcp.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,22 @@ String setContainer(ToolContext context, @ToolParam(description = "Container pat
9999
{
100100
final String message;
101101

102-
if (containerPath == null)
102+
if (StringUtils.isBlank(containerPath))
103103
{
104-
message = "Container path was null. Please provide a valid containerPath parameter. Try using the listContainers tool to see them.";
104+
message = "Container path was missing. Please provide a valid containerPath parameter. Try using the listContainers tool to see them.";
105105
}
106106
else
107107
{
108108
Container container = ContainerManager.getForPath(containerPath);
109109

110-
if (container == null)
110+
// Must exist and user must have read permission to set a container. Note: Send the same message in both
111+
// cases to prevent information exposure.
112+
if (container == null || !container.hasPermission(getUser(context), ReadPermission.class))
111113
{
112114
message = "That's not a valid container path. Try using listContainers to see them.";
113115
}
114116
else
115117
{
116-
// Must have read permission to set a container
117-
if (!container.hasPermission(getUser(context), ReadPermission.class))
118-
throw new UnauthorizedException();
119-
120118
McpService.get().saveSessionContainer(context, container);
121119
message = "Container has been set to " + container.getPath();
122120
}

0 commit comments

Comments
 (0)