From 9f0874dc9bea105b635aa99fde9959b5f6ba4881 Mon Sep 17 00:00:00 2001 From: Agustin Groh <77737320+agustingroh@users.noreply.github.com> Date: Tue, 21 May 2024 10:22:19 -0300 Subject: [PATCH] SP-717 Adds scan filter criteria on local crypto scannning * SP-717 Adds scan filter criteria on local crypto scannning --------- Co-authored-by: Franco Stramana --- src/cli/commands/crypto.ts | 5 ++++- src/sdk/tree/Filters/FilterAND.ts | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/sdk/tree/Filters/FilterAND.ts diff --git a/src/cli/commands/crypto.ts b/src/cli/commands/crypto.ts index ae41c8e..479460a 100644 --- a/src/cli/commands/crypto.ts +++ b/src/cli/commands/crypto.ts @@ -11,6 +11,9 @@ import { DependencyFilter } from '../../sdk/tree/Filters/DependencyFilter'; import { CryptoCfg } from '../../sdk/Cryptography/CryptoCfg'; import fs from 'fs'; import { BinaryFilter } from '../../sdk/tree/Filters/BinaryFilter'; +import { ScanFilter } from '../../sdk/tree/Filters/ScanFilter'; +import { FilterAND } from '../../sdk/tree/Filters/FilterAND'; +import { isBinaryFileSync } from 'isbinaryfile'; export async function cryptoHandler(rootPath: string, options: any): Promise { rootPath = rootPath.replace(/\/$/, ''); // Remove trailing slash if exists @@ -31,7 +34,7 @@ export async function cryptoHandler(rootPath: string, options: any): Promise; + + constructor(filters: Array) { + super(); + this.filters = filters; + } + + public evaluate(node: Node): boolean { + let valid = false; + for(let i = 0; i < this.filters.length; i++) { + valid = this.filters[i].evaluate(node); + if(!valid) return false; + } + return valid; + } + +}