Harden Puppetfile parsing, module sources and cache GC
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful

- return an error for an option with no value instead of reading past EOF
- recover panics per environment, module and single-flight as errors
- accept only https, http, ssh and user@host:path module remotes
- fetch modules with protocol.file.allow=never
- reuse module and forge dirs only with an out-of-tree done marker
- rename GC'd dirs aside before deleting and sweep leftovers
- add a Puppetfile fuzz target; serve test modules over git smart HTTP
This commit is contained in:
2026-11-08 20:25:59 +11:00
parent 24857770b2
commit 8a336b62a5
5 changed files with 352 additions and 64 deletions
+3 -2
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"os"
"os/exec"
"slices"
"strings"
"syscall"
"time"
@@ -39,13 +40,13 @@ func (d *Deployer) git(ctx context.Context, dir string, args ...string) (out str
return out, err
}
func (d *Deployer) syncMirror(ctx context.Context, mirror, url string, refspecs ...string) error {
func (d *Deployer) syncMirror(ctx context.Context, mirror, url string, opts, refspecs []string) error {
if _, err := os.Stat(mirror); os.IsNotExist(err) {
if _, err := d.git(ctx, "", "init", "-q", "--bare", "--", mirror); err != nil {
return err
}
}
args := append([]string{"fetch", "-q", "--prune", "--force", "--", url}, refspecs...)
args := slices.Concat(opts, []string{"fetch", "-q", "--prune", "--force", "--", url}, refspecs)
_, err := d.git(ctx, mirror, args...)
return err
}