Repository: Infisical/infisical
File: frontend/src/components/v2/InfisicalSecretInput/InfisicalSecretInput.tsx (TypeScript)

Code before:
                text: "Invalid secret reference",
                type: "error"
              });
              return;
            }

            const pathSegment = pathSegments[i];
            folderPath += `${pathSegment}`;
            if (pathSegment === segment) {
              folderPath += "/";
              break;
            }
            folderPath += "/";
          }
        }

        const secretPath = segment === environmentSlug ? "/" : folderPath;

        const canReadSecretValue = hasSecretReadValueOrDescribePermission(
          permission,
          ProjectPermissionSecretActions.ReadValue,
          {
            environment: environmentSlug,
            secretPath,
            secretName: secretName ?? "",
            secretTags: []
          }
        );

        console.log("canReadSecretValue", canReadSecretValue);
        console.log("environmentSlug", environmentSlug);
        console.log("secretPath", secretPath);
        console.log("secretName", secretName);

        if (!canReadSecretValue) {
          createNotification({
            text: "You do not have permission to access this secret",
            type: "error"
          });
          return;
        }

        navigate({
          to: ROUTE_PATHS.SecretManager.SecretDashboardPage.path,
          params: {
            projectId,
            envSlug: environmentSlug
          },
          search: (prev) => ({
            ...prev,
            secretPath: segment === environmentSlug ? "/" : folderPath,

Review comment (security):
I think if these aren't set (because of the segment clicked) we should use wildcards (same above):
  ``` 
  secretName: secretName ?? "*",
  secretTags: ["*"]
  ```

Code after:
            }

            const pathSegment = pathSegments[i];
            folderPath += `${pathSegment}`;
            if (pathSegment === segment) {
              folderPath += "/";
              break;
            }
            folderPath += "/";
          }
        }

        // Only validate secret permission, users can always view environments and folders
        if (segment === secretName) {
          const canReadSecretValue = hasSecretReadValueOrDescribePermission(
            permission,
            ProjectPermissionSecretActions.ReadValue,
            {
              environment: environmentSlug,
              secretPath: folderPath,
              secretName,
              secretTags: ["*"]
            }
          );

          if (!canReadSecretValue) {
            createNotification({
              text: "You do not have permission to access this secret",
              type: "error"
            });
            return;
          }
        }

        navigate({
          to: ROUTE_PATHS.SecretManager.SecretDashboardPage.path,
          params: {
            projectId,
            envSlug: environmentSlug
          },
          search: (prev) => ({
            ...prev,
            secretPath: segment === environmentSlug ? "/" : folderPath,
            search: segment === secretName ? secretName : prev.search,
            filterBy: segment === secretName ? "secret" : prev.filterBy,
            tags: ""
          })
        });
      },
      [navigate, projectId, permission, propEnvironment, propSecretPath]
    );