ccsniff 1.1.13 → 1.1.15
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/package.json +1 -1
- package/src/cli.js +13 -5
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -400,11 +400,15 @@ if (opts['search-discipline']) {
|
|
|
400
400
|
}
|
|
401
401
|
} else if (name === 'Bash') {
|
|
402
402
|
const cmd = ev.block?.input?.command || '';
|
|
403
|
-
|
|
403
|
+
// A search tool fed by a pipe (`<cmd> | grep ...`) is filtering another command's stdout,
|
|
404
|
+
// not searching the codebase tree — codesearch has no equivalent for that and it is not the
|
|
405
|
+
// bypass the rule targets. Flag only a search tool that STARTS a pipeline segment (reads the
|
|
406
|
+
// tree directly), never one immediately downstream of a pipe.
|
|
407
|
+
const isTreeSearchLine = (line) => BASH_SEARCH.test(line.split('|')[0]);
|
|
408
|
+
const hitLine = cmd.split('\n').find(isTreeSearchLine);
|
|
409
|
+
if (hitLine) {
|
|
404
410
|
kind = 'native-search-bash';
|
|
405
|
-
|
|
406
|
-
const hit = cmd.split('\n').find(l => BASH_SEARCH.test(l)) || cmd;
|
|
407
|
-
detail = hit.trim().slice(0, 120);
|
|
411
|
+
detail = (hitLine.split('|')[0]).trim().slice(0, 120);
|
|
408
412
|
}
|
|
409
413
|
}
|
|
410
414
|
if (kind) violations.push({ ts, sid, project, kind, detail });
|
|
@@ -436,6 +440,9 @@ if (opts['glyph-discipline']) {
|
|
|
436
440
|
const includeSubagents = opts['include-subagents'];
|
|
437
441
|
const GLYPH = /[←-⇿⌀-⏿■-◿☀-➿⬀-⯿]|[\u{1F000}-\u{1FAFF}]/u;
|
|
438
442
|
const GLYPH_G = /[←-⇿⌀-⏿■-◿☀-➿⬀-⯿]|[\u{1F000}-\u{1FAFF}]/gu;
|
|
443
|
+
// Glyphs inside a regex char-class (e.g. /[←-⇿]/) are a detector/range DEFINITION, not decorative
|
|
444
|
+
// prose — blank those bracket bodies before testing so a glyph-rule definition does not flag itself.
|
|
445
|
+
const stripGlyphCharClass = (s) => s.replace(/\[[^\]\n]*\]/g, (m) => GLYPH.test(m) ? '[]' : m);
|
|
439
446
|
const violations = [];
|
|
440
447
|
for (const ev of all) {
|
|
441
448
|
if (!filter(ev)) continue;
|
|
@@ -445,7 +452,8 @@ if (opts['glyph-discipline']) {
|
|
|
445
452
|
if (name !== 'Write' && name !== 'Edit' && name !== 'NotebookEdit') continue;
|
|
446
453
|
const inp = ev.block?.input || {};
|
|
447
454
|
const filePath = inp.file_path || inp.notebook_path || '';
|
|
448
|
-
const
|
|
455
|
+
const rawContent = [inp.content, inp.new_string, inp.new_source].filter(s => typeof s === 'string').join('\n');
|
|
456
|
+
const content = stripGlyphCharClass(rawContent);
|
|
449
457
|
if (!content || !GLYPH.test(content)) continue;
|
|
450
458
|
const glyphs = [...new Set((content.match(GLYPH_G) || []))].slice(0, 10).join(' ');
|
|
451
459
|
violations.push({ ts: ev.timestamp, sid: ev.conversation?.id || '', project: path.basename(ev.conversation?.cwd || ''), kind: 'glyph-written', file: path.basename(filePath), glyphs });
|