Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.17] [ML] Removing use of re2 library (#186104) #188372

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { IScopedClusterClient } from 'kibana/server';
import RE2 from 're2';
import { mlLog } from '../../../lib/log';
import { Job } from '../../../../common/types/anomaly_detection_jobs';

Expand Down Expand Up @@ -43,7 +42,7 @@ export async function logJobsSpaces({
}

function findLogJobSpaceFactory() {
const reg = new RE2(`${MODULE_PREFIX}-(.+)-(${SOURCES.join('|')})-(${JOB_IDS.join('|')})`);
const reg = new RegExp(`${MODULE_PREFIX}-(.+)-(${SOURCES.join('|')})-(${JOB_IDS.join('|')})`);

return (jobId: string) => {
const result = reg.exec(jobId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { IScopedClusterClient } from 'kibana/server';
import RE2 from 're2';
import { mlLog } from '../../../lib/log';
import { Job } from '../../../../common/types/anomaly_detection_jobs';

Expand Down Expand Up @@ -50,7 +49,7 @@ export async function metricsJobsSpaces({
}

function findMetricsJobSpaceFactory() {
const reg = new RE2(`${MODULE_PREFIX}-(.+)-(${SOURCES.join('|')})-(${JOB_IDS.join('|')})`);
const reg = new RegExp(`${MODULE_PREFIX}-(.+)-(${SOURCES.join('|')})-(${JOB_IDS.join('|')})`);

return (jobId: string) => {
const result = reg.exec(jobId);
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/ml/server/saved_objects/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import RE2 from 're2';
import {
KibanaRequest,
SavedObjectsClientContract,
Expand Down Expand Up @@ -281,7 +280,7 @@ export function jobSavedObjectServiceFactory(
if (id.match('\\*') === null) {
return jobIds.includes(id);
}
const regex = new RE2(id.replace('*', '.*'));
const regex = new RegExp(id.replace('*', '.*'));
return jobIds.some((jId) => typeof jId === 'string' && regex.exec(jId));
});
}
Expand Down