[Pgp-tools-commit] r392 - trunk/keyanalyze/scripts

myon at alioth.debian.org myon at alioth.debian.org
Fri Jul 18 16:16:02 UTC 2008


Author: myon
Date: 2008-07-18 16:16:01 +0000 (Fri, 18 Jul 2008)
New Revision: 392

Added:
   trunk/keyanalyze/scripts/htmlify_report
Modified:
   trunk/keyanalyze/scripts/top50.pl
Log:
add/update some intestesting scripts


Added: trunk/keyanalyze/scripts/htmlify_report
===================================================================
--- trunk/keyanalyze/scripts/htmlify_report	                        (rev 0)
+++ trunk/keyanalyze/scripts/htmlify_report	2008-07-18 16:16:01 UTC (rev 392)
@@ -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";
+}


Property changes on: trunk/keyanalyze/scripts/htmlify_report
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/keyanalyze/scripts/top50.pl
===================================================================
--- trunk/keyanalyze/scripts/top50.pl	2008-07-18 13:42:10 UTC (rev 391)
+++ trunk/keyanalyze/scripts/top50.pl	2008-07-18 16:16:01 UTC (rev 392)
@@ -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
+# 2004-09-14: modifications by Christoph Berg <cb at df7cb.de>:
+#  * use perl to read top50comments.txt
+#  * use gpg --list-key instead of wget
+#  * use strict & warnings
 
-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 {
+# 2008-07-18: modifications by Christoph Berg <cb at 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;
+	}
+	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++;
+	}
+	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 at df7cb.de>:
+		next unless /^uid:[-qmfue]::::\d*::[\dA-F]*::(.+):$/;
 		$name = $1;
+		$name =~ s/</&lt;/g;
+		$name =~ s/>/&gt;/g;
+		$name =~ s/\@/&#64;/g;
+		last;
 	}
-	if ($rawcomments) {
-		$rawcomments =~ /(\w|\d)+\s(.*)/;
-		$comments = $2;
-	} else {
-		$comments = '';
-	}
-	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";
+	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";




More information about the Pgp-tools-commit mailing list