Rename project to certspotter

This commit is contained in:
Andrew Ayer 2016-05-04 11:49:07 -07:00
parent ea3db97486
commit 670cddafbc
16 changed files with 52 additions and 52 deletions

View File

@ -1,4 +1,4 @@
package ctwatch package certspotter
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package ctwatch package certspotter
import ( import (
"time" "time"

View File

@ -1,4 +1,4 @@
package ctwatch package certspotter
import ( import (
"testing" "testing"

View File

@ -1,7 +1,7 @@
package ctwatch package certspotter
import ( import (
"src.agwa.name/ctwatch/ct" "src.agwa.name/certspotter/ct"
"bytes" "bytes"
"crypto/sha256" "crypto/sha256"
) )

1
cmd/certspotter/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/certspotter

View File

@ -9,16 +9,16 @@ import (
"golang.org/x/net/idna" "golang.org/x/net/idna"
"src.agwa.name/ctwatch" "src.agwa.name/certspotter"
"src.agwa.name/ctwatch/ct" "src.agwa.name/certspotter/ct"
"src.agwa.name/ctwatch/cmd" "src.agwa.name/certspotter/cmd"
) )
func DefaultStateDir () string { func DefaultStateDir () string {
if envVar := os.Getenv("CTWATCH_STATE_DIR"); envVar != "" { if envVar := os.Getenv("CTWATCH_STATE_DIR"); envVar != "" {
return envVar return envVar
} else { } else {
return cmd.DefaultStateDir("ctwatch") return cmd.DefaultStateDir("certspotter")
} }
} }
@ -66,7 +66,7 @@ func setWatchDomains (domains []string) error {
} }
addWatchDomain("*" + parentDomain) addWatchDomain("*" + parentDomain)
addWatchDomain("?" + parentDomain) addWatchDomain("?" + parentDomain)
addWatchDomain(ctwatch.UnparsableDNSLabelPlaceholder + parentDomain) addWatchDomain(certspotter.UnparsableDNSLabelPlaceholder + parentDomain)
} }
} }
return nil return nil
@ -95,15 +95,15 @@ func anyDnsNameMatches (dnsNames []string) bool {
return false return false
} }
func processEntry (scanner *ctwatch.Scanner, entry *ct.LogEntry) { func processEntry (scanner *certspotter.Scanner, entry *ct.LogEntry) {
info := ctwatch.EntryInfo{ info := certspotter.EntryInfo{
LogUri: scanner.LogUri, LogUri: scanner.LogUri,
Entry: entry, Entry: entry,
IsPrecert: ctwatch.IsPrecert(entry), IsPrecert: certspotter.IsPrecert(entry),
FullChain: ctwatch.GetFullChain(entry), FullChain: certspotter.GetFullChain(entry),
} }
info.CertInfo, info.ParseError = ctwatch.MakeCertInfoFromLogEntry(entry) info.CertInfo, info.ParseError = certspotter.MakeCertInfoFromLogEntry(entry)
if info.CertInfo != nil { if info.CertInfo != nil {
info.Identifiers, info.IdentifiersParseError = info.CertInfo.ParseIdentifiers() info.Identifiers, info.IdentifiersParseError = info.CertInfo.ParseIdentifiers()

View File

@ -14,8 +14,8 @@ import (
"time" "time"
"strconv" "strconv"
"src.agwa.name/ctwatch" "src.agwa.name/certspotter"
"src.agwa.name/ctwatch/ct" "src.agwa.name/certspotter/ct"
) )
var batchSize = flag.Int("batch_size", 1000, "Max number of entries to request at per call to get-entries") var batchSize = flag.Int("batch_size", 1000, "Max number of entries to request at per call to get-entries")
@ -55,11 +55,11 @@ func DefaultStateDir (programName string) string {
} }
} }
func LogEntry (info *ctwatch.EntryInfo) { func LogEntry (info *certspotter.EntryInfo) {
if !*noSave { if !*noSave {
var alreadyPresent bool var alreadyPresent bool
var err error var err error
alreadyPresent, info.Filename, err = ctwatch.WriteCertRepository(filepath.Join(stateDir, "certs"), info.IsPrecert, info.FullChain) alreadyPresent, info.Filename, err = certspotter.WriteCertRepository(filepath.Join(stateDir, "certs"), info.IsPrecert, info.FullChain)
if err != nil { if err != nil {
log.Print(err) log.Print(err)
} }
@ -88,27 +88,27 @@ func saveEvidence (logUri string, firstSTH *ct.SignedTreeHead, secondSTH *ct.Sig
now := strconv.FormatInt(time.Now().Unix(), 10) now := strconv.FormatInt(time.Now().Unix(), 10)
firstFilename := filepath.Join(stateDir, "evidence", defangLogUri(logUri) + ".inconsistent." + now + ".first") firstFilename := filepath.Join(stateDir, "evidence", defangLogUri(logUri) + ".inconsistent." + now + ".first")
if err := ctwatch.WriteSTHFile(firstFilename, firstSTH); err != nil { if err := certspotter.WriteSTHFile(firstFilename, firstSTH); err != nil {
return "", "", "", err return "", "", "", err
} }
secondFilename := filepath.Join(stateDir, "evidence", defangLogUri(logUri) + ".inconsistent." + now + ".second") secondFilename := filepath.Join(stateDir, "evidence", defangLogUri(logUri) + ".inconsistent." + now + ".second")
if err := ctwatch.WriteSTHFile(secondFilename, secondSTH); err != nil { if err := certspotter.WriteSTHFile(secondFilename, secondSTH); err != nil {
return "", "", "", err return "", "", "", err
} }
proofFilename := filepath.Join(stateDir, "evidence", defangLogUri(logUri) + ".inconsistent." + now + ".proof") proofFilename := filepath.Join(stateDir, "evidence", defangLogUri(logUri) + ".inconsistent." + now + ".proof")
if err := ctwatch.WriteProofFile(proofFilename, proof); err != nil { if err := certspotter.WriteProofFile(proofFilename, proof); err != nil {
return "", "", "", err return "", "", "", err
} }
return firstFilename, secondFilename, proofFilename, nil return firstFilename, secondFilename, proofFilename, nil
} }
func Main (argStateDir string, processCallback ctwatch.ProcessCallback) { func Main (argStateDir string, processCallback certspotter.ProcessCallback) {
stateDir = argStateDir stateDir = argStateDir
var logs []ctwatch.LogInfo var logs []certspotter.LogInfo
if *logsFilename != "" { if *logsFilename != "" {
logFile, err := os.Open(*logsFilename) logFile, err := os.Open(*logsFilename)
if err != nil { if err != nil {
@ -116,16 +116,16 @@ func Main (argStateDir string, processCallback ctwatch.ProcessCallback) {
os.Exit(1) os.Exit(1)
} }
defer logFile.Close() defer logFile.Close()
var logFileObj ctwatch.LogInfoFile var logFileObj certspotter.LogInfoFile
if err := json.NewDecoder(logFile).Decode(&logFileObj); err != nil { if err := json.NewDecoder(logFile).Decode(&logFileObj); err != nil {
fmt.Fprintf(os.Stderr, "%s: Error decoding logs file: %s: %s\n", os.Args[0], *logsFilename, err) fmt.Fprintf(os.Stderr, "%s: Error decoding logs file: %s: %s\n", os.Args[0], *logsFilename, err)
os.Exit(1) os.Exit(1)
} }
logs = logFileObj.Logs logs = logFileObj.Logs
} else if *underwater { } else if *underwater {
logs = ctwatch.UnderwaterLogs logs = certspotter.UnderwaterLogs
} else { } else {
logs = ctwatch.DefaultLogs logs = certspotter.DefaultLogs
} }
if err := os.Mkdir(stateDir, 0777); err != nil && !os.IsExist(err) { if err := os.Mkdir(stateDir, 0777); err != nil && !os.IsExist(err) {
@ -159,20 +159,20 @@ func Main (argStateDir string, processCallback ctwatch.ProcessCallback) {
continue continue
} }
stateFilename := filepath.Join(stateDir, "sths", defangLogUri(logUri)) stateFilename := filepath.Join(stateDir, "sths", defangLogUri(logUri))
prevSTH, err := ctwatch.ReadSTHFile(stateFilename) prevSTH, err := certspotter.ReadSTHFile(stateFilename)
if err != nil { if err != nil {
log.Printf("Error reading state file: %s: %s\n", stateFilename, err) log.Printf("Error reading state file: %s: %s\n", stateFilename, err)
exitCode |= 1 exitCode |= 1
continue continue
} }
opts := ctwatch.ScannerOptions{ opts := certspotter.ScannerOptions{
BatchSize: *batchSize, BatchSize: *batchSize,
NumWorkers: *numWorkers, NumWorkers: *numWorkers,
ParallelFetch: *parallelFetch, ParallelFetch: *parallelFetch,
Quiet: !*verbose, Quiet: !*verbose,
} }
scanner := ctwatch.NewScanner(logUri, logKey, &opts) scanner := certspotter.NewScanner(logUri, logKey, &opts)
latestSTH, err := scanner.GetSTH() latestSTH, err := scanner.GetSTH()
if err != nil { if err != nil {
@ -201,7 +201,7 @@ func Main (argStateDir string, processCallback ctwatch.ProcessCallback) {
} }
if latestSTH.TreeSize > startIndex { if latestSTH.TreeSize > startIndex {
var treeBuilder *ctwatch.MerkleTreeBuilder var treeBuilder *certspotter.MerkleTreeBuilder
if prevSTH != nil { if prevSTH != nil {
var valid bool var valid bool
var err error var err error
@ -223,7 +223,7 @@ func Main (argStateDir string, processCallback ctwatch.ProcessCallback) {
continue continue
} }
} else { } else {
treeBuilder = &ctwatch.MerkleTreeBuilder{} treeBuilder = &certspotter.MerkleTreeBuilder{}
} }
if err := scanner.Scan(int64(startIndex), int64(latestSTH.TreeSize), processCallback, treeBuilder); err != nil { if err := scanner.Scan(int64(startIndex), int64(latestSTH.TreeSize), processCallback, treeBuilder); err != nil {
@ -244,7 +244,7 @@ func Main (argStateDir string, processCallback ctwatch.ProcessCallback) {
log.Printf("final log size = %d, final root hash = %x", latestSTH.TreeSize, latestSTH.SHA256RootHash) log.Printf("final log size = %d, final root hash = %x", latestSTH.TreeSize, latestSTH.SHA256RootHash)
} }
if err := ctwatch.WriteSTHFile(stateFilename, latestSTH); err != nil { if err := certspotter.WriteSTHFile(stateFilename, latestSTH); err != nil {
log.Printf("Error writing state file: %s: %s\n", stateFilename, err) log.Printf("Error writing state file: %s: %s\n", stateFilename, err)
exitCode |= 1 exitCode |= 1
continue continue

View File

@ -4,9 +4,9 @@ import (
"flag" "flag"
"os" "os"
"src.agwa.name/ctwatch" "src.agwa.name/certspotter"
"src.agwa.name/ctwatch/ct" "src.agwa.name/certspotter/ct"
"src.agwa.name/ctwatch/cmd" "src.agwa.name/certspotter/cmd"
) )
func DefaultStateDir () string { func DefaultStateDir () string {
@ -19,15 +19,15 @@ func DefaultStateDir () string {
var stateDir = flag.String("state_dir", DefaultStateDir(), "Directory for storing state") var stateDir = flag.String("state_dir", DefaultStateDir(), "Directory for storing state")
func processEntry (scanner *ctwatch.Scanner, entry *ct.LogEntry) { func processEntry (scanner *certspotter.Scanner, entry *ct.LogEntry) {
info := ctwatch.EntryInfo{ info := certspotter.EntryInfo{
LogUri: scanner.LogUri, LogUri: scanner.LogUri,
Entry: entry, Entry: entry,
IsPrecert: ctwatch.IsPrecert(entry), IsPrecert: certspotter.IsPrecert(entry),
FullChain: ctwatch.GetFullChain(entry), FullChain: certspotter.GetFullChain(entry),
} }
info.CertInfo, info.ParseError = ctwatch.MakeCertInfoFromLogEntry(entry) info.CertInfo, info.ParseError = certspotter.MakeCertInfoFromLogEntry(entry)
if info.CertInfo != nil { if info.CertInfo != nil {
info.Identifiers, info.IdentifiersParseError = info.CertInfo.ParseIdentifiers() info.Identifiers, info.IdentifiersParseError = info.CertInfo.ParseIdentifiers()
} }

View File

@ -1 +0,0 @@
/ctwatch

View File

@ -13,7 +13,7 @@ import (
"net/http" "net/http"
"time" "time"
"src.agwa.name/ctwatch/ct" "src.agwa.name/certspotter/ct"
"github.com/mreiferson/go-httpclient" "github.com/mreiferson/go-httpclient"
) )

View File

@ -1,4 +1,4 @@
package ctwatch package certspotter
import ( import (
"fmt" "fmt"
@ -17,7 +17,7 @@ import (
"encoding/pem" "encoding/pem"
"encoding/json" "encoding/json"
"src.agwa.name/ctwatch/ct" "src.agwa.name/certspotter/ct"
) )
func ReadSTHFile (path string) (*ct.SignedTreeHead, error) { func ReadSTHFile (path string) (*ct.SignedTreeHead, error) {

View File

@ -1,4 +1,4 @@
package ctwatch package certspotter
import ( import (
"bytes" "bytes"

View File

@ -1,4 +1,4 @@
package ctwatch package certspotter
import ( import (
"encoding/base64" "encoding/base64"

View File

@ -1,4 +1,4 @@
package ctwatch package certspotter
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package ctwatch package certspotter
import ( import (
// "container/list" // "container/list"
@ -10,8 +10,8 @@ import (
"crypto" "crypto"
"errors" "errors"
"src.agwa.name/ctwatch/ct" "src.agwa.name/certspotter/ct"
"src.agwa.name/ctwatch/ct/client" "src.agwa.name/certspotter/ct/client"
) )
type ProcessCallback func(*Scanner, *ct.LogEntry) type ProcessCallback func(*Scanner, *ct.LogEntry)

View File

@ -1,4 +1,4 @@
package ctwatch package certspotter
import ( import (
"fmt" "fmt"