@cdot65/prisma-airs-cli 5.7.0 → 5.7.1

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.
Files changed (2) hide show
  1. package/dist/cli/index.js +77 -56
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -8804,6 +8804,11 @@ var SdkDictionariesService = class {
8804
8804
  }
8805
8805
  };
8806
8806
 
8807
+ // src/cli/commands/dlp/config.ts
8808
+ async function loadDlpClientOptions() {
8809
+ return managementClientOptions(await loadConfig());
8810
+ }
8811
+
8807
8812
  // src/cli/commands/dlp/patch.ts
8808
8813
  import { readFile as readFile7 } from "fs/promises";
8809
8814
  function buildMergePatch(opts) {
@@ -8894,7 +8899,7 @@ function register(dlp) {
8894
8899
  try {
8895
8900
  const { page, size } = resolvePageParams(listCmd, opts);
8896
8901
  const includeKeywords = opts.keywords || opts.includeKeywords;
8897
- const svc = new SdkDictionariesService();
8902
+ const svc = new SdkDictionariesService(await loadDlpClientOptions());
8898
8903
  const params = {
8899
8904
  size,
8900
8905
  sort: opts.sort,
@@ -8909,17 +8914,18 @@ function register(dlp) {
8909
8914
  fail(err);
8910
8915
  }
8911
8916
  });
8912
- group.command("create").description("Create dictionary via multipart upload").option("--name <s>", "").option("--category <s>", "").option("--region <s>", "").option("--description <s>", "").option("--classification <s>", "").option("--file <path>", "Keyword file").option("--metadata-file <path>", "JSON metadata file (overrides --name/--category/...)").option("--include-keywords", "Include keywords in response").option("--output <fmt>", "Output format", "pretty").action(async (opts) => {
8917
+ group.command("create").description("Create dictionary via multipart upload").option("--name <s>", "").option("--category <s>", "").option("--region <s>", "").option("--description <s>", "").option("--classification <s>", "").option("--file <path>", "Keyword file").option("--metadata-file <path>", "JSON metadata file (overrides --name/--category/...)").option("--include-keywords", "Include keywords in response").option("--output <fmt>", "Output format", "pretty").action(async (opts, command) => {
8913
8918
  try {
8919
+ const format = await resolveOutput(command, opts);
8914
8920
  const metadata = await buildMetadata(opts);
8915
8921
  if (!opts.file) throw new Error("--file is required (multipart upload)");
8916
8922
  const file = await readFile8(opts.file);
8917
- const r = await new SdkDictionariesService().create({
8923
+ const r = await new SdkDictionariesService(await loadDlpClientOptions()).create({
8918
8924
  metadata,
8919
8925
  file,
8920
8926
  includeKeywords: opts.includeKeywords
8921
8927
  });
8922
- dlpDictionaries.renderCreated(r, opts.output);
8928
+ dlpDictionaries.renderCreated(r, format);
8923
8929
  } catch (err) {
8924
8930
  usageError(err instanceof Error ? err.message : String(err));
8925
8931
  }
@@ -8928,7 +8934,9 @@ function register(dlp) {
8928
8934
  try {
8929
8935
  const includeKeywords = opts.keywords || opts.includeKeywords;
8930
8936
  dlpDictionaries.renderGet(
8931
- await new SdkDictionariesService().get(id, { includeKeywords }),
8937
+ await new SdkDictionariesService(await loadDlpClientOptions()).get(id, {
8938
+ includeKeywords
8939
+ }),
8932
8940
  await resolveOutput(getCmd, opts)
8933
8941
  );
8934
8942
  } catch (err) {
@@ -8937,12 +8945,13 @@ function register(dlp) {
8937
8945
  });
8938
8946
  group.command("replace <id>").description(
8939
8947
  'Full-replace via multipart upload. --file required. May return 200 (body) or 204 (re-get; falls back to "(state not echoed)" on transient failure).'
8940
- ).option("--name <s>", "").option("--category <s>", "").option("--region <s>", "").option("--description <s>", "").option("--classification <s>", "").option("--file <path>", "Keyword file (required)").option("--metadata-file <path>", "JSON metadata file").option("--include-keywords", "").option("--output <fmt>", "Output format", "pretty").action(async (id, opts) => {
8948
+ ).option("--name <s>", "").option("--category <s>", "").option("--region <s>", "").option("--description <s>", "").option("--classification <s>", "").option("--file <path>", "Keyword file (required)").option("--metadata-file <path>", "JSON metadata file").option("--include-keywords", "").option("--output <fmt>", "Output format", "pretty").action(async (id, opts, command) => {
8941
8949
  try {
8942
8950
  const metadata = await buildMetadata(opts);
8951
+ const format = await resolveOutput(command, opts);
8943
8952
  if (!opts.file) throw new Error("--file is required (multipart upload)");
8944
8953
  const file = await readFile8(opts.file);
8945
- const r = await new SdkDictionariesService().replace(id, {
8954
+ const r = await new SdkDictionariesService(await loadDlpClientOptions()).replace(id, {
8946
8955
  metadata,
8947
8956
  file,
8948
8957
  includeKeywords: opts.includeKeywords
@@ -8950,22 +8959,23 @@ function register(dlp) {
8950
8959
  if ("kind" in r && r.kind === "fallback") {
8951
8960
  dlpDictionaries.renderReplaced204Fallback(id);
8952
8961
  } else {
8953
- dlpDictionaries.renderReplaced(r, opts.output);
8962
+ dlpDictionaries.renderReplaced(r, format);
8954
8963
  }
8955
8964
  } catch (err) {
8956
8965
  usageError(err instanceof Error ? err.message : String(err));
8957
8966
  }
8958
8967
  });
8959
- group.command("patch <id>").option("--body-file <path>", "").option("--set <k=v...>", "(repeatable)", (v, p = []) => [...p, v]).option("--clear <key...>", "(repeatable)", (v, p = []) => [...p, v]).option("--output <fmt>", "Output format", "pretty").action(async (id, opts) => {
8968
+ group.command("patch <id>").option("--body-file <path>", "").option("--set <k=v...>", "(repeatable)", (v, p = []) => [...p, v]).option("--clear <key...>", "(repeatable)", (v, p = []) => [...p, v]).option("--output <fmt>", "Output format", "pretty").action(async (id, opts, command) => {
8960
8969
  try {
8970
+ const format = await resolveOutput(command, opts);
8961
8971
  if (opts.bodyFile && (opts.set || opts.clear)) {
8962
8972
  throw new Error("--body-file is mutually exclusive with --set/--clear");
8963
8973
  }
8964
8974
  const body = opts.bodyFile ? await parseBody({ bodyFile: opts.bodyFile }) : buildMergePatch({ set: opts.set, clear: opts.clear });
8965
8975
  dlpDictionaries.renderPatched(
8966
8976
  // biome-ignore lint/suspicious/noExplicitAny: buildMergePatch returns Record<string, unknown>, cast for patch()
8967
- await new SdkDictionariesService().patch(id, body),
8968
- opts.output
8977
+ await new SdkDictionariesService(await loadDlpClientOptions()).patch(id, body),
8978
+ format
8969
8979
  );
8970
8980
  } catch (err) {
8971
8981
  usageError(err instanceof Error ? err.message : String(err));
@@ -8973,7 +8983,7 @@ function register(dlp) {
8973
8983
  });
8974
8984
  group.command("delete <id>").description("Delete a dictionary").action(async (id) => {
8975
8985
  try {
8976
- await new SdkDictionariesService().delete(id);
8986
+ await new SdkDictionariesService(await loadDlpClientOptions()).delete(id);
8977
8987
  dlpDictionaries.renderDeleted(id);
8978
8988
  } catch (err) {
8979
8989
  fail(err);
@@ -9146,7 +9156,7 @@ function register2(dlp) {
9146
9156
  listCmd.action(async (opts) => {
9147
9157
  try {
9148
9158
  const { page, size } = resolvePageParams(listCmd, opts);
9149
- const svc = new SdkDataFilteringProfilesService();
9159
+ const svc = new SdkDataFilteringProfilesService(await loadDlpClientOptions());
9150
9160
  const all = opts.all ? await svc.listAll({ size, sort: opts.sort, max: Number(opts.max) }) : void 0;
9151
9161
  const r = all ? { content: all, totalElements: all.length } : await svc.list({ page, size, sort: opts.sort });
9152
9162
  dlpFilteringProfiles.renderList(r, await resolveOutput(listCmd, opts));
@@ -9156,20 +9166,21 @@ function register2(dlp) {
9156
9166
  });
9157
9167
  const getCmd = group.command("get <id>").description("Get a filtering profile by id").option("--output <fmt>", "Output format: pretty, table, markdown, csv, json, yaml").action(async (id, opts) => {
9158
9168
  try {
9159
- const svc = new SdkDataFilteringProfilesService();
9169
+ const svc = new SdkDataFilteringProfilesService(await loadDlpClientOptions());
9160
9170
  dlpFilteringProfiles.renderGet(await svc.get(id), await resolveOutput(getCmd, opts));
9161
9171
  } catch (err) {
9162
9172
  fail(err);
9163
9173
  }
9164
9174
  });
9165
- group.command("replace <id>").description("Full-replace a filtering profile (PUT)").option("--file-based", "Apply to file-based scans (boolean)").option("--non-file-based", "Apply to non-file-based scans (boolean)").option("--description <s>", "Description").option("--direction <s>", "Direction: BOTH|UPLOAD|DOWNLOAD").option("--log-severity <s>", "Severity: CRITICAL|HIGH|MEDIUM|LOW|INFORMATIONAL").option("--scan-type <s>", "Scan type: include|exclude").option("--data-profile-id <n>", "Data profile ID", (v) => Number(v)).option("--euc-template-id <s>", "EUC template ID").option("--end-user-coaching", "Enable end-user coaching").option("--granular", "Granular profile").option("--file-type <s>", "File type (repeatable)", repeatable).option("--body <json|->", 'Raw JSON body (escape hatch; or "-" for stdin)').option("--body-file <path>", "Raw JSON body file (escape hatch)").option("--output <fmt>", "Output format", "pretty").action(async (id, opts) => {
9175
+ group.command("replace <id>").description("Full-replace a filtering profile (PUT)").option("--file-based", "Apply to file-based scans (boolean)").option("--non-file-based", "Apply to non-file-based scans (boolean)").option("--description <s>", "Description").option("--direction <s>", "Direction: BOTH|UPLOAD|DOWNLOAD").option("--log-severity <s>", "Severity: CRITICAL|HIGH|MEDIUM|LOW|INFORMATIONAL").option("--scan-type <s>", "Scan type: include|exclude").option("--data-profile-id <n>", "Data profile ID", (v) => Number(v)).option("--euc-template-id <s>", "EUC template ID").option("--end-user-coaching", "Enable end-user coaching").option("--granular", "Granular profile").option("--file-type <s>", "File type (repeatable)", repeatable).option("--body <json|->", 'Raw JSON body (escape hatch; or "-" for stdin)').option("--body-file <path>", "Raw JSON body file (escape hatch)").option("--output <fmt>", "Output format", "pretty").action(async (id, opts, command) => {
9166
9176
  try {
9167
9177
  const body = await resolveReplaceBody(opts);
9168
- const svc = new SdkDataFilteringProfilesService();
9178
+ const format = await resolveOutput(command, opts);
9179
+ const svc = new SdkDataFilteringProfilesService(await loadDlpClientOptions());
9169
9180
  dlpFilteringProfiles.renderReplaced(
9170
9181
  // biome-ignore lint/suspicious/noExplicitAny: body shape verified by SDK Zod
9171
9182
  await svc.replace(id, body),
9172
- opts.output
9183
+ format
9173
9184
  );
9174
9185
  } catch (err) {
9175
9186
  usageError(err instanceof Error ? err.message : String(err));
@@ -9314,7 +9325,7 @@ function register4(dlp) {
9314
9325
  listCmd.action(async (opts) => {
9315
9326
  try {
9316
9327
  const { page, size } = resolvePageParams(listCmd, opts);
9317
- const svc = new SdkDataPatternsService();
9328
+ const svc = new SdkDataPatternsService(await loadDlpClientOptions());
9318
9329
  const result = opts.all ? await svc.listAll({ size, sort: opts.sort, max: Number(opts.max) }) : void 0;
9319
9330
  dlpPatterns.renderList(
9320
9331
  result ? { content: result, totalElements: result.length } : await svc.list({ page, size, sort: opts.sort }),
@@ -9324,22 +9335,25 @@ function register4(dlp) {
9324
9335
  fail(err);
9325
9336
  }
9326
9337
  });
9327
- writeFlags(group.command("create").description("Create a data pattern")).action(async (opts) => {
9328
- try {
9329
- const body = await resolveWriteBody(opts);
9330
- dlpPatterns.renderCreated(
9331
- // biome-ignore lint/suspicious/noExplicitAny: body shape verified by SDK Zod
9332
- await new SdkDataPatternsService().create(body),
9333
- opts.output
9334
- );
9335
- } catch (err) {
9336
- usageError(err instanceof Error ? err.message : String(err));
9338
+ writeFlags(group.command("create").description("Create a data pattern")).action(
9339
+ async (opts, command) => {
9340
+ try {
9341
+ const format = await resolveOutput(command, opts);
9342
+ const body = await resolveWriteBody(opts);
9343
+ dlpPatterns.renderCreated(
9344
+ // biome-ignore lint/suspicious/noExplicitAny: body shape verified by SDK Zod
9345
+ await new SdkDataPatternsService(await loadDlpClientOptions()).create(body),
9346
+ format
9347
+ );
9348
+ } catch (err) {
9349
+ usageError(err instanceof Error ? err.message : String(err));
9350
+ }
9337
9351
  }
9338
- });
9352
+ );
9339
9353
  const getCmd = group.command("get <id>").description("Get a data pattern by id").option("--output <fmt>", "Output format: pretty, table, markdown, csv, json, yaml").action(async (id, opts) => {
9340
9354
  try {
9341
9355
  dlpPatterns.renderGet(
9342
- await new SdkDataPatternsService().get(id),
9356
+ await new SdkDataPatternsService(await loadDlpClientOptions()).get(id),
9343
9357
  await resolveOutput(getCmd, opts)
9344
9358
  );
9345
9359
  } catch (err) {
@@ -9347,13 +9361,14 @@ function register4(dlp) {
9347
9361
  }
9348
9362
  });
9349
9363
  writeFlags(group.command("replace <id>").description("Full-replace a data pattern (PUT)")).action(
9350
- async (id, opts) => {
9364
+ async (id, opts, command) => {
9351
9365
  try {
9366
+ const format = await resolveOutput(command, opts);
9352
9367
  const body = await resolveWriteBody(opts);
9353
9368
  dlpPatterns.renderReplaced(
9354
9369
  // biome-ignore lint/suspicious/noExplicitAny: body shape verified by SDK Zod
9355
- await new SdkDataPatternsService().replace(id, body),
9356
- opts.output
9370
+ await new SdkDataPatternsService(await loadDlpClientOptions()).replace(id, body),
9371
+ format
9357
9372
  );
9358
9373
  } catch (err) {
9359
9374
  usageError(err instanceof Error ? err.message : String(err));
@@ -9362,16 +9377,17 @@ function register4(dlp) {
9362
9377
  );
9363
9378
  group.command("patch <id>").description(
9364
9379
  `JSON Merge Patch. Use --body-file for nested fields. --set/--clear coerce values: numbers/booleans/JSON literals. To force a string, quote: --set count='"5"'.`
9365
- ).option("--body-file <path>", "JSON merge-patch body file").option("--set <k=v...>", "Set scalar field (repeatable)", repeatable).option("--clear <key...>", "Clear field via merge-patch null (repeatable)", repeatable).option("--output <fmt>", "Output format", "pretty").action(async (id, opts) => {
9380
+ ).option("--body-file <path>", "JSON merge-patch body file").option("--set <k=v...>", "Set scalar field (repeatable)", repeatable).option("--clear <key...>", "Clear field via merge-patch null (repeatable)", repeatable).option("--output <fmt>", "Output format", "pretty").action(async (id, opts, command) => {
9366
9381
  try {
9382
+ const format = await resolveOutput(command, opts);
9367
9383
  if (opts.bodyFile && (opts.set || opts.clear)) {
9368
9384
  throw new Error("--body-file is mutually exclusive with --set/--clear");
9369
9385
  }
9370
9386
  const body = opts.bodyFile ? await parseBody({ bodyFile: opts.bodyFile }) : buildMergePatch({ set: opts.set, clear: opts.clear });
9371
9387
  dlpPatterns.renderPatched(
9372
9388
  // biome-ignore lint/suspicious/noExplicitAny: buildMergePatch returns Record<string, unknown>, cast for patch()
9373
- await new SdkDataPatternsService().patch(id, body),
9374
- opts.output
9389
+ await new SdkDataPatternsService(await loadDlpClientOptions()).patch(id, body),
9390
+ format
9375
9391
  );
9376
9392
  } catch (err) {
9377
9393
  usageError(err instanceof Error ? err.message : String(err));
@@ -9379,7 +9395,7 @@ function register4(dlp) {
9379
9395
  });
9380
9396
  group.command("delete <id>").description("Soft-delete (archive) a data pattern").action(async (id) => {
9381
9397
  try {
9382
- await new SdkDataPatternsService().delete(id);
9398
+ await new SdkDataPatternsService(await loadDlpClientOptions()).delete(id);
9383
9399
  dlpPatterns.renderArchived(id);
9384
9400
  } catch (err) {
9385
9401
  fail(err);
@@ -9455,7 +9471,7 @@ function register5(dlp) {
9455
9471
  listCmd.action(async (opts) => {
9456
9472
  try {
9457
9473
  const { page, size } = resolvePageParams(listCmd, opts);
9458
- const svc = new SdkDataProfilesService();
9474
+ const svc = new SdkDataProfilesService(await loadDlpClientOptions());
9459
9475
  const result = opts.all ? await svc.listAll({ size, sort: opts.sort, max: Number(opts.max) }) : void 0;
9460
9476
  dlpProfiles.renderList(
9461
9477
  result ? { content: result, totalElements: result.length } : await svc.list({ page, size, sort: opts.sort }),
@@ -9465,22 +9481,25 @@ function register5(dlp) {
9465
9481
  fail(err);
9466
9482
  }
9467
9483
  });
9468
- writeFlags2(group.command("create").description("Create a data profile")).action(async (opts) => {
9469
- try {
9470
- const body = await resolveWriteBody2(opts);
9471
- dlpProfiles.renderCreated(
9472
- // biome-ignore lint/suspicious/noExplicitAny: body shape verified by SDK Zod
9473
- await new SdkDataProfilesService().create(body),
9474
- opts.output
9475
- );
9476
- } catch (err) {
9477
- usageError(err instanceof Error ? err.message : String(err));
9484
+ writeFlags2(group.command("create").description("Create a data profile")).action(
9485
+ async (opts, command) => {
9486
+ try {
9487
+ const format = await resolveOutput(command, opts);
9488
+ const body = await resolveWriteBody2(opts);
9489
+ dlpProfiles.renderCreated(
9490
+ // biome-ignore lint/suspicious/noExplicitAny: body shape verified by SDK Zod
9491
+ await new SdkDataProfilesService(await loadDlpClientOptions()).create(body),
9492
+ format
9493
+ );
9494
+ } catch (err) {
9495
+ usageError(err instanceof Error ? err.message : String(err));
9496
+ }
9478
9497
  }
9479
- });
9498
+ );
9480
9499
  const getCmd = group.command("get <id>").description("Get a data profile by id").option("--output <fmt>", "Output format: pretty, table, markdown, csv, json, yaml").action(async (id, opts) => {
9481
9500
  try {
9482
9501
  dlpProfiles.renderGet(
9483
- await new SdkDataProfilesService().get(id),
9502
+ await new SdkDataProfilesService(await loadDlpClientOptions()).get(id),
9484
9503
  await resolveOutput(getCmd, opts)
9485
9504
  );
9486
9505
  } catch (err) {
@@ -9488,13 +9507,14 @@ function register5(dlp) {
9488
9507
  }
9489
9508
  });
9490
9509
  writeFlags2(group.command("replace <id>").description("Full-replace a data profile (PUT)")).action(
9491
- async (id, opts) => {
9510
+ async (id, opts, command) => {
9492
9511
  try {
9512
+ const format = await resolveOutput(command, opts);
9493
9513
  const body = await resolveWriteBody2(opts);
9494
9514
  dlpProfiles.renderReplaced(
9495
9515
  // biome-ignore lint/suspicious/noExplicitAny: body shape verified by SDK Zod
9496
- await new SdkDataProfilesService().replace(id, body),
9497
- opts.output
9516
+ await new SdkDataProfilesService(await loadDlpClientOptions()).replace(id, body),
9517
+ format
9498
9518
  );
9499
9519
  } catch (err) {
9500
9520
  usageError(err instanceof Error ? err.message : String(err));
@@ -9503,16 +9523,17 @@ function register5(dlp) {
9503
9523
  );
9504
9524
  group.command("patch <id>").description(
9505
9525
  `JSON Merge Patch. body must include name + profile_type. Use --body-file for nested fields. --set/--clear coerce values: numbers/booleans/JSON literals. To force a string, quote: --set count='"5"'.`
9506
- ).option("--body-file <path>", "JSON merge-patch body file").option("--set <k=v...>", "Set scalar field (repeatable)", repeatable).option("--clear <key...>", "Clear field via merge-patch null (repeatable)", repeatable).option("--output <fmt>", "Output format", "pretty").action(async (id, opts) => {
9526
+ ).option("--body-file <path>", "JSON merge-patch body file").option("--set <k=v...>", "Set scalar field (repeatable)", repeatable).option("--clear <key...>", "Clear field via merge-patch null (repeatable)", repeatable).option("--output <fmt>", "Output format", "pretty").action(async (id, opts, command) => {
9507
9527
  try {
9528
+ const format = await resolveOutput(command, opts);
9508
9529
  if (opts.bodyFile && (opts.set || opts.clear)) {
9509
9530
  throw new Error("--body-file is mutually exclusive with --set/--clear");
9510
9531
  }
9511
9532
  const body = opts.bodyFile ? await parseBody({ bodyFile: opts.bodyFile }) : buildMergePatch({ set: opts.set, clear: opts.clear });
9512
9533
  dlpProfiles.renderPatched(
9513
9534
  // biome-ignore lint/suspicious/noExplicitAny: buildMergePatch returns Record<string, unknown>, cast for patch()
9514
- await new SdkDataProfilesService().patch(id, body),
9515
- opts.output
9535
+ await new SdkDataProfilesService(await loadDlpClientOptions()).patch(id, body),
9536
+ format
9516
9537
  );
9517
9538
  } catch (err) {
9518
9539
  usageError(err instanceof Error ? err.message : String(err));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cdot65/prisma-airs-cli",
3
3
  "packageManager": "pnpm@10.6.5",
4
- "version": "5.7.0",
4
+ "version": "5.7.1",
5
5
  "description": "CLI and library for Palo Alto Prisma AIRS — guardrail refinement, AI red teaming, model security scanning, profile audits",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",