mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-19 19:17:02 -07:00
feat: updated cache implementation and fixed bugs
This commit is contained in:
parent
a86ca3477a
commit
333b65a379
2 changed files with 20 additions and 11 deletions
30
cmd/cache.go
30
cmd/cache.go
|
|
@ -272,9 +272,14 @@ var cacheInfoCmd = &cobra.Command{
|
||||||
|
|
||||||
var cacheEditCmd = &cobra.Command{
|
var cacheEditCmd = &cobra.Command{
|
||||||
Use: "edit",
|
Use: "edit",
|
||||||
Example: ` magellan cache edit
|
Example: ` // star the cache editor
|
||||||
magellan cache edit --host https://172.16.0.101 --port 443 --protocol udp
|
magellan cache edit -i
|
||||||
magellan cache edit --host https://172.16.0.101
|
|
||||||
|
// edit a single entry only changing values specified (e.g. port and protocol)
|
||||||
|
magellan cache edit https://172.16.0.101 --port 443 --protocol udp
|
||||||
|
|
||||||
|
// edit two entries' time stamps
|
||||||
|
magellan cache edit https://172.16.0.101 https://172.16.0.102 --timestamp 06/25/2025
|
||||||
`,
|
`,
|
||||||
Args: cobra.ExactArgs(0),
|
Args: cobra.ExactArgs(0),
|
||||||
Short: "Edit existing cache data.",
|
Short: "Edit existing cache data.",
|
||||||
|
|
@ -287,17 +292,17 @@ var cacheEditCmd = &cobra.Command{
|
||||||
|
|
||||||
if interactive {
|
if interactive {
|
||||||
// load the assets found from scan
|
// load the assets found from scan
|
||||||
scannedResults, err := sqlite.GetScannedAssets(cachePath)
|
scannedResults, err := sqlite.GetRemoteAssets(cachePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Str("path", cachePath).Msg("failed to get scanned assets from cache")
|
log.Error().Err(err).Str("path", cachePath).Msg("failed to get scanned assets from cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
// set columns to cache headers
|
// set columns to cache headers
|
||||||
columns = []table.Column{
|
columns = []table.Column{
|
||||||
{Title: "hosts", Width: 20},
|
{Title: "host", Width: 30},
|
||||||
{Title: "ports", Width: 5},
|
{Title: "ports", Width: 8},
|
||||||
{Title: "protocol", Width: 8},
|
{Title: "protocol", Width: 10},
|
||||||
{Title: "timestamp", Width: 12},
|
{Title: "timestamp", Width: 20},
|
||||||
}
|
}
|
||||||
|
|
||||||
// set rows to cache data
|
// set rows to cache data
|
||||||
|
|
@ -310,7 +315,7 @@ var cacheEditCmd = &cobra.Command{
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// new table
|
// create a new table
|
||||||
assetsTable := table.New(
|
assetsTable := table.New(
|
||||||
table.WithColumns(columns),
|
table.WithColumns(columns),
|
||||||
table.WithRows(rows),
|
table.WithRows(rows),
|
||||||
|
|
@ -331,11 +336,16 @@ var cacheEditCmd = &cobra.Command{
|
||||||
Bold(false)
|
Bold(false)
|
||||||
assetsTable.SetStyles(styles)
|
assetsTable.SetStyles(styles)
|
||||||
|
|
||||||
m := cache.Model{Table: assetsTable}
|
m := cache.NewModel(cachePath, &assetsTable)
|
||||||
if _, err := tea.NewProgram(m, tea.WithAltScreen()).Run(); err != nil {
|
if _, err := tea.NewProgram(m, tea.WithAltScreen()).Run(); err != nil {
|
||||||
fmt.Println("Error running program:", err)
|
fmt.Println("Error running program:", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// non-interactive editting
|
||||||
|
// for _, host := range args {
|
||||||
|
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
internal/cache/modify.go
vendored
1
internal/cache/modify.go
vendored
|
|
@ -1 +0,0 @@
|
||||||
package cache
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue