Skip to content

Commit

Permalink
cert and connection analyzer publish their findings to compliance ana…
Browse files Browse the repository at this point in the history
…lyzers for further inspection
  • Loading branch information
0xdiba committed Apr 28, 2015
1 parent 0c7ee4c commit cd9503b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/certAnalyzer/analyserPool.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import (

const rxQueue = "cert_scan_results_queue"
const rxRoutKey = "cert_scan_results"
const analyzerQueue = "cert_analysis_queue"
const analyzerRoutKey = "cert_analysis"
const esIndex = "observer"
const esinfoType = "certificate"
const esrawType = "certificateRaw"
Expand Down Expand Up @@ -391,6 +393,12 @@ func pushCertificate(id string, c certificate.Certificate, certRaw []byte) {

_, err = es.Push(esIndex, esinfoType, id, jsonCert)
panicIf(err)

if err == nil {
err = broker.Publish(analyzerQueue, analyzerRoutKey, []byte(jsonCert))
panicIf(err)
}

}

//getCert tries to retrieve a stored certificate from the database.
Expand Down
26 changes: 20 additions & 6 deletions src/tlsAnalyzer/tlsAnalyser.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (

const rxQueue = "conn_scan_results_queue"
const rxRoutKey = "conn_scan_results"
const analyzerQueue = "conn_analysis_queue"
const analyzerRoutKey = "conn_analysis"
const esIndex = "observer"
const esType = "connection"

var broker *amqpmodule.Broker

//the 2 following structs represent the cipherscan output.

func failOnError(err error, msg string) {
if err != nil {
log.Fatalf("%s: %s", msg, err)
Expand Down Expand Up @@ -133,7 +133,7 @@ func updateAndPushConnections(newconn connection.Stored, conns map[string]connec
jsonConn, err := json.Marshal(conn)

if err == nil {
_, err = es.Push(esIndex, esType, "", jsonConn)
_, err = pushConnection("", jsonConn)
}

break
Expand All @@ -150,7 +150,7 @@ func updateAndPushConnections(newconn connection.Stored, conns map[string]connec
break
}

obsID, err = es.Push(esIndex, esType, "", jsonConn)
obsID, err = pushConnection("", jsonConn)

if err != nil {
break
Expand All @@ -160,7 +160,7 @@ func updateAndPushConnections(newconn connection.Stored, conns map[string]connec

jsonConn, err = json.Marshal(conn)

obsID, err = es.Push(esIndex, esType, id, jsonConn)
obsID, err = pushConnection(id, jsonConn)
}
}
}
Expand All @@ -171,14 +171,28 @@ func updateAndPushConnections(newconn connection.Stored, conns map[string]connec
jsonConn, err := json.Marshal(newconn)

if err == nil {
_, err = es.Push(esIndex, esType, "", jsonConn)
_, err = pushConnection("", jsonConn)
}

}

return err
}

func pushConnection(ID string, doc []byte) (string, error) {

newID, err := es.Push(esIndex, esType, ID, doc)

if err == nil {
err = broker.Publish(analyzerQueue, analyzerRoutKey, []byte(doc))
} else {
newID = ""
}

return newID, err

}

func printIntro() {
fmt.Println(`
##################################
Expand Down

0 comments on commit cd9503b

Please sign in to comment.