gpt4 book ai didi

org.apache.poi.openxml4j.util.ZipSecureFile.setMinInflateRatio()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 03:55:31 33 4
gpt4 key购买 nike

本文整理了Java中org.apache.poi.openxml4j.util.ZipSecureFile.setMinInflateRatio()方法的一些代码示例,展示了ZipSecureFile.setMinInflateRatio()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipSecureFile.setMinInflateRatio()方法的具体详情如下:
包路径:org.apache.poi.openxml4j.util.ZipSecureFile
类名称:ZipSecureFile
方法名:setMinInflateRatio

ZipSecureFile.setMinInflateRatio介绍

[英]Sets the ratio between de- and inflated bytes to detect zipbomb. It defaults to 1% (= 0.01d), i.e. when the compression is better than 1% for any given read package part, the parsing will fail indicating a Zip-Bomb.
[中]设置反压缩字节和膨胀字节之间的比率,以检测压缩字节。它默认为1%(=0.01d),也就是说,当任何给定的读取包部分的压缩比大于1%时,解析将失败,表明存在压缩炸弹。

代码示例

代码示例来源:origin: wuyouzhuguli/FEBS-Shiro

static void writeByLocalOrBrowser(HttpServletResponse response, String fileName, SXSSFWorkbook wb, OutputStream out) {
  try {
    ZipSecureFile.setMinInflateRatio(0L);
    if (response != null) {
      // response对象不为空,响应到浏览器下载
      response.setContentType(FebsConstant.XLSX_CONTENT_TYPE);
      response.setHeader("Content-disposition", "attachment; filename="
          + URLEncoder.encode(String.format("%s%s", fileName, FebsConstant.XLSX_SUFFIX), "UTF-8"));
      if (out == null) {
        out = response.getOutputStream();
      }
    }
    wb.write(out);
    out.flush();
    out.close();
  } catch (Exception e) {
    log.error(e.getMessage());
  }
}

代码示例来源:origin: pentaho/pentaho-kettle

minInflateRatio = Const.KETTLE_ZIP_MIN_INFLATE_RATIO_DEFAULT;
ZipSecureFile.setMinInflateRatio( minInflateRatio );

代码示例来源:origin: pentaho/pentaho-kettle

@Test
public void testZipBombConfiguration_Default() throws Exception {
 // First set some random values
 Long bogusMaxEntrySize = 1000L;
 ZipSecureFile.setMaxEntrySize( bogusMaxEntrySize );
 Long bogusMaxTextSize = 1000L;
 ZipSecureFile.setMaxTextSize( bogusMaxTextSize );
 Double bogusMinInflateRatio = 0.5d;
 ZipSecureFile.setMinInflateRatio( bogusMinInflateRatio );
 // Verify that the bogus values were set
 assertEquals( bogusMaxEntrySize, (Long) ZipSecureFile.getMaxEntrySize() );
 assertEquals( bogusMaxTextSize, (Long) ZipSecureFile.getMaxTextSize() );
 assertEquals( bogusMinInflateRatio, (Double) ZipSecureFile.getMinInflateRatio() );
 // Initializing the ExcelInput step should make the new values to be set
 meta.setSpreadSheetType( SpreadSheetType.SAX_POI );
 init( "Balance_Type_Codes.xlsx" );
 // Verify that the default values were used
 assertEquals( Const.KETTLE_ZIP_MAX_ENTRY_SIZE_DEFAULT, (Long) ZipSecureFile.getMaxEntrySize() );
 assertEquals( Const.KETTLE_ZIP_MAX_TEXT_SIZE_DEFAULT, (Long) ZipSecureFile.getMaxTextSize() );
 assertEquals( Const.KETTLE_ZIP_MIN_INFLATE_RATIO_DEFAULT, (Double) ZipSecureFile.getMinInflateRatio() );
}

代码示例来源:origin: openl-tablets/openl-tablets

public static void configureZipBombDetection() {
  // ZIP bomb detection tuning. Don't disable it by setting it in 0.
  // https://bz.apache.org/bugzilla/show_bug.cgi?id=58499
  // 0.001 is when 1MByte expands to 1 GByte
  ZipSecureFile.setMinInflateRatio(0.001);
}

代码示例来源:origin: wuyouzhuguli/FEBS-Security

static void writeByLocalOrBrowser(HttpServletResponse response, String fileName, SXSSFWorkbook wb, OutputStream out) {
  try {
    ZipSecureFile.setMinInflateRatio(0L);
    if (response != null) {
      // response对象不为空,响应到浏览器下载
      response.setContentType(FebsConstant.XLSX_CONTENT_TYPE);
      response.setHeader("Content-disposition", "attachment; filename="
          + URLEncoder.encode(String.format("%s%s", fileName, FebsConstant.XLSX_SUFFIX), "UTF-8"));
      if (out == null) {
        out = response.getOutputStream();
      }
    }
    wb.write(out);
    out.flush();
    out.close();
  } catch (Exception e) {
    log.error(e.getMessage());
  }
}

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com