@cdot65/prisma-airs-cli 5.8.4 → 5.8.5

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 +18 -9
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -9719,11 +9719,19 @@ async function backupDlpResources(api, tsgId, options = {}) {
9719
9719
  if (!record.id) throw new Error("Inventory dictionary has no id");
9720
9720
  if (record.type !== "predefined" && !Array.isArray(record.keywords))
9721
9721
  throw new Error(`Dictionary keywords were not returned by the region: ${record.name}`);
9722
- dictionaries.set(record.id, structuredClone(record));
9722
+ const stored = record.type === "predefined" ? { id: record.id, name: record.name, type: record.type } : record;
9723
+ dictionaries.set(record.id, structuredClone(stored));
9723
9724
  };
9724
9725
  const addPattern = (record) => {
9725
9726
  if (!record.id) throw new Error("Inventory data pattern has no id");
9726
- patterns.set(record.id, structuredClone(record));
9727
+ const stored = record.type === "predefined" ? {
9728
+ id: record.id,
9729
+ name: record.name,
9730
+ type: record.type,
9731
+ ...record.version != null ? { version: record.version } : {},
9732
+ ...record.detection_config?.technique ? { detection_config: { technique: record.detection_config.technique } } : {}
9733
+ } : record;
9734
+ patterns.set(record.id, structuredClone(stored));
9727
9735
  };
9728
9736
  if (kinds.includes("dictionaries")) {
9729
9737
  for (const record of inventory2.dictionaries)
@@ -9885,14 +9893,15 @@ function normalizedName(value) {
9885
9893
  }
9886
9894
  function predefinedCandidates(source, records) {
9887
9895
  const wanted = normalizedName(source.name ?? "");
9888
- const wantedTokens = new Set(wanted.split(" "));
9889
- return records.filter(
9890
- (record) => record.type === "predefined" && record.name != null && !RETIRED_PATTERN.has(record.status ?? "active") && record.detection_config?.technique === source.detection_config?.technique
9891
- ).map((record) => {
9896
+ const scored = /* @__PURE__ */ new Map();
9897
+ for (const record of records) {
9898
+ if (record.type !== "predefined" || record.name == null || RETIRED_PATTERN.has(record.status ?? "active") || record.detection_config?.technique !== source.detection_config?.technique)
9899
+ continue;
9892
9900
  const name = normalizedName(record.name);
9893
- const score = name === wanted ? 3 : name.includes(wanted) || wanted.includes(name) ? 2 : name.split(" ").some((token) => wantedTokens.has(token)) ? 1 : 0;
9894
- return { name: record.name, score };
9895
- }).filter((item) => item.score > 0).sort((a, b) => b.score - a.score || a.name.localeCompare(b.name)).slice(0, 3).map((item) => item.name);
9901
+ const score = name === wanted ? 2 : name.includes(wanted) || wanted.includes(name) ? 1 : 0;
9902
+ if (score > 0) scored.set(record.name, Math.max(scored.get(record.name) ?? 0, score));
9903
+ }
9904
+ return [...scored.entries()].sort(([aName, aScore], [bName, bScore]) => bScore - aScore || aName.localeCompare(bName)).slice(0, 3).map(([name]) => name);
9896
9905
  }
9897
9906
  function matchByName(records, name, retired, label) {
9898
9907
  const matches = records.filter((record) => record.name === name && !retired(record));
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.8.4",
4
+ "version": "5.8.5",
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",