Skip to content

Commit

Permalink
added back semver validation
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaElastic committed Dec 7, 2021
1 parent 1c60944 commit 154322e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion x-pack/plugins/fleet/server/routes/epm/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import path from 'path';

import type { TypeOf } from '@kbn/config-schema';
import mime from 'mime-types';
import semverValid from 'semver/functions/valid';
import type { ResponseHeaders, KnownHeaders } from 'src/core/server';

import type {
Expand Down Expand Up @@ -50,7 +51,11 @@ import {
getInstallation,
} from '../../services/epm/packages';
import type { BulkInstallResponse } from '../../services/epm/packages';
import { defaultIngestErrorHandler, ingestErrorToResponseOptions } from '../../errors';
import {
defaultIngestErrorHandler,
ingestErrorToResponseOptions,
IngestManagerError,
} from '../../errors';
import { licenseService } from '../../services';
import { getArchiveEntry } from '../../services/epm/archive/cache';
import { getAsset } from '../../services/epm/archive/storage';
Expand Down Expand Up @@ -190,6 +195,9 @@ export const getInfoHandler: FleetRequestHandler<TypeOf<typeof GetInfoRequestSch
try {
const savedObjectsClient = context.fleet.epm.internalSoClient;
const { pkgName, pkgVersion } = request.params;
if (!semverValid(pkgVersion)) {
throw new IngestManagerError('Package version is not a valid semver');
}
const res = await getPackageInfo({ savedObjectsClient, pkgName, pkgVersion });
const body: GetInfoResponse = {
item: res,
Expand Down

0 comments on commit 154322e

Please sign in to comment.