Skip to content

Commit 163b145

Browse files
authored
Merge pull request #1659 from RedisInsight/main
Merge main into release/2.18.0
2 parents 8de7bf1 + 559b589 commit 163b145

File tree

25 files changed

+5008
-116
lines changed

25 files changed

+5008
-116
lines changed

redisinsight/api/src/constants/recommendations.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@ export const RECOMMENDATION_NAMES = Object.freeze({
1717
REDIS_VERSION: 'redisVersion',
1818
REDIS_SEARCH: 'redisSearch',
1919
SEARCH_INDEXES: 'searchIndexes',
20-
DANGEROUS_COMMANDS: 'dangerousCommands',
2120
});
2221

2322
export const ONE_NODE_RECOMMENDATIONS = [
2423
RECOMMENDATION_NAMES.LUA_SCRIPT,
25-
RECOMMENDATION_NAMES.DANGEROUS_COMMANDS,
2624
RECOMMENDATION_NAMES.AVOID_LOGICAL_DATABASES,
2725
RECOMMENDATION_NAMES.RTS,
2826
RECOMMENDATION_NAMES.REDIS_VERSION,

redisinsight/api/src/modules/recommendation/providers/recommendation.provider.spec.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -651,18 +651,4 @@ describe('RecommendationProvider', () => {
651651
expect(redisVersionRecommendation).toEqual(null);
652652
});
653653
});
654-
655-
describe('determineDangerousCommandsRecommendation', () => {
656-
it('should not return dangerous commands recommendation when "command" command executed with error',
657-
async () => {
658-
resetAllWhenMocks();
659-
when(nodeClient.sendCommand)
660-
.calledWith(jasmine.objectContaining({ name: 'command' }))
661-
.mockRejectedValue('some error');
662-
663-
const dangerousCommandsRecommendation = await service
664-
.determineDangerousCommandsRecommendation(nodeClient);
665-
expect(dangerousCommandsRecommendation).toEqual(null);
666-
});
667-
});
668654
});

redisinsight/api/src/modules/recommendation/providers/recommendation.provider.ts

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -438,39 +438,6 @@ export class RecommendationProvider {
438438
}
439439
}
440440

441-
/*
442-
* Check dangerous commands recommendation
443-
* @param redisClient
444-
*/
445-
446-
async determineDangerousCommandsRecommendation(
447-
redisClient: Redis | Cluster,
448-
): Promise<Recommendation> {
449-
try {
450-
const dangerousCommands = await redisClient.sendCommand(
451-
new Command('ACL', ['CAT', 'dangerous'], { replyEncoding: 'utf8' }),
452-
) as string[];
453-
454-
const filteredDangerousCommands = dangerousCommands.filter((command) => {
455-
const commandName = command.split('|')[0];
456-
return !redisInsightCommands.includes(commandName);
457-
});
458-
459-
const activeDangerousCommands = await Promise.all(
460-
filteredDangerousCommands.map(async (command) => await this.checkCommandInfo(redisClient, command)),
461-
);
462-
const commands = activeDangerousCommands
463-
.filter((command) => !isNull(command))
464-
.join('\r\n').toUpperCase();
465-
return activeDangerousCommands.length
466-
? { name: RECOMMENDATION_NAMES.DANGEROUS_COMMANDS, params: { commands } }
467-
: null;
468-
} catch (err) {
469-
this.logger.error('Can not determine dangerous commands recommendation', err);
470-
return null;
471-
}
472-
}
473-
474441
private async checkAuth(redisClient: Redis | Cluster): Promise<boolean> {
475442
try {
476443
await redisClient.sendCommand(
@@ -484,20 +451,6 @@ export class RecommendationProvider {
484451
return false;
485452
}
486453

487-
private async checkCommandInfo(redisClient: Redis | Cluster, command: string): Promise<string> {
488-
try {
489-
const result = await redisClient.sendCommand(
490-
new Command('command', ['info', command]),
491-
);
492-
if (isNull(result[0])) {
493-
return null;
494-
}
495-
} catch (err) {
496-
return null;
497-
}
498-
return command;
499-
}
500-
501454
private checkTimestamp(value: string): boolean {
502455
try {
503456
if (!IS_NUMBER_REGEX.test(value) && isValid(new Date(value))) {

redisinsight/api/src/modules/recommendation/recommendation.service.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ export class RecommendationService {
108108
RECOMMENDATION_NAMES.SEARCH_INDEXES,
109109
async () => await this.recommendationProvider.determineSearchIndexesRecommendation(client, keys, globalClient),
110110
],
111-
[
112-
RECOMMENDATION_NAMES.DANGEROUS_COMMANDS,
113-
async () => await this.recommendationProvider.determineDangerousCommandsRecommendation(client),
114-
],
115111
[
116112
RECOMMENDATION_NAMES.SET_PASSWORD,
117113
async () => await this.recommendationProvider.determineSetPasswordRecommendation(client),

redisinsight/ui/src/components/query-card/QueryCardHeader/QueryCardHeader.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ const QueryCardHeader = (props: Props) => {
109109
setSelectedValue,
110110
onQueryDelete,
111111
onQueryReRun,
112+
onQueryProfile,
112113
db,
113114
} = props
114115

redisinsight/ui/src/constants/dbAnalysisRecommendations.json

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -687,36 +687,5 @@
687687
}
688688
],
689689
"badges": ["upgrade"]
690-
},
691-
"dangerousCommands": {
692-
"id": "dangerousCommands",
693-
"title": "Rename or disable dangerous commands",
694-
"content": [
695-
{
696-
"id": "1",
697-
"type": "paragraph",
698-
"value": "The following commands are currently not renamed or disabled for your Instance. These commands are powerful and dangerous if not managed properly. Rename or disable them, especially for the production environment"
699-
},
700-
{
701-
"id": "2",
702-
"type": "pre",
703-
"parameter": ["commands"],
704-
"value": "${0} "
705-
},
706-
{
707-
"id": "3",
708-
"type": "spacer",
709-
"value": "s"
710-
},
711-
{
712-
"id": "4",
713-
"type": "link",
714-
"value": {
715-
"href": "https://redis.io/download/",
716-
"name": "Read more"
717-
}
718-
}
719-
],
720-
"badges": ["code_changes"]
721690
}
722691
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# RI-Explain plugin
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"author": {
3+
"name": "Redis Ltd.",
4+
"email": "[email protected]",
5+
"url": "https://redis.com/redis-enterprise/redis-insight"
6+
},
7+
"bugs": {
8+
"url": "https://github.com/"
9+
},
10+
"description": "Show Profile/Explain Visualization",
11+
"source": "./src/main.tsx",
12+
"styles": "./dist/styles.css",
13+
"main": "./dist/index.js",
14+
"name": "explain-plugin",
15+
"version": "0.0.1",
16+
"scripts": {
17+
"start": "cross-env NODE_ENV=development parcel serve src/index.html",
18+
"build": "rimraf dist && cross-env NODE_ENV=production concurrently \"yarn build:js && yarn minify:js\" \"yarn build:css\" \"yarn build:assets\"",
19+
"build-lite": "rm dist/*.js && cross-env NODE_ENV=production concurrently \"yarn build:js && yarn minify:js\"",
20+
"build:js": "parcel build src/main.tsx --dist-dir dist",
21+
"build:css": "parcel build src/styles/styles.less --dist-dir dist",
22+
"build:assets": "parcel build src/assets/**/* --dist-dir dist",
23+
"minify:js": "terser -- dist/main.js > dist/index.js && rimraf dist/main.js"
24+
},
25+
"targets": {
26+
"main": false,
27+
"module": {
28+
"includeNodeModules": true
29+
}
30+
},
31+
"visualizations": [
32+
{
33+
"id": "profile-explain-viz",
34+
"name": "Visualization",
35+
"activationMethod": "renderCore",
36+
"matchCommands": [
37+
"FT.EXPLAIN",
38+
"FT.EXPLAINCLI",
39+
"FT.PROFILE",
40+
"GRAPH.EXPLAIN",
41+
"GRAPH.PROFILE"
42+
],
43+
"iconDark": "./dist/profile_icon_dark.svg",
44+
"iconLight": "./dist/profile_icon_light.svg",
45+
"description": "Profile/Explain plugin Visualization",
46+
"default": true
47+
}
48+
],
49+
"devDependencies": {
50+
"@parcel/compressor-brotli": "^2.0.0",
51+
"@parcel/compressor-gzip": "^2.0.0",
52+
"@parcel/transformer-less": "^2.3.2",
53+
"concurrently": "^6.3.0",
54+
"cross-env": "^7.0.3",
55+
"parcel": "^2.0.0",
56+
"rimraf": "^3.0.2",
57+
"terser": "^5.9.0"
58+
},
59+
"dependencies": {
60+
"@antv/hierarchy": "^0.6.8",
61+
"@antv/x6": "^2.1.3",
62+
"@antv/x6-react-shape": "^2.1.0",
63+
"@elastic/eui": "34.6.0",
64+
"@emotion/react": "^11.7.1",
65+
"classnames": "^2.3.1",
66+
"prop-types": "^15.8.1",
67+
"react": "^18.2.0",
68+
"react-dom": "^18.2.0",
69+
"uuid": "^9.0.0"
70+
}
71+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react'
2+
import Explain from './Explain'
3+
4+
const isDarkTheme = document.body.classList.contains('theme_DARK')
5+
6+
export function App(props: { command?: string, data: any }) {
7+
8+
const ErrorResponse = HandleError(props)
9+
10+
if (ErrorResponse !== null) return ErrorResponse
11+
12+
return (
13+
<div id="mainApp" style={{ height: "100%", width: '100%', overflowX: 'auto' }}>
14+
<Explain command={props.command || ''} data={props.data}/>
15+
</div>
16+
)
17+
}
18+
19+
function HandleError(props: { command?: string, data: any }): JSX.Element | null {
20+
const { data: [{ response = '', status = '' } = {}] = [] } = props
21+
22+
if (status === 'fail') {
23+
return <div className="responseFail">{JSON.stringify(response)}</div>
24+
}
25+
26+
return null
27+
}

0 commit comments

Comments
 (0)