From 399de2651b9ae515825eb9a261fe87a213274de1 Mon Sep 17 00:00:00 2001 From: myon Date: Fri, 18 Jul 2008 16:16:01 +0000 Subject: [PATCH] add/update some intestesting scripts git-svn-id: svn://svn.debian.org/pgp-tools/trunk@392 b513b33f-fedd-0310-b452-c3deb5f4c849 --- keyanalyze/scripts/htmlify_report | 53 ++++++++++++++++++ keyanalyze/scripts/top50.pl | 91 ++++++++++++++++++++++--------- 2 files changed, 118 insertions(+), 26 deletions(-) create mode 100755 keyanalyze/scripts/htmlify_report diff --git a/keyanalyze/scripts/htmlify_report b/keyanalyze/scripts/htmlify_report new file mode 100755 index 0000000..c110287 --- /dev/null +++ b/keyanalyze/scripts/htmlify_report @@ -0,0 +1,53 @@ +#!/usr/bin/perl -w + +use strict; +use Getopt::Std; + +my %options; +getopts('k:', \%options); +my $keyring = $options{k} ? "--no-default-keyring --keyring=$options{k}" : ""; +my %UID; + +sub get_uid { + my $key = shift; + return $UID{$key} if $UID{$key}; + open G, "gpg --list-key --fixed-list-mode --with-colon $keyring $key |" or die "gpg: $!"; + while() { + next unless /^uid:[-qmfue]::::\d*::[\dA-F]*::(.+):$/; + my $name = $1; + $name =~ s//>/g; + $name =~ s/\@/@/g; + close G; + return $UID{$key} = $name; + } + close G; +} + +sub uid_link { + my $key = shift; + #$key =~ /^([\dA-F]{2})/; + #return "$key"; + return "$key"; +} + +for my $file (@ARGV) { + #print STDERR "$file...\n"; + open F, "$file" or die "$file: $!"; + open H, ">$file.html" or die "$file.html: $!"; + print H < + + +$file + + +
+EOF
+	while() {
+		next if /^(This individual|report at)/;
+		s/([\dA-F]{8})$/uid_link($1)." ".get_uid($1);/e;
+		print H;
+	}
+	print H "
\n\n"; +} diff --git a/keyanalyze/scripts/top50.pl b/keyanalyze/scripts/top50.pl index 0bfe47f..5a30de6 100755 --- a/keyanalyze/scripts/top50.pl +++ b/keyanalyze/scripts/top50.pl @@ -1,33 +1,72 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w # this short script is for making the HTML for the top50 report monthly # Copyright (c)2001 M. Drew Streib # This code is released under the GPL version 2 or later. -# NOTE: this is designed to be run one directory up, from analyze.sh - -while ($line = ) { - $line =~ /\s+(\d+)\s+((\w|\d)+)\s+((\w|\d)+)\s+((\d|\.)+)/; - $rank = $1; - $key0 = $2; - $key = $4; - $msd = $6; - $command = 'wget -O - -q "http://pgp.dtype.org:11371/pks/lookup?search=0x' - .$key.'&op=index"'; - $wget = `$command`; - $command = 'grep "'.$key.'" scripts/top50comments.txt'; - $rawcomments = `$command`; - if (!($wget =~ /\d\d\d\d\/\d\d\/\d\d (.*)( \<.*)\n/)) { - $wget =~ /\d\d\d\d\/\d\d\/\d\d (.*)/; - $name = $1; - } - else { - $name = $1; +# 2004-09-14: modifications by Christoph Berg : +# * use perl to read top50comments.txt +# * use gpg --list-key instead of wget +# * use strict & warnings + +# 2008-07-18: modifications by Christoph Berg : +# * directly read msd.txt instead of a -sorted variant + +use strict; +use Getopt::Std; + +#my $keyserver = "http://pks.gpg.cz:11371/pks/lookup?op=vindex&fingerprint=on&search=0x"; +#my $keyserver = "http://keyserver.noreply.org/pks/lookup?op=index&fingerprint=on&search=0x"; +my $keyserver = "http://subkeys.pgp.net:11371/pks/lookup?op=index&fingerprint=on&search=0x"; +my %options; +getopts('c:k:n:', \%options); +my $comments = $options{c} || "top50comments.txt"; +my $keyring = $options{k} ? "--no-default-keyring --keyring=$options{k}" : ""; +my $top = $options{n} || 50; + +my %comment; +if (open F, $comments) { + while() { + die "$comments.$.: syntax error" unless /([\dA-F]+)\b ?(.*)/; + $comment{$1} = $2; } - if ($rawcomments) { - $rawcomments =~ /(\w|\d)+\s(.*)/; - $comments = $2; - } else { - $comments = ''; + close F; +} + +my %msd; +while (my $line = <>) { + $line =~ /^\w+\s+(\w+)\s+([\d\.]+)/ or die "cannot parse line $.: $_"; + $msd{$1} = $2; +} + +print "\n"; +print "\n"; + +my $oldmsd = 0; +my $i = 1; +foreach my $key (sort { $msd{$a} <=> $msd{$b} } keys %msd) { + my $rank = ""; + if($oldmsd != $msd{$key}) { + $rank = $i++; } - print "\n"; + last if $rank and $rank > $top; + $oldmsd = $msd{$key}; + my $name = ""; + open G, "gpg --list-key --fixed-list-mode --with-colon --trust-model always $keyring $key |" or die "gpg: $!"; + while() { + #uid:u::::1082202576::1DC0BEA2AC64671CC902D50B8121F6E4E6336E15::Christoph Berg : + next unless /^uid:[-qmfue]::::\d*::[\dA-F]*::(.+):$/; + $name = $1; + $name =~ s//>/g; + $name =~ s/\@/@/g; + last; + } + close G; + my $comment = $comment{$key} || ""; + $key =~ /^([\dA-F]{2})/; + #my $prefix = $1; + #print "\n"; + print "\n"; } + +print "
#IdNameMSD
$rank$key$name$comments$msd
$rank$key keyserver$name$comment$msd
$rank$keykeyserver$name $comment$msd{$key}
\n"; -- 2.30.2