richardlehane / siegfried

signature-based file format identification
http://www.itforarchivists.com/siegfried
Apache License 2.0
224 stars 30 forks source link

roy inspect custom signatures #108

Closed ross-spencer closed 6 years ago

ross-spencer commented 6 years ago

Hi Richard,

I tried to inspect this following custom signature I added using Roy (the signature is for identifying HFS disk images):

    <?xml version="1.0" encoding="UTF-8"?>
    <FFSignatureFile xmlns="http://www.nationalarchives.gov.uk/pronom/SignatureFile" Version="1" DateCreated="2017-10-25T11:10:16+01:00">
      <InternalSignatureCollection>
      <InternalSignature ID="1" Specificity="Specific">
      <ByteSequence Reference="BOFoffset">
        <SubSequence MinFragLength="23" Position="1" SubSeqMaxOffset="1024" SubSeqMinOffset="1024">
          <Sequence>000000</Sequence>
          <DefaultShift>4</DefaultShift>
          <Shift Byte="00">1</Shift>
          <LeftFragment MaxOffset="0" MinOffset="0" Position="1">02</LeftFragment>
          <LeftFragment MaxOffset="0" MinOffset="0" Position="1">08</LeftFragment>
          <LeftFragment MaxOffset="0" MinOffset="0" Position="2">0000</LeftFragment>
          <LeftFragment MaxOffset="4" MinOffset="4" Position="3">0003</LeftFragment>
          <LeftFragment MaxOffset="1" MinOffset="1" Position="4">0000</LeftFragment>
          <LeftFragment MaxOffset="0" MinOffset="0" Position="5">01</LeftFragment>
          <LeftFragment MaxOffset="0" MinOffset="0" Position="5">08</LeftFragment>
          <LeftFragment MaxOffset="8" MinOffset="8" Position="6">4244</LeftFragment>
          <RightFragment MaxOffset="1" MinOffset="1" Position="1">0000</RightFragment>
          <RightFragment MaxOffset="1" MinOffset="1" Position="2">0000</RightFragment>
        </SubSequence>
      </ByteSequence>
    </InternalSignature>
    </InternalSignatureCollection>
    <FileFormatCollection>
      <FileFormat ID="1" Name="HFS-Dev-Sig-3" PUID="hfs/1" Version="1.0" MIMEType="application/hfs">
        <InternalSignatureID>1</InternalSignatureID>
        <Extension>img</Extension>
      </FileFormat>
    </FileFormatCollection></FFSignatureFile>

Should that be possible at all? - Currently in Linux I just get a blank line output. (The signature works well in Siegfried).

richardlehane commented 6 years ago

Hi Ross, tldr try a command like: roy inspect -extend hfs-dev-sig-3.xml hfs/1

Long version: when you use roy inspect to inspect formats it uses as input the source XML files (normally the droid XML file and/or the harvested PRONOM XML files) rather than your compiled signature (.sig) file. (This is because once signatures are compiled they are kind of shredded up for inserting in the search trees & pretty difficult to reconstruct). So to inspect a custom signature you need to use the same -extend or -extendc flags (if a container signature) you would use to build the signature file in order to tell roy where it can find your custom source file.

E.g. like:

image

richardlehane commented 6 years ago

p.s. I'll make a change for the next release so that if roy can't find anything to inspect, rather than a blank line, it will return a more meaningful message like "I can't inspect {user input}! See roy inspect -help"

ross-spencer commented 6 years ago

Thanks Richard - that would work well.

On Thu, Nov 2, 2017 at 12:25 PM, Richard Lehane notifications@github.com wrote:

p.s. I'll make a change for the next release so that if roy can't find anything to inspect, rather than a blank line, it will return a more meaningful message like "I can't inspect {user input}! See roy inspect -help"

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/richardlehane/siegfried/issues/108#issuecomment-341273016, or mute the thread https://github.com/notifications/unsubscribe-auth/AByxXBoJYqLpwZEZtRYZyFklX7Sl-eAVks5syP38gaJpZM4QNy5_ .