Skip to content

Commit 06049fd

Browse files
committed
updated the new enum output
1 parent bd6da1e commit 06049fd

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

cmd/amass/enum.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ func processOutput(ctx context.Context, g *netmap.Graph, e *enum.Enumeration, ou
414414
known := stringset.New()
415415
defer known.Close()
416416
// The function that obtains output from the enum and puts it on the channel
417-
extract := func() {
418-
for _, o := range NewOutput(ctx, g, e, known) {
417+
extract := func(since time.Time) {
418+
for _, o := range NewOutput(ctx, g, e, known, since) {
419419
for _, ch := range outputs {
420420
ch <- o
421421
}
@@ -424,17 +424,20 @@ func processOutput(ctx context.Context, g *netmap.Graph, e *enum.Enumeration, ou
424424

425425
t := time.NewTimer(10 * time.Second)
426426
defer t.Stop()
427+
last := e.Config.CollectionStartTime
427428
for {
428429
select {
429430
case <-ctx.Done():
430-
extract()
431+
extract(last)
431432
return
432433
case <-done:
433-
extract()
434+
extract(last)
434435
return
435436
case <-t.C:
436-
extract()
437+
next := time.Now()
438+
extract(last)
437439
t.Reset(10 * time.Second)
440+
last = next
438441
}
439442
}
440443
}

cmd/amass/io.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"golang.org/x/net/publicsuffix"
2323
)
2424

25-
func NewOutput(ctx context.Context, g *netmap.Graph, e *enum.Enumeration, filter *stringset.Set) []string {
25+
func NewOutput(ctx context.Context, g *netmap.Graph, e *enum.Enumeration, filter *stringset.Set, since time.Time) []string {
2626
var output []string
2727

2828
// Make sure a filter has been created
@@ -32,26 +32,27 @@ func NewOutput(ctx context.Context, g *netmap.Graph, e *enum.Enumeration, filter
3232
}
3333

3434
var assets []*types.Asset
35-
qtime := e.Config.CollectionStartTime.UTC()
3635
for _, atype := range []oam.AssetType{oam.FQDN, oam.IPAddress, oam.Netblock, oam.ASN, oam.RIROrg} {
37-
if a, err := g.DB.FindByType(atype, qtime); err == nil {
36+
if a, err := g.DB.FindByType(atype, since.UTC()); err == nil {
3837
assets = append(assets, a...)
3938
}
4039
}
4140

41+
arrow := white("-->")
42+
start := e.Config.CollectionStartTime.UTC()
4243
for _, from := range assets {
43-
fromstr := extractAssetName(from, qtime)
44+
fromstr := extractAssetName(from)
4445

45-
if rels, err := g.DB.OutgoingRelations(from, qtime); err == nil {
46+
if rels, err := g.DB.OutgoingRelations(from, start); err == nil {
4647
for _, rel := range rels {
4748
lineid := from.ID + rel.ID + rel.ToAsset.ID
4849
if filter.Has(lineid) {
4950
continue
5051
}
51-
if to, err := g.DB.FindById(rel.ToAsset.ID, qtime); err == nil {
52-
tostr := extractAssetName(to, qtime)
52+
if to, err := g.DB.FindById(rel.ToAsset.ID, start); err == nil {
53+
tostr := extractAssetName(to)
5354

54-
output = append(output, fmt.Sprintf("%s %s %s %s %s", fromstr, "-->", magenta(rel.Type), "-->", tostr))
55+
output = append(output, fmt.Sprintf("%s %s %s %s %s", fromstr, arrow, magenta(rel.Type), arrow, tostr))
5556
filter.Insert(lineid)
5657
}
5758
}
@@ -61,7 +62,7 @@ func NewOutput(ctx context.Context, g *netmap.Graph, e *enum.Enumeration, filter
6162
return output
6263
}
6364

64-
func extractAssetName(a *types.Asset, since time.Time) string {
65+
func extractAssetName(a *types.Asset) string {
6566
var result string
6667

6768
switch a.Asset.AssetType() {

cmd/amass/main.go

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ var (
6363
green = color.New(color.FgHiGreen).SprintFunc()
6464
blue = color.New(color.FgHiBlue).SprintFunc()
6565
magenta = color.New(color.FgHiMagenta).SprintFunc()
66+
white = color.New(color.FgHiWhite).SprintFunc()
6667
)
6768

6869
func commandUsage(msg string, cmdFlagSet *flag.FlagSet, errBuf *bytes.Buffer) {

0 commit comments

Comments
 (0)