@@ -2,6 +2,7 @@ import { CxWrapper } from '../main/wrapper/CxWrapper';
22import { CxCommandOutput } from "../main/wrapper/CxCommandOutput" ;
33import { CxParamType } from "../main/wrapper/CxParamType" ;
44import { BaseTest } from "./BaseTest" ;
5+ import { OssPackage } from "./data/ossTypes" ;
56
67describe ( "ScanCreate cases" , ( ) => {
78 const cxScanConfig = new BaseTest ( ) ;
@@ -173,21 +174,58 @@ describe("ScanCreate cases", () => {
173174 expect ( Number . isInteger ( scanObject . scanDetails [ 0 ] . line ) ) . toBe ( true ) ;
174175 expect ( typeof scanObject . scanDetails [ 0 ] . description ) . toBe ( 'string' ) ;
175176 } ) ;
176-
177+
177178 it ( 'ScanOss Successful case' , async ( ) => {
178179 const wrapper = new CxWrapper ( cxScanConfig ) ;
179- const cxCommandOutput : CxCommandOutput = await wrapper . ossScanResults ( "tsc/tests/data/package.json" ) ;
180+ const cxCommandOutput : CxCommandOutput = await wrapper . ossScanResults ( "tsc/tests/data/package.json" , "" ) ;
180181 console . log ( "Json object from scanOSS successful case: " + JSON . stringify ( cxCommandOutput ) ) ;
181182 expect ( cxCommandOutput . payload ) . toBeDefined ( ) ;
182183 expect ( cxCommandOutput . exitCode ) . toBe ( 0 ) ;
183184 } ) ;
184185
185- it . skip ( 'ScanSecrets Successful case' , async ( ) => {
186+ it . skip ( 'ScanOss with ignored package should filter results' , async ( ) => {
187+ const wrapper = new CxWrapper ( cxScanConfig ) ;
188+ const sourceFile = "tsc/tests/data/package.json" ;
189+ const ignoredFile = "tsc/tests/data/checkmarxIgnoredTempFile.json" ;
190+
191+ const cxCommandOutput : CxCommandOutput = await wrapper . ossScanResults ( sourceFile , ignoredFile ) ;
192+
193+ expect ( cxCommandOutput . exitCode ) . toBe ( 0 ) ;
194+ expect ( cxCommandOutput . payload ) . toBeDefined ( ) ;
195+
196+ const results = cxCommandOutput . payload as OssPackage [ ] ;
197+
198+ console . log ( "Filtered OSS packages:" , results ) ;
199+
200+ expect ( results . length ) . toBe ( 1 ) ;
201+
202+ const hasCOA = results . some ( pkg =>
203+ pkg . PackageManager === "coa" && pkg . PackageVersion === "3.1.3"
204+ ) ;
205+ expect ( hasCOA ) . toBe ( false ) ;
206+ } ) ;
207+
208+ it ( 'ScanSecrets Successful case' , async ( ) => {
186209 const wrapper = new CxWrapper ( cxScanConfig ) ;
187- const cxCommandOutput : CxCommandOutput = await wrapper . secretsScanResults ( "src/tests/data/secret-exposed.txt" ) ;
210+ const cxCommandOutput : CxCommandOutput = await wrapper . secretsScanResults ( "src/tests/data/secret-exposed.txt" , "" ) ;
188211 console . log ( "Json object from scanOSS successful case: " + JSON . stringify ( cxCommandOutput ) ) ;
189212 expect ( cxCommandOutput . payload ) . toBeDefined ( ) ;
190213 expect ( cxCommandOutput . exitCode ) . toBe ( 0 ) ;
191214 } ) ;
192215
216+ it . skip ( 'ScanSecrets with ignore file filters the result' , async ( ) => {
217+ const wrapper = new CxWrapper ( cxScanConfig ) ;
218+ const cxCommandOutput : CxCommandOutput = await wrapper . secretsScanResults (
219+ "src/tests/data/secret-exposed.txt" ,
220+ "src/tests/data/ignoreFileSecrets.json"
221+ ) ;
222+
223+ console . log ( "Json object from scanSecrets with ignore file: " + JSON . stringify ( cxCommandOutput ) ) ;
224+ expect ( cxCommandOutput . payload ) . toBeDefined ( ) ;
225+ expect ( Array . isArray ( cxCommandOutput . payload ) ) . toBe ( true ) ;
226+ expect ( cxCommandOutput . payload . length ) . toBe ( 0 ) ;
227+ expect ( cxCommandOutput . exitCode ) . toBe ( 0 ) ;
193228} ) ;
229+
230+ } ) ;
231+
0 commit comments