Skip to content

Commit 4b37ae1

Browse files
committed
tmp path fix to perform tests
1 parent a5d8551 commit 4b37ae1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

main.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func main() {
179179
if err != nil {
180180
log.Fatal("Queue processed")
181181
}
182-
processFile(jsonPath)
182+
processFile(c.certPath, jsonPath)
183183

184184
// Exit Signal Handle
185185
select {
@@ -202,7 +202,7 @@ func main() {
202202
for _, f := range files {
203203
path[1] = f.Name()
204204
jsonPath = strings.Join(path, "/")
205-
processFile(jsonPath)
205+
processFile(c.certPath, jsonPath)
206206

207207
// Exit Signal Handle
208208
select {
@@ -214,7 +214,7 @@ func main() {
214214
}
215215
}
216216

217-
func processFile(p string) bool {
217+
func processFile(fp string, p string) bool {
218218
// read corresponding json file
219219
dat, err := ioutil.ReadFile(p)
220220
if err != nil {
@@ -243,7 +243,7 @@ func processFile(p string) bool {
243243
session := buildChain(&s)
244244

245245
// Insert Certificates
246-
idc, err := insertCertificates(session)
246+
idc, err := insertCertificates(fp, session)
247247
if err != nil {
248248
log.Fatal(fmt.Sprintf("Insert Certificate into DB failed: %q", err))
249249
}
@@ -429,9 +429,9 @@ func unique(s []certMapElm) []certMapElm {
429429
return list
430430
}
431431

432-
func insertCertificate(c certMapElm) (string, error) {
432+
func insertCertificate(fp string, c certMapElm) (string, error) {
433433
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))
435435
if err != nil {
436436
return c.CertHash, err
437437
}
@@ -451,14 +451,14 @@ func insertCertificate(c certMapElm) (string, error) {
451451

452452
// getFullPath takes a certificate's hash and return the full path to
453453
// 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
456456
}
457457

458-
func insertCertificates(s *sessionRecord) ([]string, error) {
458+
func insertCertificates(fp string, s *sessionRecord) ([]string, error) {
459459
var inserted []string
460460
for _, certificate := range s.Certificates {
461-
tmp, err := insertCertificate(certificate)
461+
tmp, err := insertCertificate(fp, certificate)
462462
inserted = append(inserted, tmp)
463463
if err != nil {
464464
return inserted, err

0 commit comments

Comments
 (0)