aboutsummaryrefslogtreecommitdiffsponsor
path: root/archive.go
diff options
context:
space:
mode:
Diffstat (limited to 'archive.go')
-rw-r--r--archive.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/archive.go b/archive.go
index 6610936..76c16b8 100644
--- a/archive.go
+++ b/archive.go
@@ -124,6 +124,8 @@ type TarCfg struct {
Root string
Chown bool
Chmod bool
+ // Strict bails out when anything unexpected is encountered.
+ Strict bool
}
type TarExtracter struct {
@@ -140,6 +142,21 @@ func (s *TarExtracter) FilterTar(
) error {
target := path.Join(s.cfg.Root, header.Name)
+ if s.cfg.Strict {
+ if len(header.PAXRecords) > 0 {
+ return errors.Errorf(
+ "%s: contains unsupported PAXRecords, bailing out",
+ header.Name,
+ )
+ }
+ if len(header.Xattrs) > 0 {
+ return errors.Errorf(
+ "%s: contains unsupported extended attributes, bailing out",
+ header.Name,
+ )
+ }
+ }
+
var err error
switch header.Typeflag {
case tar.TypeBlock: