unbound-cli 1.21.0 → 1.21.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.
package/README.md CHANGED
@@ -315,9 +315,9 @@ Listing needs Admin, Manager or Analytics Viewer. `mark-fp` needs Admin.
315
315
  |---------|-------------|
316
316
  | `unbound flags terminal` | Terminal runs that a tool policy flagged (block, approval, warn, audit) |
317
317
  | `unbound flags terminal mark-fp <id> --risk-score <n>` | Reject the run's risk score as a false positive |
318
- | `unbound flags data-security` | PII and secrets a guardrail found (values masked; `--reveal` shows them) |
318
+ | `unbound flags data-security` | PII and secrets a guardrail found (the detected values and prompts are never shown) |
319
319
  | `unbound flags data-security mark-fp <action-id>` | Mark a detection as a false positive |
320
- | `unbound trace <trace-id>` | The log, terminal runs and data security detections for one trace ID (prompts and values hidden; `--reveal` shows them) |
320
+ | `unbound trace <trace-id>` | The log, terminal runs and data security detections for one trace ID (prompts and detected values are never shown) |
321
321
  | `unbound false-positive list\|mark\|unmark <trace-id>` | Any user: show, mark or unmark a false positive on their own findings (alias `fp`; admins can act on any finding in their org) |
322
322
 
323
323
  ```bash
@@ -328,7 +328,7 @@ unbound flags data-security mark-fp 5521
328
328
  unbound trace 3f2a6c1e-8b7d-4e2f-9a1c-5d6e7f8a9b0c --json
329
329
  ```
330
330
 
331
- Terminal `mark-fp` records the same feedback as rejecting a risk score in the dashboard. It does not hide the run. Data security `mark-fp` moves the detection to `--findings false-positive`, and the gateway then skips that value for the organization.
331
+ Terminal `mark-fp` records the same feedback as rejecting a risk score in the dashboard. It does not hide the run. Data security `mark-fp` moves the detection to `--findings false-positive`, and the gateway then skips that value for the organization. The CLI never shows a detected value or the prompt it was found in; see them in the console.
332
332
 
333
333
  ## Configuration
334
334
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unbound-cli",
3
- "version": "1.21.0",
3
+ "version": "1.21.1",
4
4
  "description": "CLI tool for Unbound - AI Gateway management",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -113,19 +113,16 @@ async function listDataSecurity(opts) {
113
113
  const data = await api.get(`${DATA_SECURITY_PATH}?${buildQueryString(query)}`);
114
114
  const logs = (data.logs && data.logs.data) || [];
115
115
  if (opts.json) {
116
- const payload = opts.reveal ? data : { ...data, logs: { ...data.logs, data: logs.map(redactDataSecurityLog) } };
117
- output.json(payload);
116
+ output.json({ ...data, logs: { ...data.logs, data: logs.map(redactDataSecurityLog) } });
118
117
  return;
119
118
  }
120
119
  if (logs.length === 0) {
121
120
  output.info('No data security flags for this window and filter set.');
122
121
  return;
123
122
  }
124
- output.logTable(DATA_SECURITY_HEADERS, dataSecurityRows(logs, { reveal: Boolean(opts.reveal), wide: Boolean(opts.wide) }),
125
- { wide: Boolean(opts.wide) });
123
+ output.logTable(DATA_SECURITY_HEADERS, dataSecurityRows(logs), { wide: Boolean(opts.wide) });
126
124
  const totalPages = data.logs.total_pages;
127
125
  pageFooter(query.page, totalPages, data.logs.total_items, 'flagged requests', query.page < (totalPages || 0));
128
- if (!opts.reveal) output.info('Detected values are masked. Use --reveal to show them.');
129
126
  output.info('Mark one as a false positive: unbound flags data-security mark-fp <Action ID>');
130
127
  }
131
128
 
@@ -207,26 +204,28 @@ Admin only.
207
204
 
208
205
  const dataSecurity = flags
209
206
  .command('data-security')
210
- .description('List prompts where a data security guardrail found PII or a secret (Analytics > Data Security).')
207
+ .description('List requests where a data security guardrail found PII or a secret, without the values (Analytics > Data).')
211
208
  .option('--guardrail <names>', 'Guardrail names or IDs, comma-separated, e.g. PII,Secrets')
212
209
  .option('--action <actions>', `Action taken, comma-separated: ${DATA_SECURITY_ACTIONS.join(', ')}`)
213
210
  .option('--findings <which>', `${Object.keys(FINDINGS).join(' | ')} (default real)`)
214
211
  .option('--trace <trace-id>', 'Only the request with this gateway trace ID (default --findings all)')
215
- .option('--reveal', 'Show detected values and prompts in clear text')
216
212
  .option('--page <n>', 'Page number (10 requests per page)')
217
- .option('--json', 'Output the JSON response (values masked unless --reveal)')
213
+ .option('--json', 'Output the JSON response (without detected values or prompts)')
218
214
  .option('--wide', 'Print full values instead of clipping to terminal width');
219
215
  addWindowOptions(dataSecurity)
220
216
  .addHelpText('after', `
221
217
  Columns:
222
218
  Action ID The detection's ID. Pass it to \`mark-fp\`.
223
- Value The detected value, masked unless --reveal.
219
+ Type The kind of data found, e.g. EMAIL_ADDRESS or AWS key.
220
+
221
+ The detected values and the prompts are never shown here. See them in the
222
+ console under Analytics > Data.
224
223
  ${WINDOW_HELP}
225
224
  Examples:
226
225
  $ unbound flags data-security
227
226
  $ unbound flags data-security --guardrail Secrets --action block
228
227
  $ unbound flags data-security --findings false-positive
229
- $ unbound flags data-security --trace 3f2a6c1e-8b7d-4e2f-9a1c-5d6e7f8a9b0c --reveal
228
+ $ unbound flags data-security --trace 3f2a6c1e-8b7d-4e2f-9a1c-5d6e7f8a9b0c
230
229
 
231
230
  Admin, Manager or Analytics Viewer.
232
231
  `)
@@ -32,7 +32,7 @@ const SOURCES = [
32
32
  rows: (data, trace) => (data.prompts || []).filter((p) => sameTrace(p.traceId, trace)),
33
33
  more: (data, page) => page < (data.total_pages || 0),
34
34
  headers: LOG_HEADERS,
35
- toTable: (rows, opts) => logRows(rows, { reveal: Boolean(opts.reveal), wide: Boolean(opts.wide) }),
35
+ toTable: (rows) => logRows(rows),
36
36
  redact: (rows) => rows.map(redactLog),
37
37
  },
38
38
  {
@@ -52,7 +52,7 @@ const SOURCES = [
52
52
  rows: (data, trace) => ((data.logs && data.logs.data) || []).filter((l) => sameTrace(l.trace_id, trace)),
53
53
  more: (data, page) => page < ((data.logs && data.logs.total_pages) || 0),
54
54
  headers: DATA_SECURITY_HEADERS,
55
- toTable: (rows, opts) => dataSecurityRows(rows, { reveal: Boolean(opts.reveal), wide: Boolean(opts.wide) }),
55
+ toTable: (rows) => dataSecurityRows(rows),
56
56
  redact: (rows) => rows.map(redactDataSecurityLog),
57
57
  },
58
58
  ];
@@ -77,13 +77,13 @@ async function lookup(trace) {
77
77
  }));
78
78
  }
79
79
 
80
- function printJson(trace, results, opts) {
80
+ function printJson(trace, results) {
81
81
  const payload = { trace_id: trace };
82
82
  for (const { source, rows, error, incomplete } of results) {
83
83
  if (error) {
84
84
  payload[source.key] = { error };
85
85
  } else {
86
- payload[source.key] = { rows: source.redact && !opts.reveal ? source.redact(rows) : rows };
86
+ payload[source.key] = { rows: source.redact ? source.redact(rows) : rows };
87
87
  if (incomplete) payload[source.key].incomplete = true;
88
88
  }
89
89
  }
@@ -103,10 +103,8 @@ function printTables(trace, results, opts) {
103
103
  }
104
104
  if (incomplete) output.warn(`${source.title}: more than ${MAX_PAGES} pages matched. Only the first ${MAX_PAGES} are shown.`);
105
105
  }
106
- if (!opts.reveal) {
107
- console.log('');
108
- output.info('Prompts and detected values are hidden. Use --reveal to show them.');
109
- }
106
+ console.log('');
107
+ output.info('Prompts and detected values are not shown in the CLI. See them in the console.');
110
108
  }
111
109
 
112
110
  async function runTrace(value, opts) {
@@ -115,7 +113,7 @@ async function runTrace(value, opts) {
115
113
  const trace = resolveTraceId(value);
116
114
  const results = await lookup(trace);
117
115
  if (opts.json) {
118
- printJson(trace, results, opts);
116
+ printJson(trace, results);
119
117
  } else {
120
118
  printTables(trace, results, opts);
121
119
  }
@@ -132,17 +130,17 @@ function register(program) {
132
130
  .command('trace <trace-id>')
133
131
  .description('Find everything recorded for one gateway trace ID: the log, terminal runs and data security flags.')
134
132
  .option('--json', 'Output one JSON object with a key per source')
135
- .option('--reveal', 'Show prompts and detected data security values in clear text')
136
133
  .option('--wide', 'Print full values instead of clipping to terminal width')
137
134
  .addHelpText('after', `
138
135
  The trace ID is the UUID shown to a user under a blocked or warned action.
139
136
 
140
137
  Sources:
141
- Logs The request and its prompt (any age)
138
+ Logs The request (any age)
142
139
  Terminal Runs Tool calls on the request, flagged or not (last 3 months)
143
- Data Security PII or secret detections on the request (last 3 months)
140
+ Data Security PII or secret detections on the request, without the values (last 3 months)
144
141
 
145
- Prompts and detected values are hidden unless --reveal is given.
142
+ Prompts and detected data security values are never shown. See them in the
143
+ console.
146
144
 
147
145
  The exit code is 1 when a source cannot be read, for example because your
148
146
  role cannot see it, or when a source has more than ${MAX_PAGES} pages. The
package/src/index.js CHANGED
@@ -178,7 +178,7 @@ FLAGS AND FALSE POSITIVES (Admin/Analytics Viewer/Manager; mark-fp is Admin only
178
178
  $ unbound flags terminal Terminal runs a tool policy flagged
179
179
  $ unbound flags terminal mark-fp <id> --risk-score <n>
180
180
  Mark a flagged run as a false positive
181
- $ unbound flags data-security PII and secrets a guardrail found (values masked)
181
+ $ unbound flags data-security PII and secrets a guardrail found (values never shown)
182
182
  $ unbound flags data-security mark-fp <action-id>
183
183
  Mark a detection as a false positive
184
184
  $ unbound trace <trace-id> Log, terminal runs and data security for one trace ID
package/src/lib/flags.js CHANGED
@@ -98,24 +98,12 @@ function resolveGuardrailIds(raw, available) {
98
98
  });
99
99
  }
100
100
 
101
- /** Hide a detected secret or PII value; the backend returns it in clear. */
102
- function maskValue(value) {
103
- const text = String(value ?? '');
104
- if (!text) return '';
105
- if (text.length < 10) return '****';
106
- return `${text.slice(0, 2)}****${text.slice(-2)}`;
107
- }
108
-
109
- /** A data security log with every detected value masked and the raw prompt removed. */
101
+ /** A data security log without its detected values or prompt text; the CLI never prints either, masked or not. */
110
102
  function redactDataSecurityLog(log) {
111
- const { prompt, sensitive_contents: contents, ...rest } = log;
103
+ const { prompt, sensitive_contents: contents, prompt_mask_values: maskValues, ...rest } = log;
112
104
  return {
113
105
  ...rest,
114
- sensitive_contents: (contents || []).map(maskValue),
115
- sensitive_content_details: (log.sensitive_content_details || []).map((d) => ({
116
- ...d,
117
- sensitive_content: maskValue(d.sensitive_content),
118
- })),
106
+ sensitive_content_details: (log.sensitive_content_details || []).map(({ sensitive_content: value, ...d }) => d),
119
107
  };
120
108
  }
121
109
 
@@ -161,42 +149,41 @@ function terminalRows(rows, { wide = false } = {}) {
161
149
  ]);
162
150
  }
163
151
 
164
- const DATA_SECURITY_HEADERS = ['Action ID', 'Time (UTC)', 'User', 'AI Tool', 'Guardrail', 'Action', 'Value', 'False Positive', 'Trace ID'];
152
+ const DATA_SECURITY_HEADERS = ['Action ID', 'Time (UTC)', 'User', 'AI Tool', 'Guardrail', 'Type', 'Action', 'False Positive', 'Trace ID'];
165
153
 
166
- /** One row per detection, because mark-fp takes a detection's action ID. */
167
- function dataSecurityRows(logs, { reveal = false, wide = false } = {}) {
154
+ /** One row per detection, because mark-fp takes a detection's action ID; the detected value is never shown. */
155
+ function dataSecurityRows(logs) {
168
156
  const rows = [];
169
157
  for (const log of logs || []) {
170
158
  const base = [shortTime(log.timestamp), log.user_email || log.user_name || '', log.application_name || ''];
171
159
  const details = log.sensitive_content_details || [];
172
160
  if (details.length === 0) {
173
161
  // Detections with no stored value carry no action ID in the response.
174
- rows.push(['-', ...base, (log.guardrails || []).join(', '), (log.guardrail_actions || []).join(', '),
175
- '', log.has_false_positive ? 'yes' : '', log.trace_id || '']);
162
+ rows.push(['-', ...base, (log.guardrails || []).join(', '), '', (log.guardrail_actions || []).join(', '),
163
+ log.has_false_positive ? 'yes' : '', log.trace_id || '']);
176
164
  continue;
177
165
  }
178
166
  for (const d of details) {
179
- rows.push([String(d.action_id), ...base, d.guardrail_name || d.entity_type || '', d.action || '',
180
- reveal ? clipText(d.sensitive_content, 40, wide) : maskValue(d.sensitive_content),
167
+ rows.push([String(d.action_id), ...base, d.guardrail_name || '', d.entity_type || '', d.action || '',
181
168
  d.is_false_positive ? 'yes' : '', log.trace_id || '']);
182
169
  }
183
170
  }
184
171
  return rows;
185
172
  }
186
173
 
187
- // Prompt text on a log can hold the same secret a data security guardrail found.
174
+ // Prompt text on a log can hold a secret or PII the user pasted.
188
175
  const LOG_TEXT_FIELDS = ['userPrompt', 'systemPrompt', 'assistantPrompt', 'cleanedPrompt'];
189
176
 
190
- /** A log with its prompt text removed. */
177
+ /** A log with its prompt text removed; the CLI never prints prompts, which can hold a secret the user pasted. */
191
178
  function redactLog(log) {
192
179
  const copy = { ...log };
193
180
  for (const field of LOG_TEXT_FIELDS) delete copy[field];
194
181
  return copy;
195
182
  }
196
183
 
197
- const LOG_HEADERS = ['Log ID', 'Time (UTC)', 'User', 'AI Tool', 'Model', 'Status', 'User Prompt'];
184
+ const LOG_HEADERS = ['Log ID', 'Time (UTC)', 'User', 'AI Tool', 'Model', 'Status'];
198
185
 
199
- function logRows(prompts, { reveal = false, wide = false } = {}) {
186
+ function logRows(prompts) {
200
187
  return (prompts || []).map((p) => [
201
188
  p.urlKey || p.id || '',
202
189
  shortTime(p.requestInitializedAt),
@@ -204,7 +191,6 @@ function logRows(prompts, { reveal = false, wide = false } = {}) {
204
191
  p.toolType || '',
205
192
  (p.aiModel && p.aiModel.name) || '',
206
193
  p.statusCode ?? '',
207
- reveal ? clipText(p.userPrompt || '', 60, wide) : '(hidden)',
208
194
  ]);
209
195
  }
210
196
 
@@ -220,7 +206,6 @@ module.exports = {
220
206
  dataSecurityRows,
221
207
  feedbackLabel,
222
208
  logRows,
223
- maskValue,
224
209
  redactDataSecurityLog,
225
210
  redactLog,
226
211
  resolveGuardrailIds,
@@ -10,7 +10,6 @@ const {
10
10
  buildDataSecurityQuery,
11
11
  buildTerminalQuery,
12
12
  dataSecurityRows,
13
- maskValue,
14
13
  redactDataSecurityLog,
15
14
  resolveGuardrailIds,
16
15
  resolveTraceId,
@@ -56,12 +55,6 @@ test('guardrail names resolve to IDs case-insensitively, and an unknown name lis
56
55
  assert.throws(() => resolveGuardrailIds('nope', available), /Available: PII, Secrets/);
57
56
  });
58
57
 
59
- test('maskValue keeps only the ends of a long value', () => {
60
- assert.equal(maskValue('AKIAE2ETESTKEY0000001'), 'AK****01');
61
- assert.equal(maskValue('short'), '****');
62
- assert.equal(maskValue(''), '');
63
- });
64
-
65
58
  const LOG = {
66
59
  id: 7,
67
60
  trace_id: TRACE,
@@ -77,18 +70,37 @@ const LOG = {
77
70
  prompt: { user_prompt: 'my key is AKIAE2ETESTKEY0000001' },
78
71
  };
79
72
 
80
- test('redacted data security JSON carries no detected value and no prompt', () => {
81
- const text = JSON.stringify(redactDataSecurityLog(LOG));
82
- assert.ok(!text.includes('AKIAE2ETESTKEY0000001'), text);
83
- assert.ok(!('prompt' in redactDataSecurityLog(LOG)));
73
+ test('redacted data security JSON carries no detected value, masked or not, and no prompt', () => {
74
+ const redacted = redactDataSecurityLog({ ...LOG, prompt_mask_values: ['AKIAE2ETESTKEY0000001'] });
75
+ assert.ok(!JSON.stringify(redacted).includes('AKIA'), JSON.stringify(redacted));
76
+ for (const key of ['prompt', 'sensitive_contents', 'prompt_mask_values']) assert.ok(!(key in redacted), key);
77
+ assert.ok(!('sensitive_content' in redacted.sensitive_content_details[0]));
78
+ assert.equal(redacted.sensitive_content_details[0].action_id, 1);
84
79
  });
85
80
 
86
- test('data security rows list one line per detection, masked unless revealed', () => {
81
+ test('data security rows list one line per detection, with no value column', () => {
87
82
  const [row] = dataSecurityRows([LOG]);
88
83
  assert.equal(row[0], '1');
89
84
  assert.equal(row[1], '2026-09-24 19:17');
90
- assert.equal(row[6], 'AK****01');
91
- assert.equal(dataSecurityRows([LOG], { reveal: true })[0][6], 'AKIAE2ETESTKEY0000001');
85
+ assert.equal(row.length, 9);
86
+ assert.ok(!row.join(' ').includes('AKIA'), row.join(' '));
87
+ });
88
+
89
+ test('flags data-security prints no detected value in the table or JSON, and has no --reveal', async () => {
90
+ const { server, port } = await startServer((method, url) =>
91
+ (url.pathname === '/api/v1/analytics/guardrails/' ? [200, { logs: { data: [LOG], total_pages: 1 } }] : null));
92
+ try {
93
+ for (const args of [['flags', 'data-security'], ['flags', 'data-security', '--json']]) {
94
+ const r = await runCli(port, args);
95
+ assert.equal(r.code, 0, r.stderr);
96
+ assert.ok(!r.stdout.includes('AKIA'), r.stdout);
97
+ }
98
+ const reveal = await runCli(port, ['flags', 'data-security', '--reveal']);
99
+ assert.notEqual(reveal.code, 0);
100
+ assert.ok(!reveal.stdout.includes('AKIA'), reveal.stdout);
101
+ } finally {
102
+ server.close();
103
+ }
92
104
  });
93
105
 
94
106
  test('terminal rows show policies with their action and the feedback as a label', () => {
@@ -178,7 +190,7 @@ test('flags data-security mark-fp posts the detection ID', async () => {
178
190
  }
179
191
  });
180
192
 
181
- test('trace keeps only exact log matches, masks values, and exits 1 when a source fails', async () => {
193
+ test('trace keeps only exact log matches, never prints a data security value, and exits 1 when a source fails', async () => {
182
194
  const { server, port } = await startServer((method, url) => {
183
195
  if (url.pathname === '/api/v1/logs/prompts/') {
184
196
  return [200, { prompts: [
@@ -201,13 +213,18 @@ test('trace keeps only exact log matches, masks values, and exits 1 when a sourc
201
213
  assert.deepEqual(out.logs.rows.map((p) => p.id), ['1']);
202
214
  assert.equal(out.terminal_runs.error, 'Manager or admin access required');
203
215
  assert.equal(out.data_security.rows.length, 1);
204
- assert.ok(!r.stdout.includes('AKIAE2ETESTKEY0000001'), 'values must be masked without --reveal');
216
+ assert.ok(!r.stdout.includes('AKIA'), 'no value, masked or not, without --reveal');
217
+ // The log's prompt can hold the secret the guardrail found, so it is never printed either.
218
+ assert.ok(!('userPrompt' in out.logs.rows[0]));
219
+ const revealed = await runCli(port, ['trace', TRACE, '--json', '--reveal']);
220
+ assert.notEqual(revealed.code, 0);
221
+ assert.ok(!revealed.stdout.includes('AKIA'), revealed.stdout);
205
222
  } finally {
206
223
  server.close();
207
224
  }
208
225
  });
209
226
 
210
- test('trace reads every page of a source and hides log prompts in the table', async () => {
227
+ test('trace reads every page of a source and never prints log prompts', async () => {
211
228
  const { server, seen, port } = await startServer((method, url) => {
212
229
  const page = url.searchParams.get('page');
213
230
  if (url.pathname === '/api/v1/logs/prompts/') {
@@ -228,8 +245,8 @@ test('trace reads every page of a source and hides log prompts in the table', as
228
245
  ['1', '2']);
229
246
  const table = await runCli(port, ['trace', TRACE]);
230
247
  assert.ok(!table.stdout.includes('AKIAE2ETESTKEY0000001'), table.stdout);
231
- const revealed = await runCli(port, ['trace', TRACE, '--reveal', '--wide']);
232
- assert.ok(revealed.stdout.includes('AKIAE2ETESTKEY0000001'), revealed.stdout);
248
+ const wide = await runCli(port, ['trace', TRACE, '--wide']);
249
+ assert.ok(!wide.stdout.includes('AKIAE2ETESTKEY0000001'), wide.stdout);
233
250
  } finally {
234
251
  server.close();
235
252
  }