【Linux】升级FastJSON版本-jar

打印 上一主题 下一主题

主题 1027|帖子 1027|积分 3081

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
摘要

在长期运行的应用服务器上,近期的安全漏洞扫描揭示了fastjson组件存在潜伏的安全隐患(FastJSON是一个Java 语言实现的 JSON 解析器和天生器。FastJSON存在长途代码实行漏洞,恶意攻击者可以通过此漏洞长途实行恶意代码来入侵服务器)。为解决这一漏洞,解决方案是对fastjson版本的升级,以增强体系的安全性。为了制止因重新打包整个应用带来的不便与效率损失,我们采取了一种更为灵活的更新计谋——直接在生产环境中升级fastjson至最新稳定版本。
FastJson下载

官方链接:https://mvnrepository.com/artifact/com.alibaba/fastjson
按照如下步骤进行下载FastJson的jar包

 下滑找到你要的fastjson包版本,我选择1.2.83。

 跳转到具体1.2.83版本页。

 跳转到GitHub,点击如下图所示:

 点击下载FastJson的jar包

 升级Fastjson

1.找到服务器上正在运行的Java的jar包

  1. # 根据命令能看见正在跑的Java的jar包
  2. ps -ef|grep java
  3. # 根据命令找到Java包的位置
  4. find / -name xx.jar
复制代码

2.备份jar包

  1. # 切换到jar包目录
  2. cd /xxx/xxx
  3. # 复制一份jar包
  4. cp xx.jar xx.jar_日期.bak
复制代码
 举例如下:

3.创建临时文件夹,并将jar移入

注:先备份要进行升级fastjson的jar包
  1. mkdir temp
  2. mv xxx.jar temp/
  3. # 切换到临时目录
  4. cd temp/
复制代码
4.解压jar包

  1. jar xvf xxx.jar
  2. # 一般解压有三个目录:BOOT-INF/ META-INF/ org/
复制代码
通过jar --help 命令查看 jar 的相干命令
  1. Illegal option: -
  2. Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
  3. Options:
  4.     -c  create new archive
  5.     -t  list table of contents for archive
  6.     -x  extract named (or all) files from archive
  7.     -u  update existing archive
  8.     -v  generate verbose output on standard output
  9.     -f  specify archive file name
  10.     -m  include manifest information from specified manifest file
  11.     -n  perform Pack200 normalization after creating a new archive
  12.     -e  specify application entry point for stand-alone application
  13.         bundled into an executable jar file
  14.     -0  store only; use no ZIP compression
  15.     -P  preserve leading '/' (absolute path) and ".." (parent directory) components from file names
  16.     -M  do not create a manifest file for the entries
  17.     -i  generate index information for the specified jar files
  18.     -C  change to the specified directory and include the following file
  19. If any file is a directory then it is processed recursively.
  20. The manifest file name, the archive file name and the entry point name are
  21. specified in the same order as the 'm', 'f' and 'e' flags.
  22. Example 1: to archive two class files into an archive called classes.jar:
  23.        jar cvf classes.jar Foo.class Bar.class
  24. Example 2: use an existing manifest file 'mymanifest' and archive all the
  25.            files in the foo/ directory into 'classes.jar':
  26.        jar cvfm classes.jar mymanifest -C foo/ .
复制代码
  用法:jar {ctxui} [vfmn0PMe] [jar文件] [清单文件] [入口点] [-C目录]文件...
选项:
    -c创建新档案
    -t列出要归档的目录
    -x从存档中提取命名(或所有)文件
    -u更新现有档案
    -v在标准输出上天生详细输出
    -f指定归档文件名
    -m包罗来自指定清单文件的清单信息
    -n在创建新存档后实行Pack200规范化
    -e指定独立应用程序的应用程序入口点
        捆绑到可实行的jar文件中
    -0只存储;不使用ZIP压缩 (数字0)
    -P从文件名生存前导的“ /”(绝对路径)和“ ..”(父目录)组件
    -M不为条目创建清单文件
    -i为指定的jar文件天生索引信息
    -C更改为指定目录并包罗以下文件
如果任何文件是目录,则将对其进行递归处置惩罚。
清单文件名称,归档文件名称和入口点名称为
以与“ m”,“ f”和“ e”标记类似的顺序指定。
  5.更新fastjson的jar包

  1. # 切换到BOOT-INF/lib
  2. cd BOOT-INF/lib
  3. # 找到fastjson.jar并替换,可采用文件传输工具或者命令
复制代码
6.重新打成jar包

  1. #打包时先删除当前目录的xxx.jar包
  2. rm -rf xxx.jar
  3. #将所有文件重新压缩成xxx.jar包
  4. jar -cvfM0 xxx.jar BOOT-INF/ META-INF/ org/
  5. #将重新打包的xxx.jar放回原来目录,并运行新的jar包。
复制代码
到此,在Linux环境下fastjson升级完成。
参考:jar包的解压和重新打包_jar解压后重新打包-CSDN博客

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

愛在花開的季節

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表