ccperm 1.11.1 → 1.11.3
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/interactive.js +21 -6
- package/package.json +1 -1
package/dist/interactive.js
CHANGED
|
@@ -7,6 +7,15 @@ exports.startInteractive = startInteractive;
|
|
|
7
7
|
const node_readline_1 = __importDefault(require("node:readline"));
|
|
8
8
|
const colors_js_1 = require("./colors.js");
|
|
9
9
|
const explain_js_1 = require("./explain.js");
|
|
10
|
+
function severityTag(s) {
|
|
11
|
+
const labels = {
|
|
12
|
+
critical: `${colors_js_1.RED}CRITICAL${colors_js_1.NC}`,
|
|
13
|
+
high: `${colors_js_1.YELLOW}HIGH${colors_js_1.NC} `,
|
|
14
|
+
medium: `${colors_js_1.DIM}MEDIUM${colors_js_1.NC} `,
|
|
15
|
+
low: `${colors_js_1.DIM}LOW${colors_js_1.NC} `,
|
|
16
|
+
};
|
|
17
|
+
return labels[s];
|
|
18
|
+
}
|
|
10
19
|
// Clean up messy bash permission labels for display
|
|
11
20
|
function cleanLabel(label) {
|
|
12
21
|
let s = label;
|
|
@@ -130,13 +139,17 @@ function startInteractive(merged, results) {
|
|
|
130
139
|
function renderList(state, withPerms, emptyCount) {
|
|
131
140
|
const rows = process.stdout.rows || 24;
|
|
132
141
|
const cols = process.stdout.columns || 80;
|
|
133
|
-
const w = Math.min(cols, 82);
|
|
134
|
-
const inner = w - 4; // box border + 1 space each side
|
|
135
142
|
const cats = ['Bash', 'WebFetch', 'MCP', 'Tools'];
|
|
136
143
|
const catsPresent = cats.filter((c) => withPerms.some((r) => r.groups.has(c)));
|
|
137
144
|
const catColWidth = catsPresent.length * 7;
|
|
145
|
+
const typeColWidth = 7; // " local " or " shared"
|
|
138
146
|
const maxName = Math.max(...withPerms.map((r) => r.shortName.length), 7);
|
|
139
|
-
const
|
|
147
|
+
const nameColWidth = Math.min(maxName + typeColWidth, 35); // name + type combined
|
|
148
|
+
const nameWidth = nameColWidth - typeColWidth;
|
|
149
|
+
// content: marker(2) + nameCol(nameColWidth) + gap(2) + catCols + gap(2) + total(5)
|
|
150
|
+
const contentWidth = 2 + nameColWidth + 2 + catColWidth + 2 + 5;
|
|
151
|
+
const w = Math.min(cols, contentWidth + 4); // +4 for box borders + padding
|
|
152
|
+
const inner = w - 4;
|
|
140
153
|
const hasGlobalSep = withPerms.some((r) => r.isGlobal) && withPerms.some((r) => !r.isGlobal);
|
|
141
154
|
// box takes: top(1) + header(2) + sep(1) + content + globalSep?(1) + emptyLine?(1) + bottom(1)
|
|
142
155
|
const chrome = 5 + (hasGlobalSep ? 1 : 0) + (emptyCount > 0 ? 1 : 0);
|
|
@@ -148,7 +161,7 @@ function renderList(state, withPerms, emptyCount) {
|
|
|
148
161
|
const scrollInfo = withPerms.length > visibleRows ? `${state.cursor + 1}/${withPerms.length}` : '';
|
|
149
162
|
const lines = [];
|
|
150
163
|
lines.push(boxTop('ccperm', scrollInfo, w));
|
|
151
|
-
lines.push(boxLine(`${colors_js_1.DIM}${pad('PROJECT',
|
|
164
|
+
lines.push(boxLine(`${colors_js_1.DIM}${pad('PROJECT', nameColWidth)} ${catsPresent.map((c) => rpad(c, 5)).join(' ')} TOTAL${colors_js_1.NC}`, w));
|
|
152
165
|
lines.push(boxSep(w));
|
|
153
166
|
const globalCount = withPerms.filter((r) => r.isGlobal).length;
|
|
154
167
|
const end = Math.min(state.scrollOffset + visibleRows, withPerms.length);
|
|
@@ -201,10 +214,12 @@ function renderDetail(state, withPerms, results) {
|
|
|
201
214
|
const clean = cleanLabel(item.name);
|
|
202
215
|
if (state.showInfo) {
|
|
203
216
|
const info = (0, explain_js_1.explain)(group.category, item.name);
|
|
204
|
-
const
|
|
217
|
+
const tag = severityTag(info.risk);
|
|
218
|
+
const tagLen = info.risk.length + 2; // tag visual width (e.g. "CRITICAL" + 2 spaces)
|
|
219
|
+
const nameMax = Math.min(30, w - tagLen - 14);
|
|
205
220
|
const name = clean.length > nameMax ? clean.slice(0, nameMax - 1) + '…' : clean;
|
|
206
221
|
const desc = info.description ? `${colors_js_1.DIM}${info.description}${colors_js_1.NC}` : '';
|
|
207
|
-
navRows.push({ text: ` ${pad(name, nameMax)}
|
|
222
|
+
navRows.push({ text: ` ${pad(name, nameMax)} ${tag} ${desc}`, perm: item.name });
|
|
208
223
|
}
|
|
209
224
|
else {
|
|
210
225
|
const maxLen = w - 8;
|