@@ -231,48 +231,6 @@ describe('secrets detection (default scan mode)', () => {
231231 expect ( res . status ) . toBe ( 0 ) ;
232232 expect ( res . stdout ) . not . toContain ( 'Potential secrets detected in codebase:' ) ;
233233 } ) ;
234- it ( 'should warn about using https URLs in codebase' , ( ) => {
235- const cwd = tmpDir ( ) ;
236-
237- fs . writeFileSync ( path . join ( cwd , '.env' ) , 'DUMMY=\n' ) ;
238- fs . mkdirSync ( path . join ( cwd , 'src' ) , { recursive : true } ) ;
239- fs . writeFileSync (
240- path . join ( cwd , 'src' , 'index.ts' ) ,
241- `
242- const service = 'https://hello.com';
243- const service2 = "https://hello.com/api";
244- const service3 = \`https://hello.com/path\`;
245-
246- console.log(service, service2, service3);
247- ` . trimStart ( ) ,
248- ) ;
249-
250- const res = runCli ( cwd , [ ] ) ;
251- expect ( res . status ) . toBe ( 0 ) ;
252- expect ( res . stdout ) . toContain ( 'Potential secrets detected in codebase:' ) ;
253- expect ( res . stdout ) . toContain ( 'HTTPS URL detected' ) ;
254- } ) ;
255- it ( 'should warn about using http URLs in codebase' , ( ) => {
256- const cwd = tmpDir ( ) ;
257-
258- fs . writeFileSync ( path . join ( cwd , '.env' ) , 'DUMMY=\n' ) ;
259- fs . mkdirSync ( path . join ( cwd , 'src' ) , { recursive : true } ) ;
260- fs . writeFileSync (
261- path . join ( cwd , 'src' , 'index.ts' ) ,
262- `
263- const service = 'http://hello.com';
264- const service2 = "http://thisIsASecret.com/api";
265- const service3 = \`http://yes.com/path\`;
266-
267- console.log(service, service2, service3);
268- ` . trimStart ( ) ,
269- ) ;
270-
271- const res = runCli ( cwd , [ ] ) ;
272- expect ( res . status ) . toBe ( 0 ) ;
273- expect ( res . stdout ) . toContain ( 'Potential secrets detected in codebase:' ) ;
274- expect ( res . stdout ) . toContain ( 'HTTP URL detected' ) ;
275- } ) ;
276234 it ( 'should not give warning on SVG content' , ( ) => {
277235 const cwd = tmpDir ( ) ;
278236
@@ -312,45 +270,4 @@ describe('secrets detection (default scan mode)', () => {
312270 expect ( res . status ) . toBe ( 0 ) ;
313271 expect ( res . stdout ) . not . toContain ( 'Potential secrets detected in codebase:' ) ;
314272 } ) ;
315- it ( 'should ignore warnings with dotenv-diff-ignore comments' , ( ) => {
316- const cwd = tmpDir ( ) ;
317-
318- fs . writeFileSync ( path . join ( cwd , '.env' ) , 'DUMMY=\n' ) ;
319- fs . mkdirSync ( path . join ( cwd , 'src' ) , { recursive : true } ) ;
320- fs . writeFileSync (
321- path . join ( cwd , 'src' , 'index.ts' ) ,
322- `
323- // These should be flagged normally
324- const service1 = 'https://shouldwarn.com';
325- const secret1 = "sk_live_abcdefghijklmnopqrstuvwx";
326-
327- // These should be ignored with comments
328- const service2 = 'https://exdfdfdfdfdfe.com'; // dotenv-diff-ignore
329- const service3 = "https://ignored.com/api" /* dotenv-diff-ignore */;
330- const secret2 = "sk_live_ignoredtoken123"; // dotenv-diff-ignore
331- const apiKey = 'AKIA1234567890IGNORE' /* dotenv-diff-ignore */;
332-
333- // Also test high entropy strings
334- const ignoredEntropy = "highEntropyButIgnored987654321fedcba"; // dotenv-diff-ignore
335-
336- console.log(service1, service2, service3, secret1, secret2, apiKey, ignoredEntropy);
337- ` . trimStart ( ) ,
338- ) ;
339-
340- const res = runCli ( cwd , [ ] ) ;
341- expect ( res . status ) . toBe ( 1 ) ;
342- expect ( res . stdout ) . toContain ( 'Potential secrets detected in codebase:' ) ;
343-
344- // Should warn about the non-ignored ones
345- expect ( res . stdout ) . toContain ( 'HIGH' ) ;
346- expect ( res . stdout ) . toContain ( 'shouldwarn.com' ) ;
347- expect ( res . stdout ) . toContain ( 'sk_live_abcdefghijklmnopqrstuvwx' ) ;
348-
349- // Should NOT warn about the ignored ones
350- expect ( res . stdout ) . not . toContain ( 'exdfdfdfdfdfe.com' ) ;
351- expect ( res . stdout ) . not . toContain ( 'ignored.com' ) ;
352- expect ( res . stdout ) . not . toContain ( 'sk_live_ignoredtoken123' ) ;
353- expect ( res . stdout ) . not . toContain ( 'AKIA1234567890IGNORE' ) ;
354- expect ( res . stdout ) . not . toContain ( 'highEntropyButIgnored987654321fedcba' ) ;
355- } ) ;
356273} ) ;
0 commit comments