mirror of
https://github.com/prompt-security/clawsec.git
synced 2026-06-18 07:51:20 +03:00
Fix regex in extractSkillName function and simplify error handling in suppression config tests
This commit is contained in:
@@ -47,7 +47,7 @@ function extractSkillName(finding) {
|
||||
|
||||
// Attempt to extract from path (e.g., "skills/my-skill/...")
|
||||
if (finding.path && typeof finding.path === "string") {
|
||||
const pathMatch = finding.path.match(/skills\/([^\/]+)/);
|
||||
const pathMatch = finding.path.match(/skills\/([^/]+)/);
|
||||
if (pathMatch) return pathMatch[1];
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,8 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import os from "node:os";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { loadSuppressionConfig } from "../scripts/load_suppression_config.mjs";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
let passCount = 0;
|
||||
let failCount = 0;
|
||||
|
||||
@@ -46,7 +43,7 @@ async function withTempFile(content) {
|
||||
cleanup: async () => {
|
||||
try {
|
||||
await fs.rm(tmpDir, { recursive: true, force: true });
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// Ignore cleanup errors
|
||||
}
|
||||
},
|
||||
@@ -256,14 +253,13 @@ async function testFileNotFoundGracefulFallback() {
|
||||
try {
|
||||
await withEnv("OPENCLAW_AUDIT_CONFIG", undefined, async () => {
|
||||
const nonExistentPath1 = path.join(os.homedir(), ".openclaw", "non-existent-12345.json");
|
||||
const nonExistentPath2 = ".clawsec/non-existent-12345.json";
|
||||
|
||||
// Ensure neither path exists
|
||||
// Ensure path does not exist
|
||||
try {
|
||||
await fs.access(nonExistentPath1);
|
||||
fail(testName, "Test precondition failed: primary path should not exist");
|
||||
return;
|
||||
} catch (err) {
|
||||
} catch {
|
||||
// Expected - file should not exist
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user