@@ -179,7 +179,7 @@ func main() {
179
179
if err != nil {
180
180
log .Fatal ("Queue processed" )
181
181
}
182
- processFile (jsonPath )
182
+ processFile (c . certPath , jsonPath )
183
183
184
184
// Exit Signal Handle
185
185
select {
@@ -202,7 +202,7 @@ func main() {
202
202
for _ , f := range files {
203
203
path [1 ] = f .Name ()
204
204
jsonPath = strings .Join (path , "/" )
205
- processFile (jsonPath )
205
+ processFile (c . certPath , jsonPath )
206
206
207
207
// Exit Signal Handle
208
208
select {
@@ -214,7 +214,7 @@ func main() {
214
214
}
215
215
}
216
216
217
- func processFile (p string ) bool {
217
+ func processFile (fp string , p string ) bool {
218
218
// read corresponding json file
219
219
dat , err := ioutil .ReadFile (p )
220
220
if err != nil {
@@ -243,7 +243,7 @@ func processFile(p string) bool {
243
243
session := buildChain (& s )
244
244
245
245
// Insert Certificates
246
- idc , err := insertCertificates (session )
246
+ idc , err := insertCertificates (fp , session )
247
247
if err != nil {
248
248
log .Fatal (fmt .Sprintf ("Insert Certificate into DB failed: %q" , err ))
249
249
}
@@ -429,9 +429,9 @@ func unique(s []certMapElm) []certMapElm {
429
429
return list
430
430
}
431
431
432
- func insertCertificate (c certMapElm ) (string , error ) {
432
+ func insertCertificate (fp string , c certMapElm ) (string , error ) {
433
433
q := `INSERT INTO "certificate" (hash, "is_CA", "is_SS", issuer, subject, cert_chain, is_valid_chain, file_path) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT DO NOTHING`
434
- _ , err := db .Exec (q , c .CertHash , c .Certificate .IsCA , c .chain .isSS , c .Certificate .Issuer .String (), c .Certificate .Subject .String (), c .chain .s , c .chain .isValid , getFullPath (c .CertHash ))
434
+ _ , err := db .Exec (q , c .CertHash , c .Certificate .IsCA , c .chain .isSS , c .Certificate .Issuer .String (), c .Certificate .Subject .String (), c .chain .s , c .chain .isValid , getFullPath (fp , c .CertHash ))
435
435
if err != nil {
436
436
return c .CertHash , err
437
437
}
@@ -451,14 +451,14 @@ func insertCertificate(c certMapElm) (string, error) {
451
451
452
452
// getFullPath takes a certificate's hash and return the full path to
453
453
// its location on disk
454
- func getFullPath (h string ) string {
455
- return "TODO PATH"
454
+ func getFullPath (c string , h string ) string {
455
+ return c + h
456
456
}
457
457
458
- func insertCertificates (s * sessionRecord ) ([]string , error ) {
458
+ func insertCertificates (fp string , s * sessionRecord ) ([]string , error ) {
459
459
var inserted []string
460
460
for _ , certificate := range s .Certificates {
461
- tmp , err := insertCertificate (certificate )
461
+ tmp , err := insertCertificate (fp , certificate )
462
462
inserted = append (inserted , tmp )
463
463
if err != nil {
464
464
return inserted , err
0 commit comments