func SetAsFalsePositive(id string) error {
	sql := `UPDATE vulnerabilities
			SET false_positive = TRUE
			WHERE id = $1`
	return db.Exec(sql, id)
}
SetAsFalsePositive sets the Vulnerability as a
false positive
package management
import (
	"database/sql"
	"fmt"
	"github.com/ResultadosDigitais/x9/db"
)
type Vulnerability struct {
	ID            string `json:"id"`
	Name          string `json:"name"`
	Repository    string `json:"repository"`
	FileName      string `json:"filename"`
	Tool          string `json:"tool"`
	Value         string `json:"value"`
	FalsePositive bool   `json:"false_positive"`
	IssueURL      string `json:"issue_url"`
}
func InsertVulnerability(v Vulnerability) (Vulnerability, error) {
	v.ID = getID(v.Name, v.Repository, v.Tool, v.Value, v.FileName)
	if vuln, err := GetVulnerabilityByID(v.ID); err == nil {
		return vuln, nil
	} else if err != sql.ErrNoRows {
		return Vulnerability{}, err
	}
	sql := `INSERT INTO vulnerabilities VALUES ($1, $2, $3, $4, $5, $6, $7, $8)`
	return v, db.Exec(sql, v.ID, v.Name, v.Repository, v.FileName, v.Tool, v.Value, v.FalsePositive, v.IssueURL)
}
func GetVulnerabilities() ([]Vulnerability, error) {
	sql := `SELECT * FROM vulnerabilities 
			ORDER BY false_positive desc, repository asc, name asc`
	row, err := db.Query(sql)
	if err != nil {
		return nil, err
	}
	return processRows(row)
}
func GetVulnerabilityByID(id string) (Vulnerability, error) {
	sql := `SELECT * FROM vulnerabilities
			  WHERE id = $1`
	row, err := db.QueryRow(sql, id)
	if err != nil {
		return Vulnerability{}, err
	}
	return processRow(row)
}
func GetVulnerabilitiesByNameOrRepo(search string) ([]Vulnerability, error) {
	sql := `SELECT * FROM vulnerabilities
			WHERE LOWER(name) LIKE LOWER($1)
			OR LOWER(repository) LIKE LOWER($1)
			ORDER BY false_positive desc`
	search = fmt.Sprintf("%%%s%%", search)
	rows, err := db.Query(sql, search)
	if err != nil {
		return nil, err
	}
	return processRows(rows)
}