summaryrefslogtreecommitdiffstats
path: root/ssllabs-scan.go
diff options
context:
space:
mode:
authorMatt Keller <m@cognusion.com>2014-11-07 08:09:52 -0500
committerMatt Keller <m@cognusion.com>2014-11-07 08:09:52 -0500
commitc5c69c26aa43c42f781f731dfe7540a5faab951b (patch)
tree18bb57bfa44847ce8911284d0b7771185344c48f /ssllabs-scan.go
parent110a5578e87d72478c42c88846645d69d029575d (diff)
parent344b096b582bb636a7002af5441e7b1f42076dd0 (diff)
downloadssllabs-scan-c5c69c26aa43c42f781f731dfe7540a5faab951b.zip
ssllabs-scan-c5c69c26aa43c42f781f731dfe7540a5faab951b.tar.gz
ssllabs-scan-c5c69c26aa43c42f781f731dfe7540a5faab951b.tar.bz2
Merge branch 'master' into feature-grade
Diffstat (limited to 'ssllabs-scan.go')
-rw-r--r--ssllabs-scan.go38
1 files changed, 25 insertions, 13 deletions
diff --git a/ssllabs-scan.go b/ssllabs-scan.go
index 8034372..7409aa4 100644
--- a/ssllabs-scan.go
+++ b/ssllabs-scan.go
@@ -62,6 +62,10 @@ var requestCounter uint64 = 0
var apiLocation = "https://api.dev.ssllabs.com/api/fa78d5a4/"
+var clearCache = true
+
+var fromCache = false
+
var httpClient *http.Client
type LabsError struct {
@@ -94,8 +98,8 @@ type LabsCert struct {
Subject string
CommonNames []string
AltNames []string
- NotBefore int
- NotAfter int
+ NotBefore uint64
+ NotAfter uint64
IssuerSubject string
SigAlg string
IssuerLabel string
@@ -170,7 +174,7 @@ type LabsSuites struct {
}
type LabsEndpointDetails struct {
- HostStartTime int
+ HostStartTime uint64
Key LabsKey
Cert LabsCert
Chain LabsChain
@@ -182,7 +186,7 @@ type LabsEndpointDetails struct {
VulnBeast bool
RenegSupport int
StsResponseHeader string
- StsMaxAge int
+ StsMaxAge uint64
StsSubdomains bool
PkpResponseHeader string
SessionResumption int
@@ -225,11 +229,11 @@ type LabsReport struct {
IsPublic bool
Status string
StatusMessage string
- StartTime int
- TestTime int
+ StartTime uint64
+ TestTime uint64
EngineVersion string
CriteriaVersion string
- CacheExpiryTime int
+ CacheExpiryTime int64
Endpoints []LabsEndpoint
CertHostnames []string
rawJSON string
@@ -377,10 +381,12 @@ func invokeInfo() (*LabsInfo, error) {
return &labsInfo, nil
}
-func invokeAnalyze(host string, clearCache bool) (*LabsReport, error) {
+func invokeAnalyze(host string, clearCache bool, fromCache bool) (*LabsReport, error) {
var command = "analyze?host=" + host + "&all=done"
- if clearCache {
+ if fromCache {
+ command = command + "&fromCache=on"
+ } else if clearCache {
command = command + "&clearCache=on"
}
@@ -431,18 +437,17 @@ func NewAssessment(host string, eventChannel chan Event) {
eventChannel <- Event{host, ASSESSMENT_STARTING, nil}
var report *LabsReport
- var clearCache = true
var startTime = -1
for {
- myResponse, err := invokeAnalyze(host, clearCache)
+ myResponse, err := invokeAnalyze(host, clearCache, fromCache)
if err != nil {
log.Fatalf("[ERROR] Assessment failed: %v", err)
}
- if clearCache == true {
- clearCache = false
+ if startTime == -1 {
startTime = myResponse.StartTime
+ clearCache = false
} else {
if myResponse.StartTime != startTime {
log.Fatalf("[ERROR] Inconsistent startTime. Expected %v, got %v.", startTime, myResponse.StartTime)
@@ -722,6 +727,7 @@ func main() {
var conf_json_flat = flag.Bool("json-flat", false, "Output results in flattened JSON format")
var conf_rawoutput = flag.Bool("rawoutput", false, "Print RAW JSON response")
var conf_hostfile = flag.String("hostfile", "", "File containing hosts to scan (one per line)")
+ var conf_usecache = flag.Bool("usecache", false, "If true, accept cached results (if available), else force live scan.")
var conf_grade = flag.Bool("grade", false, "Output only the hostname: grade")
flag.Parse()
@@ -732,6 +738,12 @@ func main() {
logLevel = LOG_NONE
}
+ // We prefer cached results
+ if *conf_usecache {
+ fromCache = true
+ clearCache = false
+ }
+
// Verify that the API entry point is a URL.
if *conf_api != "BUILTIN" {
apiLocation = *conf_api