From 143ebdb1ea2c6b06a2aa741b83bce1b037f24b43 Mon Sep 17 00:00:00 2001 From: Nasirudeen Olohundare Date: Mon, 10 Feb 2025 12:01:17 +0100 Subject: [PATCH] feat: exported customDetector validation function --- package.json | 2 +- src/regexHandler.ts | 2 +- src/shared/index.ts | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 0a44759..ffdc15d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "securelog-scan", - "version": "3.0.22", + "version": "3.0.23", "description": "A CLI tool to scan codebases for potential secrets.", "main": "dist/index.js", "author": { diff --git a/src/regexHandler.ts b/src/regexHandler.ts index 7bf9e80..3f97c0c 100644 --- a/src/regexHandler.ts +++ b/src/regexHandler.ts @@ -32,7 +32,7 @@ export const isWhitelisted = (input: string): boolean => { * Validates a custom detector configuration and throws detailed errors if invalid. * @param config - The custom detector configuration to validate. */ -const validateDetectorConfig = (config: DetectorConfig): void => { +export const validateDetectorConfig = (config: DetectorConfig): void => { const { regex, keywords, detectorType, group } = config; const errors: string[] = []; diff --git a/src/shared/index.ts b/src/shared/index.ts index 75f4b12..7f2b8d3 100644 --- a/src/shared/index.ts +++ b/src/shared/index.ts @@ -6,7 +6,7 @@ import axios from "axios"; import { AhoCorasickCore } from "../ahocorasick"; import { decay } from "../decay"; -import { buildCustomDetectors } from "../regexHandler"; +import { buildCustomDetectors, validateDetectorConfig } from "../regexHandler"; import { DataFormat, ScanStringOptions } from "../types"; import { DetectorConfig } from "../types/detector"; import { maskString } from "../util"; @@ -203,3 +203,5 @@ export class DataFormatHandlers { this.formats.set(name, handler); } } + +export const validateCustomDetectorConfig = validateDetectorConfig;