From 0b76c700be9fcfd183b6c92617baea5c69426f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Wed, 28 Aug 2024 12:09:24 +0200 Subject: [PATCH] remove various little backend-common references MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- SECURITY.md | 4 ++-- docs/backend-system/core-services/database.md | 2 +- docs/contribute/project-structure.md | 8 +++++--- packages/cli/config/eslint-factory.js | 2 +- .../cli/templates/default-backend-module/package.json.hbs | 1 - .../cli/templates/default-backend-plugin/package.json.hbs | 1 - packages/cli/templates/scaffolder-module/package.json.hbs | 1 - .../scaffolder-module/src/actions/example/example.test.ts | 6 ++---- .../src/identity/UserInfoDatabaseHandler.test.ts | 2 +- 9 files changed, 12 insertions(+), 15 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 8de1307356..5c6c8106d5 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -59,14 +59,14 @@ function writeTemporaryFile(tmpDir: string, name: string, content: string) { If the `name` of the file is controlled by the user, they can for example enter `../../../../etc/hosts` as the name of the file. This can lead to a file being written outside the intended directory, which in turn can be used to inject malicious code or other form of attacks. -The recommended solution to this is to use `resolveSafeChildPath` from `@backstage/backend-common` to resolve the file path instead. It makes sure that the resolved path does not fall outside the provided directory. If you simply want to validate whether a file path is safe, you can use `isChildPath` instead. +The recommended solution to this is to use `resolveSafeChildPath` from `@backstage/backend-plugin-api` to resolve the file path instead. It makes sure that the resolved path does not fall outside the provided directory. If you simply want to validate whether a file path is safe, you can use `isChildPath` instead. The insecure example above should instead be written like this: ```ts // THIS IS GOOD, DO THIS -import { resolveSafeChildPath } from '@backstage/backend-common'; +import { resolveSafeChildPath } from '@backstage/backend-plugin-api'; import fs from 'fs-extra'; function writeTemporaryFile(tmpDir: string, name: string, content: string) { diff --git a/docs/backend-system/core-services/database.md b/docs/backend-system/core-services/database.md index e083f0b44d..2a172cbe46 100644 --- a/docs/backend-system/core-services/database.md +++ b/docs/backend-system/core-services/database.md @@ -20,7 +20,7 @@ import { coreServices, createBackendPlugin, } from '@backstage/backend-plugin-api'; -import { resolvePackagePath } from '@backstage/backend-common'; +import { resolvePackagePath } from '@backstage/backend-plugin-api'; createBackendPlugin({ pluginId: 'example', diff --git a/docs/contribute/project-structure.md b/docs/contribute/project-structure.md index 16f20a66ca..f06fba0523 100644 --- a/docs/contribute/project-structure.md +++ b/docs/contribute/project-structure.md @@ -82,9 +82,11 @@ are separated out into their own folder, see further down. package. The `backend` uses plugins to construct a working backend that the frontend (`app`) can use. -- [`backend-common/`](https://github.com/backstage/backstage/tree/master/packages/backend-common) - - There are no "core" packages in the backend. Instead we have `backend-common` - which contains helper middleware and other utils. +- [`backend-app-api/`](https://github.com/backstage/backstage/tree/master/packages/backend-app-api) - + This package contains the central wiring for how to make Backstage backends. + +- [`backend-plugin-api/`](https://github.com/backstage/backstage/tree/master/packages/backend-plugin-api) - + This package contains the core APIs that are used to make Backstage backend features such as plugins and modules. - [`catalog-client`](https://github.com/backstage/backstage/tree/master/packages/catalog-client) - An isomorphic client to interact with the Software Catalog. Backend plugins diff --git a/packages/cli/config/eslint-factory.js b/packages/cli/config/eslint-factory.js index 96d8478ec0..856068eef9 100644 --- a/packages/cli/config/eslint-factory.js +++ b/packages/cli/config/eslint-factory.js @@ -277,7 +277,7 @@ function createConfigForRole(dir, role, extraConfig = {}) { restrictedSrcSyntax: [ { message: - "`__dirname` doesn't refer to the same dir in production builds, try `resolvePackagePath()` from `@backstage/backend-common` instead.", + "`__dirname` doesn't refer to the same dir in production builds, try `resolvePackagePath()` from `@backstage/backend-plugin-api` instead.", selector: 'Identifier[name="__dirname"]', }, ...(extraConfig.restrictedSrcSyntax ?? []), diff --git a/packages/cli/templates/default-backend-module/package.json.hbs b/packages/cli/templates/default-backend-module/package.json.hbs index db8b8749b3..7e82e047ce 100644 --- a/packages/cli/templates/default-backend-module/package.json.hbs +++ b/packages/cli/templates/default-backend-module/package.json.hbs @@ -29,7 +29,6 @@ "postpack": "backstage-cli package postpack" }, "dependencies": { - "@backstage/backend-common": "{{versionQuery '@backstage/backend-common'}}", "@backstage/backend-plugin-api": "{{versionQuery '@backstage/backend-plugin-api'}}" }, "devDependencies": { diff --git a/packages/cli/templates/default-backend-plugin/package.json.hbs b/packages/cli/templates/default-backend-plugin/package.json.hbs index b05d1a844b..6c25562c21 100644 --- a/packages/cli/templates/default-backend-plugin/package.json.hbs +++ b/packages/cli/templates/default-backend-plugin/package.json.hbs @@ -28,7 +28,6 @@ "postpack": "backstage-cli package postpack" }, "dependencies": { - "@backstage/backend-common": "{{versionQuery '@backstage/backend-common'}}", "@backstage/backend-defaults": "{{versionQuery '@backstage/backend-defaults'}}", "@backstage/backend-plugin-api": "{{versionQuery '@backstage/backend-plugin-api'}}", "express": "{{versionQuery 'express' '4.17.1'}}", diff --git a/packages/cli/templates/scaffolder-module/package.json.hbs b/packages/cli/templates/scaffolder-module/package.json.hbs index df4bf352f4..a6e6b5c5bc 100644 --- a/packages/cli/templates/scaffolder-module/package.json.hbs +++ b/packages/cli/templates/scaffolder-module/package.json.hbs @@ -32,7 +32,6 @@ "@backstage/plugin-scaffolder-node": "{{versionQuery '@backstage/plugin-scaffolder-node'}}" }, "devDependencies": { - "@backstage/backend-common": "{{versionQuery '@backstage/backend-common'}}", "@backstage/cli": "{{versionQuery '@backstage/cli'}}" }, "files": [ diff --git a/packages/cli/templates/scaffolder-module/src/actions/example/example.test.ts b/packages/cli/templates/scaffolder-module/src/actions/example/example.test.ts index 242f93c2f3..d0e5374f3f 100644 --- a/packages/cli/templates/scaffolder-module/src/actions/example/example.test.ts +++ b/packages/cli/templates/scaffolder-module/src/actions/example/example.test.ts @@ -1,6 +1,5 @@ import { PassThrough } from 'stream'; import { createAcmeExampleAction } from './example'; -import { getVoidLogger } from '@backstage/backend-common'; describe('acme:example', () => { afterEach(() => { @@ -10,15 +9,14 @@ describe('acme:example', () => { it('should call action', async () => { const action = createAcmeExampleAction(); - const logger = getVoidLogger(); - jest.spyOn(logger, 'info'); + const logger = { info: jest.fn() }; await action.handler({ input: { myParameter: 'test', }, workspacePath: '/tmp', - logger, + logger: logger as any, logStream: new PassThrough(), output: jest.fn(), createTemporaryDirectory() { diff --git a/plugins/auth-backend/src/identity/UserInfoDatabaseHandler.test.ts b/plugins/auth-backend/src/identity/UserInfoDatabaseHandler.test.ts index ef3d0f6c8b..4d696aa8f2 100644 --- a/plugins/auth-backend/src/identity/UserInfoDatabaseHandler.test.ts +++ b/plugins/auth-backend/src/identity/UserInfoDatabaseHandler.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { resolvePackagePath } from '@backstage/backend-common'; +import { resolvePackagePath } from '@backstage/backend-plugin-api'; import { TestDatabaseId, TestDatabases } from '@backstage/backend-test-utils'; import { Knex } from 'knex'; import { UserInfoDatabaseHandler } from './UserInfoDatabaseHandler';