[8.5] [Fleet] Bugfix: always use posix paths for zip files (#144899) (#144913)

# Backport

This will backport the following commits from `main` to `8.5`:
- [[Fleet] Bugfix: always use posix paths for zip files
(#144899)](https://github.com/elastic/kibana/pull/144899)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Mark
Hopkin","email":"mark.hopkin@elastic.co"},"sourceCommit":{"committedDate":"2022-11-09T16:53:08Z","message":"[Fleet]
Bugfix: always use posix paths for zip files (#144899)\n\n##
Summary\r\n\r\nAlways use posix style paths when generating paths for
the
package\r\narchives.","sha":"d20bdb56d74bc2152126356e5acbe1ef58ab60f6","branchLabelMapping":{"^v8.6.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","Team:Fleet","backport:prev-minor","v8.6.0"],"number":144899,"url":"https://github.com/elastic/kibana/pull/144899","mergeCommit":{"message":"[Fleet]
Bugfix: always use posix paths for zip files (#144899)\n\n##
Summary\r\n\r\nAlways use posix style paths when generating paths for
the
package\r\narchives.","sha":"d20bdb56d74bc2152126356e5acbe1ef58ab60f6"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.6.0","labelRegex":"^v8.6.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/144899","number":144899,"mergeCommit":{"message":"[Fleet]
Bugfix: always use posix paths for zip files (#144899)\n\n##
Summary\r\n\r\nAlways use posix style paths when generating paths for
the
package\r\narchives.","sha":"d20bdb56d74bc2152126356e5acbe1ef58ab60f6"}}]}]
BACKPORT-->

Co-authored-by: Mark Hopkin <mark.hopkin@elastic.co>
This commit is contained in:
Kibana Machine 2022-11-09 12:58:56 -05:00 committed by GitHub
parent 87149bfd06
commit a6db757b62
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -179,7 +179,7 @@ function parseAndVerifyArchive(paths: string[], topLevelDirOverride?: string): A
});
// The package must contain a manifest file ...
const manifestFile = path.join(toplevelDir, MANIFEST_NAME);
const manifestFile = path.posix.join(toplevelDir, MANIFEST_NAME);
const manifestBuffer = MANIFESTS[manifestFile];
if (!paths.includes(manifestFile) || !manifestBuffer) {
throw new PackageInvalidArchiveError(`Package must contain a top-level ${MANIFEST_NAME} file.`);
@ -263,7 +263,7 @@ export function parseAndVerifyDataStreams(
const dataStreamPaths = new Set<string>();
const dataStreams: RegistryDataStream[] = [];
const pkgBasePath = pkgBasePathOverride || pkgToPkgKey({ name: pkgName, version: pkgVersion });
const dataStreamsBasePath = path.join(pkgBasePath, 'data_stream');
const dataStreamsBasePath = path.posix.join(pkgBasePath, 'data_stream');
// pick all paths matching name-version/data_stream/DATASTREAM_NAME/...
// from those, pick all unique data stream names
paths.forEach((filePath) => {
@ -275,8 +275,8 @@ export function parseAndVerifyDataStreams(
});
dataStreamPaths.forEach((dataStreamPath) => {
const fullDataStreamPath = path.join(dataStreamsBasePath, dataStreamPath);
const manifestFile = path.join(fullDataStreamPath, MANIFEST_NAME);
const fullDataStreamPath = path.posix.join(dataStreamsBasePath, dataStreamPath);
const manifestFile = path.posix.join(fullDataStreamPath, MANIFEST_NAME);
const manifestBuffer = MANIFESTS[manifestFile];
if (!paths.includes(manifestFile) || !manifestBuffer) {
throw new PackageInvalidArchiveError(
@ -547,7 +547,10 @@ const isDefaultPipelineFile = (pipelinePath: string) =>
pipelinePath.endsWith(DEFAULT_INGEST_PIPELINE_FILE_NAME_JSON);
export function parseDefaultIngestPipeline(fullDataStreamPath: string, paths: string[]) {
const ingestPipelineDirPath = path.join(fullDataStreamPath, '/elasticsearch/ingest_pipeline');
const ingestPipelineDirPath = path.posix.join(
fullDataStreamPath,
'/elasticsearch/ingest_pipeline'
);
const defaultIngestPipelinePaths = paths.filter(
(pipelinePath) =>
pipelinePath.startsWith(ingestPipelineDirPath) && isDefaultPipelineFile(pipelinePath)