Skip to content

Commit 05428a9

Browse files
#RI-4110 - remove dangerous commands recommendation
1 parent e42e71e commit 05428a9

File tree

6 files changed

+0
-112
lines changed

6 files changed

+0
-112
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/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/docs/management/security/acl/",
716-
"name": "Read more"
717-
}
718-
}
719-
],
720-
"badges": ["code_changes"]
721690
}
722691
}

redisinsight/ui/src/pages/databaseAnalysis/components/recommendations-view/Recommendations.spec.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -309,20 +309,6 @@ describe('Recommendations', () => {
309309
expect(screen.queryByTestId('configuration_changes')).not.toBeInTheDocument()
310310
})
311311

312-
it('should render configuration_changes badge in dangerousCommands recommendation', () => {
313-
(dbAnalysisSelector as jest.Mock).mockImplementation(() => ({
314-
...mockdbAnalysisSelector,
315-
data: {
316-
recommendations: [{ name: 'dangerousCommands', params: { commands: 'some commands' } }]
317-
}
318-
}))
319-
320-
render(<Recommendations />)
321-
expect(screen.queryByTestId('code_changes')).toBeInTheDocument()
322-
expect(screen.queryByTestId('upgrade')).not.toBeInTheDocument()
323-
expect(screen.queryByTestId('configuration_changes')).not.toBeInTheDocument()
324-
})
325-
326312
it('should collapse/expand and sent proper telemetry event', () => {
327313
(dbAnalysisSelector as jest.Mock).mockImplementation(() => ({
328314
...mockdbAnalysisSelector,

0 commit comments

Comments
 (0)