@pagopa/dx-cli 0.21.4 → 0.21.6

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.
@@ -285,7 +285,7 @@ describe("initialize", () => {
285
285
  principalType: "ServicePrincipal",
286
286
  roleDefinitionId: "/subscriptions/sub-1/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe",
287
287
  }));
288
- expect(mockCreateFederatedIdentityCredential).toHaveBeenCalledWith("dx-d-itn-common-rg-01", "dx-d-itn-bootstrap-id-01", "bootstrapper-dev-cd", {
288
+ expect(mockCreateFederatedIdentityCredential).toHaveBeenCalledWith("dx-d-itn-common-rg-01", "dx-d-itn-bootstrap-id-01", "dx-bootstrapper-dev-cd", {
289
289
  audiences: ["api://AzureADTokenExchange"],
290
290
  issuer: "https://token.actions.githubusercontent.com",
291
291
  subject: "repo:pagopa/dx:environment:bootstrapper-dev-cd",
@@ -341,4 +341,38 @@ describe("initialize", () => {
341
341
  secretValue: "private-key",
342
342
  });
343
343
  });
344
+ test("uses a repository-specific federated credential name", async ({ cloudAccountService, }) => {
345
+ const createOrUpdateEnvironmentSecret = vi
346
+ .fn()
347
+ .mockResolvedValue(undefined);
348
+ await cloudAccountService.initialize({
349
+ csp: "azure",
350
+ defaultLocation: "italynorth",
351
+ displayName: "Test subscription",
352
+ id: "sub-1",
353
+ }, {
354
+ name: "dev",
355
+ prefix: "dx",
356
+ }, {
357
+ clientId: "app-client-id",
358
+ id: "app-id",
359
+ installationId: "installation-id",
360
+ key: "private-key\n",
361
+ }, {
362
+ owner: "pagopa",
363
+ repo: "dx-playground",
364
+ }, {
365
+ createBranch: vi.fn(),
366
+ createOrUpdateEnvironmentSecret,
367
+ createPullRequest: vi.fn(),
368
+ getFileContent: vi.fn(),
369
+ getRepository: vi.fn(),
370
+ updateFile: vi.fn(),
371
+ });
372
+ expect(mockCreateFederatedIdentityCredential).toHaveBeenCalledWith("dx-d-itn-common-rg-01", "dx-d-itn-bootstrap-id-01", "dx-playground-bootstrapper-dev-cd", {
373
+ audiences: ["api://AzureADTokenExchange"],
374
+ issuer: "https://token.actions.githubusercontent.com",
375
+ subject: "repo:pagopa/dx-playground:environment:bootstrapper-dev-cd",
376
+ });
377
+ });
344
378
  });
@@ -199,14 +199,19 @@ export class AzureCloudAccountService {
199
199
  })));
200
200
  logger.debug("Assigned bootstrap roles to identity {identityName} in subscription {subscriptionId}", { identityName, subscriptionId: cloudAccount.id });
201
201
  const githubEnvironmentName = `bootstrapper-${name}-cd`;
202
- // Federate the bootstrap identity with the GitHub environment so workflows can exchange their OIDC token for Azure access.
203
- await msiClient.federatedIdentityCredentials.createOrUpdate(resourceGroupName, identityName, githubEnvironmentName, {
202
+ const federatedCredentialName = this.#createFederatedCredentialName({
203
+ github,
204
+ githubEnvironmentName,
205
+ });
206
+ // Include a repository-derived suffix so different repositories can share
207
+ // the same bootstrap identity without overwriting each other's OIDC trust.
208
+ await msiClient.federatedIdentityCredentials.createOrUpdate(resourceGroupName, identityName, federatedCredentialName, {
204
209
  audiences: ["api://AzureADTokenExchange"],
205
210
  issuer: "https://token.actions.githubusercontent.com",
206
211
  subject: `repo:${github.owner}/${github.repo}:environment:${githubEnvironmentName}`,
207
212
  });
208
213
  logger.debug("Configured federated identity credential {credentialName} for identity {identityName} in subscription {subscriptionId}", {
209
- credentialName: githubEnvironmentName,
214
+ credentialName: federatedCredentialName,
210
215
  identityName,
211
216
  subscriptionId: cloudAccount.id,
212
217
  });
@@ -374,6 +379,10 @@ export class AzureCloudAccountService {
374
379
  logger.debug("Created key vault {keyVaultName} in subscription {subscriptionId}", { keyVaultName, subscriptionId: cloudAccount.id });
375
380
  return keyVaultName;
376
381
  }
382
+ #createFederatedCredentialName({ github, githubEnvironmentName, }) {
383
+ const repoName = github.repo.replaceAll(/[^a-zA-Z0-9-]/g, "-");
384
+ return `${repoName}-${githubEnvironmentName}`;
385
+ }
377
386
  #createRoleAssignmentName(scope, principalId, roleDefinitionId) {
378
387
  const hash = createHash("sha256")
379
388
  .update(`${scope}:${principalId}:${roleDefinitionId}`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagopa/dx-cli",
3
- "version": "0.21.4",
3
+ "version": "0.21.6",
4
4
  "type": "module",
5
5
  "description": "A CLI useful to manage DX tools.",
6
6
  "repository": {
@@ -0,0 +1,17 @@
1
+ {
2
+ "extraKnownMarketplaces": {
3
+ "pagopa-dx": {
4
+ "source": {
5
+ "source": "github",
6
+ "repo": "pagopa/dx"
7
+ }
8
+ }
9
+ },
10
+ "enabledPlugins": {
11
+ "terraform@pagopa-dx": true,
12
+ "azure@pagopa-dx": true,
13
+ "project-management@pagopa-dx": true,
14
+ "standards@pagopa-dx": true,
15
+ "typescript@pagopa-dx": true
16
+ }
17
+ }
@@ -59,6 +59,16 @@ pnpm install
59
59
  pnpm nx run-many -t build
60
60
  ```
61
61
 
62
+ ### GitHub Copilot plugins
63
+
64
+ This repository includes `.github/copilot/settings.json` with the
65
+ recommended PagoPA DX marketplace and plugin suggestions for GitHub Copilot.
66
+
67
+ Keep the file committed to avoid per-developer setup drift. If your team does
68
+ not use some of the suggested plugins, edit the related flags in that file.
69
+ See the DX documentation for details:
70
+ https://dx.pagopa.it/docs/coding-with-ai/plugin-marketplace
71
+
62
72
  ## Useful commands
63
73
 
64
74
  This project uses `pnpm` and `nx` with workspaces to manage projects and dependencies. Here is a list of useful commands to work in this repo.