← Back to team overview

launchpad-dev team mailing list archive

question re. canonical.launchpad.mail.signed_message_from_string

 

Hello there!

I came across this yesterday: when the text in question has no GPG/PGP
signature the value of 'signedContent' may not be what you expect i.e.
it is None:

{{{
CHROOT unembargo-email-316488 $ make harness
bin/harness
execute_zcml_for_scripts()...
xmlconfig.file()...
Reading $PYTHONSTARTUP...
Initializing storm...
Creating the factory...

>>> from canonical.launchpad.mail import (
...     format_address, signed_message_from_string, sendmail)
>>> changes = '''
... Format: 1.7
... Date: Thu, 16 Feb 2006 15:34:09 +0000
... Source: foocomm
... Binary: foocomm
... Architecture: i386
... Version: 1.0-2
... Distribution: breezy
... Urgency: low
... Maintainer: Launchpad team <launchpad@xxxxxxxxxxxxxxxxxxx>
... Changed-By: Foo Bar <foo.bar@xxxxxxxxxxxxx>
... Description:
...  foocomm    - Stuff for testing
... Changes:
...  foocomm (1.0-2) breezy; urgency=low
...  .
...    * Initial version
... Files:
...  4179d951890fc16560b0c16b617cc98e 650 partner/devel optional
foocomm_1.0-2_i386.deb
... '''
>>> signed_message = signed_message_from_string(changes)
>>> signed_message
<lp.services.mail.signedmessage.SignedMessage instance at 0x5fa2b48>
>>> signed_message.signedContent
>>> signed_message.signedContent is None
True
>>> t2 = '''
... -----BEGIN PGP SIGNED MESSAGE-----
... Hash: SHA1
...
... Format: 1.7
... Date: Thu, 16 Feb 2006 15:34:09 +0000
... Source: foocomm
... Binary: foocomm
... Architecture: i386
... Version: 1.0-1
... Distribution: breezy
... Urgency: low
... Maintainer: Launchpad team <launchpad@xxxxxxxxxxxxxxxxxxx>
... Changed-By: Foo Bar <foo.bar@xxxxxxxxxxxxx>
... Description:
...  foocomm    - Stuff for testing
... Changes:
...  foocomm (1.0-1) breezy; urgency=low
...  .
...    * Initial version
... Files:
...  ecb7561590c70633ebb9fb9bffbd2298 650 partner/devel optional
foocomm_1.0-1_i386.deb
...
... -----BEGIN PGP SIGNATURE-----
... Version: GnuPG v1.4.6 (GNU/Linux)
...
... iD8DBQFG2+mzjn63CGxkqMURAsyaAJkBQFdIW3guOPZvHXhwK7kGuWg94gCdFqp1
... 5VkiTVKeY+GiHsmSywGUs2Q=
... =urSl
... -----END PGP SIGNATURE-----
... '''
>>> sm2 = signed_message_from_string(t2)
>>> sm2.signedContent is None
False
>>> sm2.signedContent
'Format: 1.7\nDate: Thu, 16 Feb 2006 15:34:09 +0000\nSource:
foocomm\nBinary: foocomm\nArchitecture: i386\nVersion:
1.0-1\nDistribution: breezy\nUrgency: low\nMaintainer: Launchpad team
<launchpad@xxxxxxxxxxxxxxxxxxx>\nChanged-By: Foo Bar
<foo.bar@xxxxxxxxxxxxx>\nDescription: \n foocomm    - Stuff for
testing\nChanges: \n foocomm (1.0-1) breezy; urgency=low\n .\n   *
Initial version\nFiles: \n ecb7561590c70633ebb9fb9bffbd2298 650
partner/devel optional foocomm_1.0-1_i386.deb\n'
}}}

Related question: do we have a regex or some other "standard" way of
checking whether a text is GPG/PGP signed?

Best regards

-- 
Muharem Hrnjadovic <muharem@xxxxxxxxxx>
Public key id   : B2BBFCFC
Key fingerprint : A5A3 CC67 2B87 D641 103F  5602 219F 6B60 B2BB FCFC

Attachment: signature.asc
Description: OpenPGP digital signature


Follow ups