@@ -879,6 +879,26 @@ if(NOT _workflow_metadata_sync_count EQUAL 2)
879879 "Both ROS 2 workflow jobs must synchronize project metadata before rosdep; "
880880 "found ${_workflow_metadata_sync_count} invocations." )
881881endif ()
882+ string (REGEX MATCHALL
883+ "git config --global --add safe\\ .directory \"\\ $\\ {GITHUB_WORKSPACE\\ }\" "
884+ _workflow_workspace_trusts
885+ "${_workflow_contents} " )
886+ list (LENGTH _workflow_workspace_trusts _workflow_workspace_trust_count)
887+ string (REGEX MATCHALL
888+ "git -C \"\\ $\\ {GITHUB_WORKSPACE\\ }\" rev-parse --is-inside-work-tree"
889+ _workflow_worktree_probes
890+ "${_workflow_contents} " )
891+ list (LENGTH _workflow_worktree_probes _workflow_worktree_probe_count)
892+ if (NOT _workflow_workspace_trust_count EQUAL 2
893+ OR NOT _workflow_worktree_probe_count EQUAL 2)
894+ message (FATAL_ERROR
895+ "Both ROS 2 workflow jobs must trust and validate the exact mounted Git workspace; "
896+ "found ${_workflow_workspace_trust_count} trust commands and "
897+ "${_workflow_worktree_probe_count} worktree probes." )
898+ endif ()
899+ if (_workflow_contents MATCHES "safe\\ .directory[^\n ]*[\" ']?\\ *" )
900+ message (FATAL_ERROR "ROS 2 workflow must not trust every Git repository with safe.directory '*'." )
901+ endif ()
882902string (REGEX MATCHALL
883903 "git diff --exit-code -- ros2/\\ */package\\ .xml"
884904 _workflow_manifest_drift_guards
@@ -978,6 +998,30 @@ if(NOT _project_workflow_metadata_sync_count EQUAL 1)
978998 "Generic ROS workflow must synchronize metadata exactly once; "
979999 "found ${_project_workflow_metadata_sync_count} invocations." )
9801000endif ()
1001+ string (REGEX MATCHALL
1002+ "git config --global --add safe\\ .directory \"\\ $\\ {GITHUB_WORKSPACE\\ }\" "
1003+ _project_workflow_workspace_trusts
1004+ "${_workflow_template_contents} " )
1005+ list (LENGTH
1006+ _project_workflow_workspace_trusts
1007+ _project_workflow_workspace_trust_count)
1008+ string (REGEX MATCHALL
1009+ "git -C \"\\ $\\ {GITHUB_WORKSPACE\\ }\" rev-parse --is-inside-work-tree"
1010+ _project_workflow_worktree_probes
1011+ "${_workflow_template_contents} " )
1012+ list (LENGTH
1013+ _project_workflow_worktree_probes
1014+ _project_workflow_worktree_probe_count)
1015+ if (NOT _project_workflow_workspace_trust_count EQUAL 1
1016+ OR NOT _project_workflow_worktree_probe_count EQUAL 1)
1017+ message (FATAL_ERROR
1018+ "Generic ROS workflow must trust and validate the exact mounted Git workspace once; "
1019+ "found ${_project_workflow_workspace_trust_count} trust commands and "
1020+ "${_project_workflow_worktree_probe_count} worktree probes." )
1021+ endif ()
1022+ if (_workflow_template_contents MATCHES "safe\\ .directory[^\n ]*[\" ']?\\ *" )
1023+ message (FATAL_ERROR "Generic ROS workflow must not trust every Git repository with safe.directory '*'." )
1024+ endif ()
9811025string (REGEX MATCHALL
9821026 "git diff --exit-code -- ros2/\\ */package\\ .xml"
9831027 _project_workflow_manifest_drift_guards
0 commit comments