add/update some intestesting scripts
authormyon <myon@b513b33f-fedd-0310-b452-c3deb5f4c849>
Fri, 18 Jul 2008 16:16:01 +0000 (16:16 +0000)
committermyon <myon@b513b33f-fedd-0310-b452-c3deb5f4c849>
Fri, 18 Jul 2008 16:16:01 +0000 (16:16 +0000)
git-svn-id: svn://svn.debian.org/pgp-tools/trunk@392 b513b33f-fedd-0310-b452-c3deb5f4c849

keyanalyze/scripts/htmlify_report [new file with mode: 0755]
keyanalyze/scripts/top50.pl

diff --git a/keyanalyze/scripts/htmlify_report b/keyanalyze/scripts/htmlify_report
new file mode 100755 (executable)
index 0000000..c110287
--- /dev/null
@@ -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(<G>) {
+               next unless /^uid:[-qmfue]::::\d*::[\dA-F]*::(.+):$/;
+               my $name = $1;
+               $name =~ s/</&lt;/g;
+               $name =~ s/>/&gt;/g;
+               $name =~ s/\@/&#64;/g;
+               close G;
+               return $UID{$key} = $name;
+       }
+       close G;
+}
+
+sub uid_link {
+       my $key = shift;
+       #$key =~ /^([\dA-F]{2})/;
+       #return "<a href=\"../$1/$key.html\">$key</a>";
+       return "<a href=\"$key.html\">$key</a>";
+}
+
+for my $file (@ARGV) {
+       #print STDERR "$file...\n";
+       open F, "$file" or die "$file: $!";
+       open H, ">$file.html" or die "$file.html: $!";
+       print H <<EOF;
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<title>$file</title>
+</head>
+<body>
+<pre>
+EOF
+       while(<F>) {
+               next if /^(This individual|report at)/;
+               s/([\dA-F]{8})$/uid_link($1)." ".get_uid($1);/e;
+               print H;
+       }
+       print H "</pre>\n</body></html>\n";
+}
index 0bfe47f47d11095052248de9987afdc0075a845a..5a30de65b00e93539f1397e824dbb0ef1138d7b7 100755 (executable)
@@ -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 = <STDIN>) {
-       $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 (.*)( \&lt.*)\n/)) { 
-                       $wget =~ /\d\d\d\d\/\d\d\/\d\d (.*)/;
-                       $name = $1;
-               }
-       else {
-               $name = $1;
+# 2004-09-14: modifications by Christoph Berg <cb@df7cb.de>:
+#  * use perl to read top50comments.txt
+#  * use gpg --list-key instead of wget
+#  * use strict & warnings
+
+# 2008-07-18: modifications by Christoph Berg <cb@df7cb.de>:
+#  * 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(<F>) {
+               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 "<table>\n";
+print "<tr><th>#</th><th>Id</th><th></th><th>Name</th><th>MSD</th></tr>\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 "<TR><TD>$rank</TD><TD><A href=\"http://pgp.dtype.org:11371/pks/lookup?search=0x$key\&op=vindex\">$key</A></TD><TD>$name</TD><TD><I>$comments</I></TD><TD align=\"right\">$msd</TD></TR>\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(<G>) {
+               #uid:u::::1082202576::1DC0BEA2AC64671CC902D50B8121F6E4E6336E15::Christoph Berg <cb@df7cb.de>:
+               next unless /^uid:[-qmfue]::::\d*::[\dA-F]*::(.+):$/;
+               $name = $1;
+               $name =~ s/</&lt;/g;
+               $name =~ s/>/&gt;/g;
+               $name =~ s/\@/&#64;/g;
+               last;
+       }
+       close G;
+       my $comment = $comment{$key} || "";
+       $key =~ /^([\dA-F]{2})/;
+       #my $prefix = $1;
+       #print "<TR><TD align=\"right\">$rank</TD><TD><a href=\"$prefix/$key.html\">$key</a> <small><A href=\"$keyserver$key\">keyserver</A></small></TD><TD>$name</TD><TD><I>$comment</I></TD><TD align=\"right\">$msd</TD></TR>\n";
+       print "<TR><TD align=\"right\">$rank</TD><TD><a href=\"$key.html\">$key</a></TD><TD><small><A href=\"$keyserver$key\">keyserver</A></small></TD><TD>$name <I>$comment</I></TD><TD align=\"right\">$msd{$key}</TD></TR>\n";
 }
+
+print "</table>\n";