跳转到主要内容

一个用于使用IODEF XML格式(RFC 5070)创建、解析和编辑网络事件报告的Python库

项目描述

iodedeflib是一个用于使用IODEF XML格式(RFC 5070)创建、解析和编辑网络事件报告的Python库。

项目网站:http://www.decalage.info/python/iodeflib

一方面,IODEF是一个非常丰富、灵活且可扩展的XML格式,用于描述网络事件。另一方面,由于其丰富的特性和深层嵌套的结构,它在实际应用中可能相当复杂,因为难以解析IODEF内容。

iodedeflib旨在提供一个简单的API,以简化对IODEF感知脚本和应用程序的开发。

iodedeflib与PyPI和Sourceforge上发布的iodef Python包不同。实际上,我创建了iodedeflib,因为我对iodef包的复杂性感到非常失望。iodef是使用GenerateDS从IODEF XML模式自动生成的,这确实暴露了IODEF模式复杂性。

相比之下,iodedeflib被精心设计,以便尽可能简化Python接口,隐藏一些不必要的IODEF模式嵌套结构,并添加更多方便的快捷方式。iodedeflib还设计为可扩展。

下载

前往https://bitbucket.org/decalage/iodeflib/downloads

使用方法

以下示例脚本包含在iodedeflib包中,位于examples子文件夹中。

如何解析IODEF数据

import iodeflib
# open XML file and parse IODEF:
iodef = iodeflib.parse_file('iodef.xml')
# print some attributes for each incident:
for incident in iodef.incidents:
    print 'Incident %s from %s - impact type: %s' % (incident.id,
        incident.id_name, incident.get_first_impact().type)
    for desc in incident.descriptions:
        print desc
    print 'Sources:'
    for system in incident.get_sources(): print system.get_addresses()
    print 'Targets:'
    for system in incident.get_targets(): print system.get_addresses()
    print ''

如何创建IODEF数据

import iodeflib
# create a new IODEF document:
iodef = iodeflib.IODEF_Document()
# create a new incident:
incident1 = iodeflib.Incident(id='1234', id_name='CSIRT-X',
    report_time='2011-09-13T11:01:00+00:00',
    start_time='2011-09-13T10:19:24+00:00')
# add description:
incident1.descriptions = ['Detected denial of service attack']
# add sources and targets:
incident1.add_system(category='source', address='192.168.1.2')
incident1.add_system(category='target', address='192.168.3.7', name='XYZ')
# add impact assessment:
incident1.add_impact(description='DoS on system XYZ', type='dos',
    severity='medium', completion='succeeded', occurence='actual',
    restriction='need-to-know')
iodef.incidents.append(incident1)
# serialize IODEF to XML, print it and save it to a file:
print iodef
open('iodef2.xml', 'w').write(str(iodef))

如何编辑IODEF数据

# open XML file and parse IODEF:
iodef = iodeflib.parse_file('iodef2.xml')
# get incident, add end time and history item:
incident1 = iodef.incidents[0]
histitem = iodeflib.HistoryItem(descriptions=['Blocked source IP.'],
    datetime='2011-09-13T13:47:12+00:00')
incident1.history.append(histitem)
incident1.end_time='2011-09-13T13:47:12+00:00'
incident1.report_time='2011-09-13T13:52:00+00:00'
# save IODEF back to an XML file:
print iodef
open('iodef2_updated.xml', 'w').write(str(iodef))

API的更多信息

请参阅碘化物库文件夹中的iodeflib.html,或检查源代码中的docstrings。

状态

碘化物库尚未实现RFC 5070的所有功能。然而,最有用的类已经可用。

如何贡献

您可以向作者发送电子邮件,或者使用Bitbucket的fork / pull request功能来提出对代码的改进。

请参阅源代码中的TODO部分,以获取潜在改进的列表。

如何报告错误

您可以在https://bitbucket.org/decalage/iodeflib/issues上创建问题票证,或向作者发送电子邮件。

请提供足够的信息以重现错误:您使用的版本,操作系统和Python的版本等。请还提供示例代码和数据文件以重现错误。

许可证

版权(c)2011-2012,菲利普·拉加代克(http://www.decalage.info)。保留所有权利。

重新分发和使用源代码和二进制代码,无论是否修改,只要满足以下条件

  • 源代码的重新分发必须保留上述版权声明、本条件列表和以下免责声明。

  • 二进制形式的重新分发必须在使用上述版权声明、本条件列表和以下免责声明的文档中或与分发提供的其他材料中重新生产。

本软件由版权所有者和贡献者提供“按原样”以及任何明示或暗示的保证,包括但不限于适销性和适用于特定目的的暗示保证均予以放弃。在任何情况下,版权所有者或贡献者不对任何直接、间接、偶然、特殊、示范性或后果性损害(包括但不限于替代商品或服务的采购;使用、数据或利润的损失;或业务中断)承担责任,即使已通知此类损害的可能性,无论此类损害是基于合同、严格责任或侵权(包括疏忽或其他)。

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源代码分发

iodeflib-0.07.zip (35.3 KB 查看散列

上传时间 源代码

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面