Harden Puppetfile parsing, module sources and cache GC
- 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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user