@@ -121,62 +121,4 @@ describe("run-opengrep.sh", () => {
121121 expect ( args ) . toContain ( "src/pr.ts" ) ;
122122 expect ( args ) . not . toContain ( "src/main-only.ts" ) ;
123123 } ) ;
124-
125- it ( "does not pass changed files ignored by semgrepignore as explicit scan paths" , ( ) => {
126- const repo = createTempDir ( "openclaw-run-opengrep-ignore-" ) ;
127- git ( repo , "init" , "-q" , "--initial-branch=main" ) ;
128- git ( repo , "config" , "user.email" , "test@example.com" ) ;
129- git ( repo , "config" , "user.name" , "Test User" ) ;
130-
131- copyRunOpengrepFiles ( repo ) ;
132- writeFile ( path . join ( repo , ".semgrepignore" ) , "*.test.*\nextensions/qa-*/\nscripts/test-*\n" ) ;
133- writeFile ( path . join ( repo , "security/opengrep/precise.yml" ) , "rules: []\n" ) ;
134- writeFile ( path . join ( repo , "src/prod.ts" ) , "export const prod = 1;\n" ) ;
135- writeFile ( path . join ( repo , "src/prod.test.ts" ) , "export const test = 1;\n" ) ;
136- writeFile ( path . join ( repo , "src/foo/extensions/qa-demo/index.ts" ) , "export const nested = 1;\n" ) ;
137- writeFile ( path . join ( repo , "extensions/qa-backdoor.ts" ) , "export const qaBackdoor = 1;\n" ) ;
138- writeFile ( path . join ( repo , "extensions/qa-demo/src/index.ts" ) , "export const qa = 1;\n" ) ;
139- writeFile ( path . join ( repo , "scripts/test-planner/vitest-args.mjs" ) , "export const plan = 1;\n" ) ;
140- git ( repo , "add" , "." ) ;
141- git ( repo , "commit" , "-qm" , "base" ) ;
142-
143- writeFile ( path . join ( repo , "src/prod.ts" ) , "export const prod = 2;\n" ) ;
144- writeFile ( path . join ( repo , "src/prod.test.ts" ) , "export const test = 2;\n" ) ;
145- writeFile ( path . join ( repo , "src/foo/extensions/qa-demo/index.ts" ) , "export const nested = 2;\n" ) ;
146- writeFile ( path . join ( repo , "extensions/qa-backdoor.ts" ) , "export const qaBackdoor = 2;\n" ) ;
147- writeFile ( path . join ( repo , "extensions/qa-demo/src/index.ts" ) , "export const qa = 2;\n" ) ;
148- writeFile ( path . join ( repo , "scripts/test-planner/vitest-args.mjs" ) , "export const plan = 2;\n" ) ;
149-
150- const argsPath = path . join ( repo , "opengrep-args.txt" ) ;
151- const binDir = path . join ( repo , "bin" ) ;
152- fs . mkdirSync ( binDir ) ;
153- writeFile (
154- path . join ( binDir , "opengrep" ) ,
155- [
156- "#!/usr/bin/env bash" ,
157- `printf '%s\\n' "$@" > ${ JSON . stringify ( argsPath ) } ` ,
158- "exit 0" ,
159- "" ,
160- ] . join ( "\n" ) ,
161- ) ;
162- fs . chmodSync ( path . join ( binDir , "opengrep" ) , 0o755 ) ;
163-
164- execFileSync ( "bash" , [ "scripts/run-opengrep.sh" , "--changed" ] , {
165- cwd : repo ,
166- env : {
167- ...process . env ,
168- PATH : `${ binDir } ${ path . delimiter } ${ process . env . PATH ?? "" } ` ,
169- OPENCLAW_OPENGREP_BASE_REF : "HEAD" ,
170- } ,
171- encoding : "utf8" ,
172- } ) ;
173-
174- const args = fs . readFileSync ( argsPath , "utf8" ) ;
175- expect ( args ) . toContain ( "src/prod.ts" ) ;
176- expect ( args ) . toContain ( "src/foo/extensions/qa-demo/index.ts" ) ;
177- expect ( args ) . toContain ( "extensions/qa-backdoor.ts" ) ;
178- expect ( args ) . not . toContain ( "src/prod.test.ts" ) ;
179- expect ( args ) . not . toContain ( "extensions/qa-demo/src/index.ts" ) ;
180- expect ( args ) . not . toContain ( "scripts/test-planner/vitest-args.mjs" ) ;
181- } ) ;
182124} ) ;
0 commit comments