コード例 #1
0
ファイル: bc_genrep_dfxml.py プロジェクト: cy-fir/bitcurator
def bc_get_volume_info_from_sax(FiwalkReport, fn, image_info, prtn_info_items,
                                glb_image_info):

    #
    # Callback function to process the SAX stream for volume object
    #
    def cbv(fv):
        t_image_info['partition_offset'] = fv.partition_offset()
        t_image_info['block_count'] = fv.block_count()
        t_image_info['last_block'] = fv.last_block()
        t_image_info['first_block'] = fv.first_block()
        t_image_info['block_size'] = fv.block_count()
        t_image_info['ftype'] = fv.ftype()
        t_image_info['ftype_str'] = fv.ftype_str()

        FiwalkReport.numPartitions += 1

        glb_image_info.append({
                  prtn_info_items[0]:t_image_info['partition_offset'],\
                  prtn_info_items[1]:t_image_info['block_count'], \
                  prtn_info_items[2]:t_image_info['first_block'], \
                  prtn_info_items[3]:t_image_info['last_block'], \
                  prtn_info_items[4]:t_image_info['block_size'], \
                  prtn_info_items[5]:t_image_info['ftype'],  \
                  prtn_info_items[6]:t_image_info['ftype_str']})

    xmlfile = open(fn, 'rb')
    '''
    ## NOTE: Originally we mandated the xml file to end with .xml
    ## Code retained for reference and context
    # Currently we support taking only xml file as input. The following
    # check is for future enhancement.
    if fn.endswith('xml'):
        r = fiwalk.fiwalk_vobj_using_sax(xmlfile=open(fn, 'rb'),callback=cbv)
        image_info['image_filename'] = r.imageobject._tags['image_filename']
        image_info['partitions'] = str(FiwalkReport.numPartitions)
      
    else:
        # We use this call if we're processing a disk image
        print("Warning: Expected an XML File ")
    '''
    r = fiwalk.fiwalk_vobj_using_sax(xmlfile=open(fn, 'rb'), callback=cbv)
    image_info['image_filename'] = r.imageobject._tags['image_filename']
    image_info['partitions'] = str(FiwalkReport.numPartitions)
コード例 #2
0
ファイル: bc_genrep_dfxml.py プロジェクト: cy-fir/bitcurator
def bc_get_volume_info_from_sax(FiwalkReport, fn, image_info, prtn_info_items, glb_image_info):

    #
    # Callback function to process the SAX stream for volume object
    #
    def cbv(fv):
        t_image_info['partition_offset'] = fv.partition_offset()
        t_image_info['block_count'] = fv.block_count()
        t_image_info['last_block'] = fv.last_block()
        t_image_info['first_block'] = fv.first_block()
        t_image_info['block_size'] = fv.block_count()
        t_image_info['ftype'] = fv.ftype()
        t_image_info['ftype_str'] = fv.ftype_str()

        FiwalkReport.numPartitions +=1;

        glb_image_info.append({
                  prtn_info_items[0]:t_image_info['partition_offset'],\
                  prtn_info_items[1]:t_image_info['block_count'], \
                  prtn_info_items[2]:t_image_info['first_block'], \
                  prtn_info_items[3]:t_image_info['last_block'], \
                  prtn_info_items[4]:t_image_info['block_size'], \
                  prtn_info_items[5]:t_image_info['ftype'],  \
                  prtn_info_items[6]:t_image_info['ftype_str']}) 

    xmlfile = open(fn, 'rb')

    '''
    ## NOTE: Originally we mandated the xml file to end with .xml
    ## Code retained for reference and context
    # Currently we support taking only xml file as input. The following
    # check is for future enhancement.
    if fn.endswith('xml'):
        r = fiwalk.fiwalk_vobj_using_sax(xmlfile=open(fn, 'rb'),callback=cbv)
        image_info['image_filename'] = r.imageobject._tags['image_filename']
        image_info['partitions'] = str(FiwalkReport.numPartitions)
      
    else:
        # We use this call if we're processing a disk image
        print("Warning: Expected an XML File ")
    '''
    r = fiwalk.fiwalk_vobj_using_sax(xmlfile=open(fn, 'rb'),callback=cbv)
    image_info['image_filename'] = r.imageobject._tags['image_filename']
    image_info['partitions'] = str(FiwalkReport.numPartitions)
コード例 #3
0
def bc_process_xmlfile_using_sax(FiwalkReport, fn, image_info):

    #
    # Callback function to process the SAX stream for volume object
    #
    def cbv(fv):
        image_info['partition_offset'] = fv.partition_offset()
        image_info['block_count'] = fv.block_count()
        image_info['last_block'] = fv.last_block()
        image_info['first_block'] = fv.first_block()
        image_info['block_size'] = fv.block_count()
        image_info['ftype'] = fv.ftype()
        image_info['ftype_str'] = fv.ftype_str()
        
        ## print("DEBUG: VolumeObject:", fv)    
        ## print("DEBUG: Image Fileinfo: ", image_info)

    #
    # Callback function to process the SAX stream for file object
    #
    def cb(fi):
        # Form a list of dictionaries of the file attributes from the
        # xml file. Each dictionary represents one file (FiwalkReport.fiDictList)

        bc_make_dict(fi, FiwalkReport, fn)

    xmlfile = open(fn, 'rb')

    # Currently we support taking only xml file as input. The following
    # check is for future enhancement.
    if fn.endswith('xml'):
        # We use this call if we're processing a fiwalk XML fle
        fiwalk.fiwalk_using_sax(xmlfile=open(fn, 'rb'),callback=cb)
        r = fiwalk.fiwalk_vobj_using_sax(xmlfile=open(fn, 'rb'),callback=cbv)
        image_info['image_filename'] = r.imageobject._tags['image_filename']
    else:
        # We use this call if we're processing a disk image
        fiwalk.fiwalk_using_sax(imagefile=open(fn, 'rb'),callback=cb)
コード例 #4
0
 def bc_get_ftype_from_sax(self, dfxmlfile):
     fiwalk.fiwalk_vobj_using_sax(xmlfile=open(dfxmlfile, 'rb'),callback=self.cbv_ftype)
コード例 #5
0
ファイル: bc_disk_access.py プロジェクト: cy-fir/bitcurator
 def bc_get_ftype_from_sax(self, dfxmlfile):
     fiwalk.fiwalk_vobj_using_sax(xmlfile=open(dfxmlfile, 'rb'),callback=self.cbv_ftype)