@@ -195,9 +195,35 @@ CMD ["echo", "test"]`
195195 t .Fatal (err )
196196 }
197197
198+ // Initialize git repository for SBOM timestamp normalization
199+ {
200+ gitInit := exec .Command ("git" , "init" )
201+ gitInit .Dir = tmpDir
202+ gitInit .Env = append (os .Environ (), "GIT_CONFIG_GLOBAL=/dev/null" , "GIT_CONFIG_SYSTEM=/dev/null" )
203+ if err := gitInit .Run (); err != nil {
204+ t .Fatalf ("Failed to initialize git repository: %v" , err )
205+ }
206+
207+ // Configure git user for commits
208+ gitConfigName := exec .Command ("git" , "config" , "user.name" , "Test User" )
209+ gitConfigName .Dir = tmpDir
210+ gitConfigName .Env = append (os .Environ (), "GIT_CONFIG_GLOBAL=/dev/null" , "GIT_CONFIG_SYSTEM=/dev/null" )
211+ if err := gitConfigName .Run (); err != nil {
212+ t .Fatalf ("Failed to configure git user.name: %v" , err )
213+ }
214+
215+ gitConfigEmail := exec .Command ("git" , "config" , "user.email" , "test@example.com" )
216+ gitConfigEmail .Dir = tmpDir
217+ gitConfigEmail .Env = append (os .Environ (), "GIT_CONFIG_GLOBAL=/dev/null" , "GIT_CONFIG_SYSTEM=/dev/null" )
218+ if err := gitConfigEmail .Run (); err != nil {
219+ t .Fatalf ("Failed to configure git user.email: %v" , err )
220+ }
221+ }
222+
198223 // Create initial git commit for SBOM timestamp
199224 gitAdd := exec .Command ("git" , "add" , "." )
200225 gitAdd .Dir = tmpDir
226+ gitAdd .Env = append (os .Environ (), "GIT_CONFIG_GLOBAL=/dev/null" , "GIT_CONFIG_SYSTEM=/dev/null" )
201227 if err := gitAdd .Run (); err != nil {
202228 t .Fatalf ("Failed to git add: %v" , err )
203229 }
@@ -206,6 +232,8 @@ CMD ["echo", "test"]`
206232 gitCommit := exec .Command ("git" , "commit" , "-m" , "initial" )
207233 gitCommit .Dir = tmpDir
208234 gitCommit .Env = append (os .Environ (),
235+ "GIT_CONFIG_GLOBAL=/dev/null" ,
236+ "GIT_CONFIG_SYSTEM=/dev/null" ,
209237 "GIT_AUTHOR_DATE=2021-01-01T00:00:00Z" ,
210238 "GIT_COMMITTER_DATE=2021-01-01T00:00:00Z" ,
211239 )
@@ -1276,23 +1304,28 @@ func TestDockerPackage_SBOM_OCI_Integration(t *testing.T) {
12761304 tmpDir := t .TempDir ()
12771305
12781306 // Initialize git repository for SBOM timestamp normalization
1279- gitInit := exec .Command ("git" , "init" )
1280- gitInit .Dir = tmpDir
1281- if err := gitInit .Run (); err != nil {
1282- t .Fatalf ("Failed to initialize git repository: %v" , err )
1283- }
1307+ {
1308+ gitInit := exec .Command ("git" , "init" )
1309+ gitInit .Dir = tmpDir
1310+ gitInit .Env = append (os .Environ (), "GIT_CONFIG_GLOBAL=/dev/null" , "GIT_CONFIG_SYSTEM=/dev/null" )
1311+ if err := gitInit .Run (); err != nil {
1312+ t .Fatalf ("Failed to initialize git repository: %v" , err )
1313+ }
12841314
1285- // Configure git user for commits
1286- gitConfigName := exec .Command ("git" , "config" , "user.name" , "Test User" )
1287- gitConfigName .Dir = tmpDir
1288- if err := gitConfigName .Run (); err != nil {
1289- t .Fatalf ("Failed to configure git user.name: %v" , err )
1290- }
1315+ // Configure git user for commits
1316+ gitConfigName := exec .Command ("git" , "config" , "user.name" , "Test User" )
1317+ gitConfigName .Dir = tmpDir
1318+ gitConfigName .Env = append (os .Environ (), "GIT_CONFIG_GLOBAL=/dev/null" , "GIT_CONFIG_SYSTEM=/dev/null" )
1319+ if err := gitConfigName .Run (); err != nil {
1320+ t .Fatalf ("Failed to configure git user.name: %v" , err )
1321+ }
12911322
1292- gitConfigEmail := exec .Command ("git" , "config" , "user.email" , "test@example.com" )
1293- gitConfigEmail .Dir = tmpDir
1294- if err := gitConfigEmail .Run (); err != nil {
1295- t .Fatalf ("Failed to configure git user.email: %v" , err )
1323+ gitConfigEmail := exec .Command ("git" , "config" , "user.email" , "test@example.com" )
1324+ gitConfigEmail .Dir = tmpDir
1325+ gitConfigEmail .Env = append (os .Environ (), "GIT_CONFIG_GLOBAL=/dev/null" , "GIT_CONFIG_SYSTEM=/dev/null" )
1326+ if err := gitConfigEmail .Run (); err != nil {
1327+ t .Fatalf ("Failed to configure git user.email: %v" , err )
1328+ }
12961329 }
12971330
12981331 // Create WORKSPACE.yaml with SBOM enabled
@@ -1335,9 +1368,35 @@ CMD ["echo", "test"]`
13351368 t .Fatal (err )
13361369 }
13371370
1371+ // Initialize git repository for SBOM timestamp normalization
1372+ {
1373+ gitInit := exec .Command ("git" , "init" )
1374+ gitInit .Dir = tmpDir
1375+ gitInit .Env = append (os .Environ (), "GIT_CONFIG_GLOBAL=/dev/null" , "GIT_CONFIG_SYSTEM=/dev/null" )
1376+ if err := gitInit .Run (); err != nil {
1377+ t .Fatalf ("Failed to initialize git repository: %v" , err )
1378+ }
1379+
1380+ // Configure git user for commits
1381+ gitConfigName := exec .Command ("git" , "config" , "user.name" , "Test User" )
1382+ gitConfigName .Dir = tmpDir
1383+ gitConfigName .Env = append (os .Environ (), "GIT_CONFIG_GLOBAL=/dev/null" , "GIT_CONFIG_SYSTEM=/dev/null" )
1384+ if err := gitConfigName .Run (); err != nil {
1385+ t .Fatalf ("Failed to configure git user.name: %v" , err )
1386+ }
1387+
1388+ gitConfigEmail := exec .Command ("git" , "config" , "user.email" , "test@example.com" )
1389+ gitConfigEmail .Dir = tmpDir
1390+ gitConfigEmail .Env = append (os .Environ (), "GIT_CONFIG_GLOBAL=/dev/null" , "GIT_CONFIG_SYSTEM=/dev/null" )
1391+ if err := gitConfigEmail .Run (); err != nil {
1392+ t .Fatalf ("Failed to configure git user.email: %v" , err )
1393+ }
1394+ }
1395+
13381396 // Create initial git commit for SBOM timestamp
13391397 gitAdd := exec .Command ("git" , "add" , "." )
13401398 gitAdd .Dir = tmpDir
1399+ gitAdd .Env = append (os .Environ (), "GIT_CONFIG_GLOBAL=/dev/null" , "GIT_CONFIG_SYSTEM=/dev/null" )
13411400 if err := gitAdd .Run (); err != nil {
13421401 t .Fatalf ("Failed to git add: %v" , err )
13431402 }
@@ -1346,6 +1405,8 @@ CMD ["echo", "test"]`
13461405 gitCommit := exec .Command ("git" , "commit" , "-m" , "initial" )
13471406 gitCommit .Dir = tmpDir
13481407 gitCommit .Env = append (os .Environ (),
1408+ "GIT_CONFIG_GLOBAL=/dev/null" ,
1409+ "GIT_CONFIG_SYSTEM=/dev/null" ,
13491410 "GIT_AUTHOR_DATE=2021-01-01T00:00:00Z" ,
13501411 "GIT_COMMITTER_DATE=2021-01-01T00:00:00Z" ,
13511412 )
0 commit comments