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

推荐订阅源

腾讯CDC
Schneier on Security
Schneier on Security
B
Blog RSS Feed
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
A
About on SuperTechFans
Recorded Future
Recorded Future
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
V2EX - 技术
V2EX - 技术
N
Netflix TechBlog - Medium
F
Fortinet All Blogs
V
Visual Studio Blog
Martin Fowler
Martin Fowler
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
Scott Helme
Scott Helme
H
Heimdal Security Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
Application and Cybersecurity Blog
Application and Cybersecurity Blog
V
Vulnerabilities – Threatpost
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Troy Hunt's Blog
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
Jina AI
Jina AI
S
Securelist
小众软件
小众软件
Simon Willison's Weblog
Simon Willison's Weblog
J
Java Code Geeks
AWS News Blog
AWS News Blog
N
News and Events Feed by Topic
博客园 - 三生石上(FineUI控件)
量子位

博客园 - 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)