mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
Removed 'dora' API
This commit is contained in:
parent
00f9d4ebf0
commit
6ff223aae1
1 changed files with 0 additions and 75 deletions
|
|
@ -1,75 +0,0 @@
|
||||||
package dora
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/OpenCHAMI/magellan/internal/util"
|
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
Host = "http://localhost"
|
|
||||||
DbType = "sqlite3"
|
|
||||||
DbPath = "../data/assets.db"
|
|
||||||
BaseEndpoint = "/v1"
|
|
||||||
Port = 8000
|
|
||||||
)
|
|
||||||
|
|
||||||
type ScannedResult struct {
|
|
||||||
id string
|
|
||||||
site any
|
|
||||||
cidr string
|
|
||||||
ip string
|
|
||||||
port int
|
|
||||||
protocol string
|
|
||||||
scanner string
|
|
||||||
state string
|
|
||||||
updated string
|
|
||||||
}
|
|
||||||
|
|
||||||
func makeEndpointUrl(endpoint string) string {
|
|
||||||
return Host + ":" + fmt.Sprint(Port) + BaseEndpoint + endpoint
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scan for BMC assets uing dora scanner
|
|
||||||
func ScanForAssets() error {
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Query dora API to get scanned ports
|
|
||||||
func QueryScannedPorts() error {
|
|
||||||
// Perform scan and collect from dora server
|
|
||||||
url := makeEndpointUrl("/scanned_ports")
|
|
||||||
_, body, err := util.MakeRequest(nil, url, "GET", nil, nil)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed todiscover assets: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// get data from JSON
|
|
||||||
var res map[string]any
|
|
||||||
if err := json.Unmarshal(body, &res); err != nil {
|
|
||||||
return fmt.Errorf("failed tounmarshal response body: %v", err)
|
|
||||||
}
|
|
||||||
data := res["data"]
|
|
||||||
|
|
||||||
fmt.Println(data)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loads scanned ports directly from DB
|
|
||||||
func LoadScannedPortsFromDB(dbPath string, dbType string) {
|
|
||||||
db, _ := sqlx.Open(dbType, dbPath)
|
|
||||||
sql := `SELECT * FROM scanned_port WHERE state='open'`
|
|
||||||
rows, _ := db.Query(sql)
|
|
||||||
for rows.Next() {
|
|
||||||
var r ScannedResult
|
|
||||||
rows.Scan(
|
|
||||||
&r.id, &r.site, &r.cidr, &r.ip, &r.port, &r.protocol, &r.scanner,
|
|
||||||
&r.state, &r.updated,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue