infracensus-collector 1.6.1 → 1.6.2

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/dist/index.js CHANGED
@@ -1198,6 +1198,22 @@ function cleanCommandOutput(raw, command, prompt) {
1198
1198
  }
1199
1199
  return lines2.join("\n");
1200
1200
  }
1201
+ var ENABLE_DETAIL = {
1202
+ /** The session never settled — there was no prompt to elevate FROM. */
1203
+ noPrompt: "the session never returned a usable prompt",
1204
+ /**
1205
+ * It asked, we answered, it stayed in user mode: the secret is wrong.
1206
+ * `enablePassword` falls back to the LOGIN password when a credential
1207
+ * carries no enable field, so "nothing was supplied" and "the wrong thing
1208
+ * was" reach the device identically — and the fix differs, which is the
1209
+ * whole reason these are two sentences.
1210
+ */
1211
+ borrowedLoginPasswordRejected: "this credential carries no enable secret, so the login password was offered instead and the device refused it",
1212
+ /** It asked, we answered with this credential's own secret, it refused. */
1213
+ secretRejected: "the device rejected this credential's enable secret",
1214
+ /** It never asked at all — the account is not permitted to elevate. */
1215
+ neverAsked: "the device never asked to be unlocked and stayed in user mode \u2014 the account is probably not permitted to enable"
1216
+ };
1201
1217
  async function gatherViaShell(conn, commands, perCommandTimeoutMs, signal, enablePassword, onDebug, usedLoginPasswordAsSecret = false) {
1202
1218
  const stream = await openShell(conn);
1203
1219
  let buf = "";
@@ -1231,7 +1247,7 @@ async function gatherViaShell(conn, commands, perCommandTimeoutMs, signal, enabl
1231
1247
  stream.write("\r");
1232
1248
  let prompt = await readUntilPrompt(8e3);
1233
1249
  let elevated = prompt != null && prompt.endsWith("#");
1234
- if (prompt === null) enableDetail = "the session never returned a usable prompt";
1250
+ if (prompt === null) enableDetail = ENABLE_DETAIL.noPrompt;
1235
1251
  if (prompt && prompt.endsWith(">")) {
1236
1252
  buf = "";
1237
1253
  stream.write("enable\r");
@@ -1251,14 +1267,7 @@ async function gatherViaShell(conn, commands, perCommandTimeoutMs, signal, enabl
1251
1267
  }
1252
1268
  elevated = prompt != null && prompt.endsWith("#");
1253
1269
  if (!elevated) {
1254
- enableDetail = askedForSecret ? (
1255
- // It asked and we answered, and it stayed in user mode: the secret is
1256
- // wrong. `enablePassword` falls back to the LOGIN password when the
1257
- // credential carries no enable field, so "no enable secret was
1258
- // supplied" and "the wrong one was" reach the device identically —
1259
- // and the fix differs.
1260
- usedLoginPasswordAsSecret ? "the device asked for an enable secret and rejected the login password \u2014 this credential carries no enable secret of its own" : "the device rejected the enable secret on this credential"
1261
- ) : "the device never asked for an enable secret and stayed in user mode \u2014 the account is probably not permitted to enable";
1270
+ enableDetail = askedForSecret ? usedLoginPasswordAsSecret ? ENABLE_DETAIL.borrowedLoginPasswordRejected : ENABLE_DETAIL.secretRejected : ENABLE_DETAIL.neverAsked;
1262
1271
  onDebug?.(`enable did not elevate (${enableDetail})`);
1263
1272
  }
1264
1273
  }