From 81bfa0bbd8bf352d9b65f05183cd4affa9581a1f Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Wed, 23 Mar 2016 20:19:39 -0700 Subject: [PATCH] Add ctparsewatch It watches for certificates which we can't fully parse --- cmd/ctparsewatch/.gitignore | 1 + cmd/ctparsewatch/main.go | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 cmd/ctparsewatch/.gitignore create mode 100644 cmd/ctparsewatch/main.go diff --git a/cmd/ctparsewatch/.gitignore b/cmd/ctparsewatch/.gitignore new file mode 100644 index 0000000..83a544e --- /dev/null +++ b/cmd/ctparsewatch/.gitignore @@ -0,0 +1 @@ +/ctparsewatch diff --git a/cmd/ctparsewatch/main.go b/cmd/ctparsewatch/main.go new file mode 100644 index 0000000..bd180c1 --- /dev/null +++ b/cmd/ctparsewatch/main.go @@ -0,0 +1,40 @@ +package main + +import ( + "flag" + "os" + + "src.agwa.name/ctwatch" + "src.agwa.name/ctwatch/ct" + "src.agwa.name/ctwatch/cmd" +) + +func DefaultStateDir () string { + if envVar := os.Getenv("CTPARSEWATCH_STATE_DIR"); envVar != "" { + return envVar + } else { + return cmd.DefaultStateDir("ctparsewatch") + } +} + +var stateDir = flag.String("state_dir", DefaultStateDir(), "Directory for storing state") + +func processEntry (scanner *ctwatch.Scanner, entry *ct.LogEntry) { + info := ctwatch.EntryInfo{ + LogUri: scanner.LogUri, + Entry: entry, + IsPrecert: ctwatch.IsPrecert(entry), + FullChain: ctwatch.GetFullChain(entry), + } + + info.CertInfo, info.ParseError = ctwatch.MakeCertInfoFromLogEntry(entry) + + if info.HasParseErrors() { + cmd.LogEntry(&info) + } +} + +func main() { + flag.Parse() + cmd.Main(*stateDir, processEntry) +}