Skip to content

Commit e6c6aa2

Browse files
committed
fix: review
1 parent 16d17b1 commit e6c6aa2

File tree

7 files changed

+14
-16
lines changed

7 files changed

+14
-16
lines changed

src/containers/Tenant/Diagnostics/AccessRights/components/ChangeOwnerDialog.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ interface GetChangeOwnerDialogProps {
2121
export async function getChangeOwnerDialog({
2222
path,
2323
database,
24+
databaseFullPath,
2425
}: GetChangeOwnerDialogProps): Promise<boolean> {
2526
return await NiceModal.show(CHANGE_OWNER_DIALOG, {
2627
id: CHANGE_OWNER_DIALOG,
2728
path,
2829
database,
30+
databaseFullPath,
2931
});
3032
}
3133

src/containers/Tenant/Diagnostics/AccessRights/components/RightsTable/RevokeAllRightsDialog.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ export async function getRevokeAllRightsDialog({
2626
path,
2727
database,
2828
subject,
29+
databaseFullPath,
2930
}: GetRevokeAllRightsDialogProps): Promise<boolean> {
3031
return await NiceModal.show(REVOKE_ALL_RIGHTS_DIALOG, {
3132
id: REVOKE_ALL_RIGHTS_DIALOG,
3233
path,
3334
database,
3435
subject,
36+
databaseFullPath,
3537
});
3638
}
3739

src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TenantCpu.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,7 @@ export function TenantCpu({
6464
</>
6565
)}
6666
<StatsWrapper title={i18n('title_top-shards')} allEntitiesLink={topShardsLink}>
67-
<TopShards
68-
database={database}
69-
path={databaseFullPath}
70-
databaseFullPath={databaseFullPath}
71-
/>
67+
<TopShards database={database} databaseFullPath={databaseFullPath} />
7268
</StatsWrapper>
7369
<StatsWrapper
7470
title={i18n('title_top-queries')}

src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopShards.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ const columnsIds: TopShardsColumnId[] = ['TabletId', 'Path', 'CPUCores'];
99

1010
interface TopShardsProps {
1111
database: string;
12-
path: string;
1312
databaseFullPath: string;
1413
}
1514

16-
export const TopShards = ({database, path, databaseFullPath}: TopShardsProps) => {
15+
export const TopShards = ({database, databaseFullPath}: TopShardsProps) => {
1716
const ShardsTable = useComponent('ShardsTable');
1817

1918
const [autoRefreshInterval] = useAutoRefreshInterval();
2019

2120
const {currentData, isFetching, error} = topShardsApi.useGetTopShardsQuery(
22-
{database, path, databaseFullPath},
21+
{database, databaseFullPath},
2322
{pollingInterval: autoRefreshInterval},
2423
);
2524

src/store/reducers/tenantOverview/topShards/tenantOverviewTopShards.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@ export const topShardsApi = api.injectEndpoints({
1919
endpoints: (builder) => ({
2020
getTopShards: builder.query({
2121
queryFn: async (
22-
{
23-
database,
24-
path,
25-
databaseFullPath,
26-
}: {database: string; path: string; databaseFullPath: string},
22+
{database, databaseFullPath}: {database: string; databaseFullPath: string},
2723
{signal},
2824
) => {
2925
try {
3026
const response = await window.api.viewer.sendQuery(
3127
{
32-
query: createShardQuery(path, databaseFullPath),
28+
query: createShardQuery(databaseFullPath, databaseFullPath),
3329
database,
3430
action: queryAction,
3531
internal_call: true,

src/store/reducers/viewSchema/viewSchema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {transformPath} from '../../../containers/Tenant/ObjectSummary/transformPath';
12
import {isQueryErrorResponse} from '../../../utils/query';
23
import {api} from '../api';
34

@@ -20,7 +21,7 @@ export const viewSchemaApi = api.injectEndpoints({
2021
timeout?: number;
2122
}) => {
2223
try {
23-
const relativePath = path.replace(databaseFullPath, '');
24+
const relativePath = transformPath(path, databaseFullPath);
2425
const response = await window.api.viewer.sendQuery(
2526
{
2627
query: createViewSchemaQuery(relativePath),

src/utils/shardsQueryBuilders.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,7 @@ function createPathWhereCondition(path: string): string {
9595
if (!path) {
9696
return '';
9797
}
98-
return `Path='${path}' OR Path LIKE '${path}/%'`;
98+
// Escape single quotes to prevent SQL injection
99+
const escapedPath = path.replace(/'/g, "''");
100+
return `Path='${escapedPath}' OR Path LIKE '${escapedPath}/%'`;
99101
}

0 commit comments

Comments
 (0)