惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - killkill

Oracle User Calls 和 Executions 两个概念的区别 使用 dbms_xplan.display 按照 plan_hash_value 查执行计划的方法 oratop 各个指标项说明 [转] sql_id VS hash_value lsattr/chattr [转]节约内存:Instagram的Redis实践 [原]佛山-杭州自驾路书 [原] insert into … on duplicate key update / replace into 多行数据 [摘] python url decoder 一条霸气的分析binlog的命令 一句命令完成MySQL的数据迁移(轻量级) [转]Linux下SSH Session复制 使用taskset命令来限制进程的CPU MySQL重复记录删除 使用Screen抵御杯具 [摘]Oracle 11g Flashback_transaction_query的undo_sql为空? Duplicate Active Database 遇到 ORA-01017 invalid username/password [摘]如何抓住蝴蝶效应中的那只蝴蝶 [原]将Oracle 中的blob导出到文件中
jar 冲突、class 冲突的检测脚本
killkill · 2019-11-28 · via 博客园 - killkill

思路很简单,解开war包,解开 jar 包,发现有同名 package.class 就报出来,不管是否“兼容” ..

import zipfile
import io
from collections import defaultdict
import sys

if len(sys.argv) < 2:
    print("{0} /path/xxx.war".format(sys.argv[0]))
    exit(1)

exit_code = 0
jar_classes = defaultdict(set)
war_file = zipfile.ZipFile(sys.argv[1], "r")

for jar_file in war_file.infolist():
    if jar_file.filename.endswith(".jar"):
        jar_content = io.BytesIO(war_file.read(jar_file))
        jar_zip_file = zipfile.ZipFile(jar_content, "r")
        for jar_item in jar_zip_file.infolist():
            if jar_item.filename.endswith(".class"):
                class_full_name = jar_item.filename
                jar_classes[class_full_name].add(jar_file.filename.split("/")[-1].strip())

for class_full_name in sorted(jar_classes.keys()):
    jar_filename_set = jar_classes[class_full_name]
    if len(jar_filename_set) > 1:
        exit_code = 1
        class_full_name = ".".join(class_full_name.replace("/", ".").split(".")[:-1])
        print("{1}\t{0}".format(class_full_name, ", ".join(jar_filename_set)))

war_file.close()
exit(exit_code)