@backstage/plugin-scaffolder-node 0.11.1-next.0 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @backstage/plugin-scaffolder-node
2
2
 
3
+ ## 0.11.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Backport security fixes
8
+
9
+ ## 0.11.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+ - @backstage/integration@1.18.0
15
+ - @backstage/types@1.2.2
16
+ - @backstage/backend-plugin-api@1.4.3
17
+ - @backstage/plugin-scaffolder-common@1.7.1
18
+
3
19
  ## 0.11.1-next.0
4
20
 
5
21
  ### Patch Changes
@@ -23,7 +23,9 @@ async function fetchContents(options) {
23
23
  if (!fetchUrlIsAbsolute && baseUrl?.startsWith("file://")) {
24
24
  const basePath = baseUrl.slice("file://".length);
25
25
  const srcDir = backendPluginApi.resolveSafeChildPath(path__default.default.dirname(basePath), fetchUrl);
26
- await fs__default.default.copy(srcDir, outputPath);
26
+ await fs__default.default.copy(srcDir, outputPath, {
27
+ filter: (src) => backendPluginApi.isChildPath(srcDir, src)
28
+ });
27
29
  } else {
28
30
  const readUrl = getReadUrl(fetchUrl, baseUrl, integrations);
29
31
  const res = await reader.readTree(readUrl, { token });
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.cjs.js","sources":["../../src/actions/fetch.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { UrlReaderService } from '@backstage/backend-plugin-api';\nimport { resolveSafeChildPath } from '@backstage/backend-plugin-api';\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\nimport fs from 'fs-extra';\nimport path from 'path';\n\n/**\n * A helper function that reads the contents of a directory from the given URL.\n * Can be used in your own actions, and also used behind fetch:template and fetch:plain\n *\n * @public\n */\nexport async function fetchContents(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n baseUrl?: string;\n fetchUrl?: string;\n outputPath: string;\n token?: string;\n}) {\n const {\n reader,\n integrations,\n baseUrl,\n fetchUrl = '.',\n outputPath,\n token,\n } = options;\n\n const fetchUrlIsAbsolute = isFetchUrlAbsolute(fetchUrl);\n\n // We handle both file locations and url ones\n if (!fetchUrlIsAbsolute && baseUrl?.startsWith('file://')) {\n const basePath = baseUrl.slice('file://'.length);\n const srcDir = resolveSafeChildPath(path.dirname(basePath), fetchUrl);\n await fs.copy(srcDir, outputPath);\n } else {\n const readUrl = getReadUrl(fetchUrl, baseUrl, integrations);\n\n const res = await reader.readTree(readUrl, { token });\n await fs.ensureDir(outputPath);\n await res.dir({ targetDir: outputPath });\n }\n}\n\n/**\n * A helper function that reads the content of a single file from the given URL.\n * Can be used in your own actions, and also used behind `fetch:plain:file`\n *\n * @public\n */\nexport async function fetchFile(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n baseUrl?: string;\n fetchUrl?: string;\n outputPath: string;\n token?: string;\n}) {\n const {\n reader,\n integrations,\n baseUrl,\n fetchUrl = '.',\n outputPath,\n token,\n } = options;\n\n const fetchUrlIsAbsolute = isFetchUrlAbsolute(fetchUrl);\n\n // We handle both file locations and url ones\n if (!fetchUrlIsAbsolute && baseUrl?.startsWith('file://')) {\n const basePath = baseUrl.slice('file://'.length);\n const src = resolveSafeChildPath(path.dirname(basePath), fetchUrl);\n await fs.copyFile(src, outputPath);\n } else {\n const readUrl = getReadUrl(fetchUrl, baseUrl, integrations);\n\n const res = await reader.readUrl(readUrl, { token });\n await fs.ensureDir(path.dirname(outputPath));\n const buffer = await res.buffer();\n await fs.outputFile(outputPath, buffer);\n }\n}\n\nfunction isFetchUrlAbsolute(fetchUrl: string) {\n let fetchUrlIsAbsolute = false;\n try {\n // eslint-disable-next-line no-new\n new URL(fetchUrl);\n fetchUrlIsAbsolute = true;\n } catch {\n /* ignored */\n }\n return fetchUrlIsAbsolute;\n}\n\nfunction getReadUrl(\n fetchUrl: string,\n baseUrl: string | undefined,\n integrations: ScmIntegrations,\n) {\n if (isFetchUrlAbsolute(fetchUrl)) {\n return fetchUrl;\n } else if (baseUrl) {\n const integration = integrations.byUrl(baseUrl);\n if (!integration) {\n throw new InputError(`No integration found for location ${baseUrl}`);\n }\n\n return integration.resolveUrl({\n url: fetchUrl,\n base: baseUrl,\n });\n }\n throw new InputError(\n `Failed to fetch, template location could not be determined and the fetch URL is relative, ${fetchUrl}`,\n );\n}\n"],"names":["resolveSafeChildPath","path","fs","InputError"],"mappings":";;;;;;;;;;;;AA6BA,eAAsB,cAAc,OAAA,EAOjC;AACD,EAAA,MAAM;AAAA,IACJ,MAAA;AAAA,IACA,YAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA,GAAW,GAAA;AAAA,IACX,UAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAEJ,EAAA,MAAM,kBAAA,GAAqB,mBAAmB,QAAQ,CAAA;AAGtD,EAAA,IAAI,CAAC,kBAAA,IAAsB,OAAA,EAAS,UAAA,CAAW,SAAS,CAAA,EAAG;AACzD,IAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,KAAA,CAAM,SAAA,CAAU,MAAM,CAAA;AAC/C,IAAA,MAAM,SAASA,qCAAA,CAAqBC,qBAAA,CAAK,OAAA,CAAQ,QAAQ,GAAG,QAAQ,CAAA;AACpE,IAAA,MAAMC,mBAAA,CAAG,IAAA,CAAK,MAAA,EAAQ,UAAU,CAAA;AAAA,EAClC,CAAA,MAAO;AACL,IAAA,MAAM,OAAA,GAAU,UAAA,CAAW,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ACF;AAEA,SAAS,mBAAmB,QAAA,EAAkB;AAC5C,EAAA,IAAI,kBAAA,GAAqB,KAAA;AACzB,EAAA,IAAI;AAEF,IAAA,IAAI,IAAI,QAAQ,CAAA;AAChB,IAAA,kBAAA,GAAqB,IAAA;AAAA,EACvB,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,kBAAA;AACT;AAEA,SAAS,UAAA,CACP,QAAA,EACA,OAAA,EACA,YAAA,EACA;AACA,EAAA,IAAI,kBAAA,CAAmB,QAAQ,CAAA,EAAG;AAChC,IAAA,OAAO,QAAA;AAAA,EACT,WAAW,OAAA,EAAS;AAClB,IAAA,MAAM,WAAA,GAAc,YAAA,CAAa,KAAA,CAAM,OAAO,CAAA;AAC9C,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,MAAM,IAAIC,iBAAA,CAAW,CAAA,kCAAA,EAAqC,OAAO,CAAA,CAAE,CAAA;AAAA,IACrE;AAEA,IAAA,OAAO,YAAY,UAAA,CAAW;AAAA,MAC5B,GAAA,EAAK,QAAA;AAAA,MACL,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACA,EAAA,MAAM,IAAIA,iBAAA;AAAA,IACR,6FAA6F,QAAQ,CAAA;AAAA,GACvG;AACF;;;;;"}
1
+ {"version":3,"file":"fetch.cjs.js","sources":["../../src/actions/fetch.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { UrlReaderService } from '@backstage/backend-plugin-api';\nimport {\n isChildPath,\n resolveSafeChildPath,\n} from '@backstage/backend-plugin-api';\nimport { InputError } from '@backstage/errors';\nimport { ScmIntegrations } from '@backstage/integration';\nimport fs from 'fs-extra';\nimport path from 'path';\n\n/**\n * A helper function that reads the contents of a directory from the given URL.\n * Can be used in your own actions, and also used behind fetch:template and fetch:plain\n *\n * @public\n */\nexport async function fetchContents(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n baseUrl?: string;\n fetchUrl?: string;\n outputPath: string;\n token?: string;\n}) {\n const {\n reader,\n integrations,\n baseUrl,\n fetchUrl = '.',\n outputPath,\n token,\n } = options;\n\n const fetchUrlIsAbsolute = isFetchUrlAbsolute(fetchUrl);\n\n // We handle both file locations and url ones\n if (!fetchUrlIsAbsolute && baseUrl?.startsWith('file://')) {\n const basePath = baseUrl.slice('file://'.length);\n const srcDir = resolveSafeChildPath(path.dirname(basePath), fetchUrl);\n await fs.copy(srcDir, outputPath, {\n filter: src => isChildPath(srcDir, src),\n });\n } else {\n const readUrl = getReadUrl(fetchUrl, baseUrl, integrations);\n\n const res = await reader.readTree(readUrl, { token });\n await fs.ensureDir(outputPath);\n await res.dir({ targetDir: outputPath });\n }\n}\n\n/**\n * A helper function that reads the content of a single file from the given URL.\n * Can be used in your own actions, and also used behind `fetch:plain:file`\n *\n * @public\n */\nexport async function fetchFile(options: {\n reader: UrlReaderService;\n integrations: ScmIntegrations;\n baseUrl?: string;\n fetchUrl?: string;\n outputPath: string;\n token?: string;\n}) {\n const {\n reader,\n integrations,\n baseUrl,\n fetchUrl = '.',\n outputPath,\n token,\n } = options;\n\n const fetchUrlIsAbsolute = isFetchUrlAbsolute(fetchUrl);\n\n // We handle both file locations and url ones\n if (!fetchUrlIsAbsolute && baseUrl?.startsWith('file://')) {\n const basePath = baseUrl.slice('file://'.length);\n const src = resolveSafeChildPath(path.dirname(basePath), fetchUrl);\n await fs.copyFile(src, outputPath);\n } else {\n const readUrl = getReadUrl(fetchUrl, baseUrl, integrations);\n\n const res = await reader.readUrl(readUrl, { token });\n await fs.ensureDir(path.dirname(outputPath));\n const buffer = await res.buffer();\n await fs.outputFile(outputPath, buffer);\n }\n}\n\nfunction isFetchUrlAbsolute(fetchUrl: string) {\n let fetchUrlIsAbsolute = false;\n try {\n // eslint-disable-next-line no-new\n new URL(fetchUrl);\n fetchUrlIsAbsolute = true;\n } catch {\n /* ignored */\n }\n return fetchUrlIsAbsolute;\n}\n\nfunction getReadUrl(\n fetchUrl: string,\n baseUrl: string | undefined,\n integrations: ScmIntegrations,\n) {\n if (isFetchUrlAbsolute(fetchUrl)) {\n return fetchUrl;\n } else if (baseUrl) {\n const integration = integrations.byUrl(baseUrl);\n if (!integration) {\n throw new InputError(`No integration found for location ${baseUrl}`);\n }\n\n return integration.resolveUrl({\n url: fetchUrl,\n base: baseUrl,\n });\n }\n throw new InputError(\n `Failed to fetch, template location could not be determined and the fetch URL is relative, ${fetchUrl}`,\n );\n}\n"],"names":["resolveSafeChildPath","path","fs","isChildPath","InputError"],"mappings":";;;;;;;;;;;;AAgCA,eAAsB,cAAc,OAAA,EAOjC;AACD,EAAA,MAAM;AAAA,IACJ,MAAA;AAAA,IACA,YAAA;AAAA,IACA,OAAA;AAAA,IACA,QAAA,GAAW,GAAA;AAAA,IACX,UAAA;AAAA,IACA;AAAA,GACF,GAAI,OAAA;AAEJ,EAAA,MAAM,kBAAA,GAAqB,mBAAmB,QAAQ,CAAA;AAGtD,EAAA,IAAI,CAAC,kBAAA,IAAsB,OAAA,EAAS,UAAA,CAAW,SAAS,CAAA,EAAG;AACzD,IAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,KAAA,CAAM,SAAA,CAAU,MAAM,CAAA;AAC/C,IAAA,MAAM,SAASA,qCAAA,CAAqBC,qBAAA,CAAK,OAAA,CAAQ,QAAQ,GAAG,QAAQ,CAAA;AACpE,IAAA,MAAMC,mBAAA,CAAG,IAAA,CAAK,MAAA,EAAQ,UAAA,EAAY;AAAA,MAChC,MAAA,EAAQ,CAAA,GAAA,KAAOC,4BAAA,CAAY,MAAA,EAAQ,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EAAO;AAChC,IAAA,MAAMC,mBAAA,CAAG,UAAA,CAAW,UAAA,EAAY,MAAM,CAAA;AAAA,EACxC;AACF;AAEA,SAAS,mBAAmB,QAAA,EAAkB;AAC5C,EAAA,IAAI,kBAAA,GAAqB,KAAA;AACzB,EAAA,IAAI;AAEF,IAAA,IAAI,IAAI,QAAQ,CAAA;AAChB,IAAA,kBAAA,GAAqB,IAAA;AAAA,EACvB,CAAA,CAAA,MAAQ;AAAA,EAER;AACA,EAAA,OAAO,kBAAA;AACT;AAEA,SAAS,UAAA,CACP,QAAA,EACA,OAAA,EACA,YAAA,EACA;AACA,EAAA,IAAI,kBAAA,CAAmB,QAAQ,CAAA,EAAG;AAChC,IAAA,OAAO,QAAA;AAAA,EACT,WAAW,OAAA,EAAS;AAClB,IAAA,MAAM,WAAA,GAAc,YAAA,CAAa,KAAA,CAAM,OAAO,CAAA;AAC9C,IAAA,IAAI,CAAC,WAAA,EAAa;AAChB,MAAA,MAAM,IAAIE,iBAAA,CAAW,CAAA,kCAAA,EAAqC,OAAO,CAAA,CAAE,CAAA;AAAA,IACrE;AAEA,IAAA,OAAO,YAAY,UAAA,CAAW;AAAA,MAC5B,GAAA,EAAK,QAAA;AAAA,MACL,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH;AACA,EAAA,MAAM,IAAIA,iBAAA;AAAA,IACR,6FAA6F,QAAQ,CAAA;AAAA,GACvG;AACF;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-scaffolder-node",
3
- "version": "0.11.1-next.0",
3
+ "version": "0.11.2",
4
4
  "description": "The plugin-scaffolder-node module for @backstage/plugin-scaffolder-backend",
5
5
  "backstage": {
6
6
  "role": "node-library",
@@ -62,13 +62,13 @@
62
62
  "test": "backstage-cli package test"
63
63
  },
64
64
  "dependencies": {
65
- "@backstage/backend-plugin-api": "1.4.3-next.0",
66
- "@backstage/catalog-model": "1.7.5",
67
- "@backstage/errors": "1.2.7",
68
- "@backstage/integration": "1.18.0-next.0",
69
- "@backstage/plugin-permission-common": "0.9.1",
70
- "@backstage/plugin-scaffolder-common": "1.7.1-next.0",
71
- "@backstage/types": "1.2.1",
65
+ "@backstage/backend-plugin-api": "^1.4.3",
66
+ "@backstage/catalog-model": "^1.7.5",
67
+ "@backstage/errors": "^1.2.7",
68
+ "@backstage/integration": "^1.18.0",
69
+ "@backstage/plugin-permission-common": "^0.9.1",
70
+ "@backstage/plugin-scaffolder-common": "^1.7.1",
71
+ "@backstage/types": "^1.2.2",
72
72
  "@isomorphic-git/pgp-plugin": "^0.0.7",
73
73
  "concat-stream": "^2.0.0",
74
74
  "fs-extra": "^11.2.0",
@@ -84,9 +84,9 @@
84
84
  "zod-to-json-schema": "^3.20.4"
85
85
  },
86
86
  "devDependencies": {
87
- "@backstage/backend-test-utils": "1.9.0-next.1",
88
- "@backstage/cli": "0.34.2-next.1",
89
- "@backstage/config": "1.3.3",
87
+ "@backstage/backend-test-utils": "^1.9.0",
88
+ "@backstage/cli": "^0.34.3",
89
+ "@backstage/config": "^1.3.4",
90
90
  "@types/lodash": "^4.14.151"
91
91
  }
92
92
  }