generateCacheMemoryGitSetupStep emits a pre-agent step that sets up the git-backed integrity repository inside the given cache directory. It must run after the cache is restored so that any previous git history is available for the merge-down step. The step also performs pre-agent security sanitizat
(builder *strings.Builder, cache CacheMemoryEntry, cacheDir, integrityLevel string, useBackwardCompatiblePaths bool)
| 610 | // working-tree files and, when allowed extensions are configured, removes files with |
| 611 | // disallowed extensions before the agent can access them. |
| 612 | func generateCacheMemoryGitSetupStep(builder *strings.Builder, cache CacheMemoryEntry, cacheDir, integrityLevel string, useBackwardCompatiblePaths bool) { |
| 613 | if useBackwardCompatiblePaths { |
| 614 | builder.WriteString(" - name: Setup cache-memory git repository\n") |
| 615 | } else { |
| 616 | fmt.Fprintf(builder, " - name: Setup cache-memory git repository (%s)\n", cache.ID) |
| 617 | } |
| 618 | builder.WriteString(" env:\n") |
| 619 | fmt.Fprintf(builder, " GH_AW_CACHE_DIR: %s\n", cacheDir) |
| 620 | fmt.Fprintf(builder, " GH_AW_MIN_INTEGRITY: %s\n", integrityLevel) |
| 621 | // Pass colon-separated allowed extensions so the setup script can remove disallowed files |
| 622 | // before the agent runs (pre-agent sanitization). Skip when the list is empty (allow all). |
| 623 | // Single quotes in the value are escaped ('' in YAML single-quoted scalars) as defense-in-depth, |
| 624 | // even though isValidFileExtension already rejects values containing single quotes at parse time. |
| 625 | if len(cache.AllowedExtensions) > 0 { |
| 626 | escaped := strings.ReplaceAll(strings.Join(cache.AllowedExtensions, ":"), "'", "''") |
| 627 | fmt.Fprintf(builder, " GH_AW_ALLOWED_EXTENSIONS: '%s'\n", escaped) |
| 628 | } |
| 629 | builder.WriteString(" run: bash \"${RUNNER_TEMP}/gh-aw/actions/setup_cache_memory_git.sh\"\n") |
| 630 | } |
| 631 | |
| 632 | // generateCacheMemoryGitCommitSteps emits post-agent steps that commit agent-written changes |
| 633 | // to the current integrity branch. These steps run after agent execution and before artifact |
no outgoing calls