@@ -32,7 +32,10 @@ import {
3232 canonicalFinalizationRecord ,
3333 finalizationRecordDigest ,
3434} from '../scripts/lib/finalization-proof.mjs'
35- import { resolveExecutable } from '../scripts/lib/github-identity.mjs'
35+ import {
36+ assertGitCommandPolicy ,
37+ resolveExecutable ,
38+ } from '../scripts/lib/github-identity.mjs'
3639
3740const execFileAsync = promisify ( execFile )
3841const testDirectory = path . dirname ( fileURLToPath ( import . meta. url ) )
@@ -2324,6 +2327,39 @@ test('authenticated remote Git accepts only exact origin and authorized ref shap
23242327 }
23252328} )
23262329
2330+ test ( 'automation allows only the exact restore cleanliness Git probes' , ( ) => {
2331+ for ( const args of [
2332+ [ 'ls-files' , '-v' , '-z' ] ,
2333+ [
2334+ '-c' ,
2335+ 'core.fileMode=true' ,
2336+ 'diff' ,
2337+ '--quiet' ,
2338+ '--no-ext-diff' ,
2339+ '--no-textconv' ,
2340+ 'HEAD' ,
2341+ '--' ,
2342+ ] ,
2343+ ] ) {
2344+ assert . doesNotThrow ( ( ) => assertGitCommandPolicy ( 'automation' , args ) )
2345+ assert . throws (
2346+ ( ) => assertGitCommandPolicy ( 'reviewer' , args ) ,
2347+ / o u t s i d e t h e a u t h e n t i c a t e d r e v i e w e r c o m m a n d t r e e / ,
2348+ )
2349+ }
2350+ for ( const args of [
2351+ [ 'ls-files' , '-v' ] ,
2352+ [ 'ls-files' , '-v' , '-z' , '--others' ] ,
2353+ [ '-c' , 'core.fileMode=false' , 'diff' , '--quiet' , 'HEAD' , '--' ] ,
2354+ [ '-c' , 'core.fileMode=true' , 'diff' , 'HEAD' , '--' ] ,
2355+ ] ) {
2356+ assert . throws (
2357+ ( ) => assertGitCommandPolicy ( 'automation' , args ) ,
2358+ / o u t s i d e t h e a u t h e n t i c a t e d a u t o m a t i o n c o m m a n d t r e e / ,
2359+ )
2360+ }
2361+ } )
2362+
23272363test ( 'authenticated real Git ignores local execution hooks and configured diff helpers' , async ( ) => {
23282364 const fixture = await createFixture ( { realGit : true } )
23292365 const realGit = await resolveExecutable ( 'git' , process . env )
0 commit comments