ferret-scan 1.0.4 → 1.0.6
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/scanner/Scanner.js +13 -7
- package/package.json +1 -1
package/dist/scanner/Scanner.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Scanner - Core orchestrator for Ferret security scanning
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { readFile } from 'node:fs/promises';
|
|
5
5
|
import { SEVERITY_ORDER, SEVERITY_WEIGHTS } from '../types.js';
|
|
6
6
|
import { discoverFiles } from './FileDiscovery.js';
|
|
7
7
|
import { matchRules } from './PatternMatcher.js';
|
|
@@ -110,9 +110,9 @@ function sortFindings(findings) {
|
|
|
110
110
|
/**
|
|
111
111
|
* Scan a single file
|
|
112
112
|
*/
|
|
113
|
-
function scanFile(file, config) {
|
|
113
|
+
async function scanFile(file, config) {
|
|
114
114
|
try {
|
|
115
|
-
const content =
|
|
115
|
+
const content = await readFile(file.path, 'utf-8');
|
|
116
116
|
const rules = getRulesForScan(config.categories, config.severities);
|
|
117
117
|
const allFindings = [];
|
|
118
118
|
// Regular pattern matching
|
|
@@ -172,7 +172,7 @@ function scanFile(file, config) {
|
|
|
172
172
|
* Yield to event loop to allow spinner updates
|
|
173
173
|
*/
|
|
174
174
|
function yieldToEventLoop() {
|
|
175
|
-
return new Promise(resolve => setTimeout(resolve,
|
|
175
|
+
return new Promise(resolve => setTimeout(resolve, 50));
|
|
176
176
|
}
|
|
177
177
|
/**
|
|
178
178
|
* Main scan function
|
|
@@ -210,17 +210,23 @@ export async function scan(config) {
|
|
|
210
210
|
const totalFiles = discovery.files.length;
|
|
211
211
|
let scannedCount = 0;
|
|
212
212
|
let findingsCount = 0;
|
|
213
|
+
let lastYield = Date.now();
|
|
213
214
|
if (showProgress && totalFiles > 0) {
|
|
214
215
|
spinner = ora(`Scanning files... 0/${totalFiles}`).start();
|
|
215
216
|
}
|
|
216
217
|
for (const file of discovery.files) {
|
|
217
218
|
logger.debug(`Scanning: ${file.relativePath}`);
|
|
218
|
-
// Update spinner and yield to let it
|
|
219
|
+
// Update spinner text and yield periodically to let it animate
|
|
219
220
|
if (spinner) {
|
|
220
221
|
spinner.text = `Scanning ${scannedCount + 1}/${totalFiles}: ${file.relativePath.slice(-50)}${findingsCount > 0 ? ` (${findingsCount} findings)` : ''}`;
|
|
221
|
-
|
|
222
|
+
// Yield every 100ms to allow spinner animation
|
|
223
|
+
const now = Date.now();
|
|
224
|
+
if (now - lastYield >= 100) {
|
|
225
|
+
await yieldToEventLoop();
|
|
226
|
+
lastYield = Date.now();
|
|
227
|
+
}
|
|
222
228
|
}
|
|
223
|
-
const result = scanFile(file, config);
|
|
229
|
+
const result = await scanFile(file, config);
|
|
224
230
|
if (result.error) {
|
|
225
231
|
errors.push({
|
|
226
232
|
file: file.path,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ferret-scan",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Security scanner for AI CLI configurations - detect prompt injections, credential leaks, and malicious patterns in AI agent configs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|