|
74 | 74 | slurpContentDisposition = slurpCmd.Flag("content-disposition", "Content disposition header").String() |
75 | 75 |
|
76 | 76 | // Testzip command (serves a local zip file via HTTP for debugging) |
77 | | - testzipCmd = app.Command("testzip", "Extract and serve a local zip file via HTTP for debugging") |
78 | | - testzipFile = testzipCmd.Arg("file", "Path to zip file").Required().String() |
| 77 | + testzipCmd = app.Command("testzip", "Extract and serve a local zip file via HTTP for debugging") |
| 78 | + testzipFile = testzipCmd.Arg("file", "Path to zip file").Required().String() |
| 79 | + testzipMaxFileSize = testzipCmd.Flag("max-file-size", "Maximum size per file in bytes").Uint64() |
| 80 | + testzipMaxTotalSize = testzipCmd.Flag("max-total-size", "Maximum total extracted size in bytes").Uint64() |
| 81 | + testzipMaxNumFiles = testzipCmd.Flag("max-num-files", "Maximum number of files").Int() |
| 82 | + testzipFilter = testzipCmd.Flag("filter", "Glob pattern to filter extracted files").String() |
79 | 83 |
|
80 | 84 | // Dump command |
81 | 85 | dumpCmd = app.Command("dump", "Dump parsed config and exit") |
@@ -306,5 +310,18 @@ func runSlurp(config *zipserver.Config) { |
306 | 310 | } |
307 | 311 |
|
308 | 312 | func runTestzip(config *zipserver.Config) { |
309 | | - must(zipserver.ServeZip(config, *testzipFile)) |
| 313 | + limits := zipserver.DefaultExtractLimits(config) |
| 314 | + if *testzipMaxFileSize > 0 { |
| 315 | + limits.MaxFileSize = *testzipMaxFileSize |
| 316 | + } |
| 317 | + if *testzipMaxTotalSize > 0 { |
| 318 | + limits.MaxTotalSize = *testzipMaxTotalSize |
| 319 | + } |
| 320 | + if *testzipMaxNumFiles > 0 { |
| 321 | + limits.MaxNumFiles = *testzipMaxNumFiles |
| 322 | + } |
| 323 | + if *testzipFilter != "" { |
| 324 | + limits.IncludeGlob = *testzipFilter |
| 325 | + } |
| 326 | + must(zipserver.ServeZip(config, *testzipFile, limits)) |
310 | 327 | } |
0 commit comments