@@ -188,6 +188,39 @@ describe('Secrets detection e2e tests', () => {
188188 expect ( result . secretsDetected . flatMap ( f => f . secrets ) ) . toHaveLength ( 0 ) ;
189189 } , 30000 ) ;
190190
191+ it ( 'no secrets in Python import statements with keyword-like variable names' , async ( ) => {
192+ writeFile ( 'src/app.py' , [
193+ 'import time' ,
194+ 'from fastapi import Request' ,
195+ 'from api.config import STRIPE_API_KEY, STRIPE_PAYMENT_WEBHOOK_SECRET' ,
196+ 'from mangum import Mangum' ,
197+ 'from starlette.responses import JSONResponse' ,
198+ ''
199+ ] . join ( '\n' ) ) ;
200+ git ( 'add src/app.py' ) ;
201+
202+ const result = await scanSecrets ( 'staged-only' ) ;
203+
204+ const pyFile = result . secretsDetected . find ( f => f . file_path === 'src/app.py' ) ;
205+ const pySecrets = pyFile ? pyFile . secrets : [ ] ;
206+ expect ( pySecrets ) . toHaveLength ( 0 ) ;
207+ } , 30000 ) ;
208+
209+ it ( 'no secrets in JS destructured imports with keyword-like names' , async ( ) => {
210+ writeFile ( 'src/config-loader.js' , [
211+ 'const { API_KEY, SECRET_TOKEN, AUTH_CREDENTIAL } = require("./config");' ,
212+ 'module.exports = { API_KEY, SECRET_TOKEN, AUTH_CREDENTIAL };' ,
213+ ''
214+ ] . join ( '\n' ) ) ;
215+ git ( 'add src/config-loader.js' ) ;
216+
217+ const result = await scanSecrets ( 'staged-only' ) ;
218+
219+ const jsFile = result . secretsDetected . find ( f => f . file_path === 'src/config-loader.js' ) ;
220+ const jsSecrets = jsFile ? jsFile . secrets : [ ] ;
221+ expect ( jsSecrets ) . toHaveLength ( 0 ) ;
222+ } , 30000 ) ;
223+
191224 it ( 'no secrets in placeholder/example values' , async ( ) => {
192225 writeFile ( 'src/config.example.js' , [
193226 'module.exports = {' ,
0 commit comments