Skip to content

Commit

Permalink
sql error
Browse files Browse the repository at this point in the history
  • Loading branch information
kopolindo committed Mar 28, 2018
1 parent e652b20 commit 681483a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
26 changes: 16 additions & 10 deletions db/populate.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,25 @@ func CveSearch(cve string) {
db := OpenDB()
fmt.Println("Looking for: ", cve)
// query
rows, err := db.Query("SELECT * FROM cve where id = \"?\"", cve)
rows, err := db.Query("SELECT * FROM cve where id = '?'", cve)
if err != nil {
fmt.Println("SQLite ERROR during \"Execution\" process: ", err)
}
defer rows.Close()
fmt.Println(rows)
var id string
var cveDescription string
var cwe string
var cweDescription string
var refs string
var cvssv2 string
var cvssv3 string
fmt.Printf("%#v", rows)
var (
id string
cveDescription string
cwe string
cweDescription string
refs string
cvssv2 string
cvssv3 string
exploit int
)

for rows.Next() {
err = rows.Scan(&id, &cveDescription, &cwe, &cweDescription, &refs, &cvssv2, &cvssv3)
err = rows.Scan(&id, &cveDescription, &cwe, &cweDescription, &exploit, &refs, &cvssv2, &cvssv3)
if err != nil {
fmt.Println("ROW SCANNING ERROR: ", err)
}
Expand All @@ -98,6 +101,9 @@ func CveSearch(cve string) {
fmt.Println(cvssv2)
fmt.Println(cvssv3)
}
if rows.Err() != nil {
fmt.Println(rows.Err())
}
}

func Populate() {
Expand Down
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ func Init() {
func validateCve() string {
cveRegexp := regexp.MustCompile("[0-9]+")
regexpArray := cveRegexp.FindAllString(*cve, -1)
if len(regexpArray) == 0 || len(regexpArray[0]) < 5 {
cve := strings.Join(regexpArray, "")
fmt.Println(cve)
if len(cve) < 5 {
fmt.Println("Please, insert at least year (YYYY) and ID number")
Usage()
os.Exit(71)
}
cve := strings.Join(regexpArray, "")
id := cve[4:]
//TODO aggiustare padding
for i := len(id); i < 4; i++ {
id = "0" + id
}
Expand Down

0 comments on commit 681483a

Please sign in to comment.