Fix duplicated nodes in matcher
This commit is contained in:
parent
1528c28d7e
commit
e8f114edef
|
@ -204,13 +204,11 @@ Node(func: allofterms(full, $a)) {
|
||||||
time.Sleep(time.Duration(2) * time.Second)
|
time.Sleep(time.Duration(2) * time.Second)
|
||||||
logrus.Info("Found paste match for ", target)
|
logrus.Info("Found paste match for ", target)
|
||||||
// TODO: review time and id to be updated on new resulsts
|
// TODO: review time and id to be updated on new resulsts
|
||||||
|
|
||||||
for _, res := range n.Result {
|
for _, res := range n.Result {
|
||||||
if len(matcher.Nodes) == 0 {
|
if len(matcher.Nodes) == 0 {
|
||||||
matcher.Nodes = append(matcher.Nodes, res)
|
matcher.Nodes = append(matcher.Nodes, res)
|
||||||
continue
|
continue
|
||||||
}
|
} else {
|
||||||
|
|
||||||
for _, node := range matcher.Nodes {
|
for _, node := range matcher.Nodes {
|
||||||
if res.UID != node.UID {
|
if res.UID != node.UID {
|
||||||
matcher.Nodes = append(matcher.Nodes, res)
|
matcher.Nodes = append(matcher.Nodes, res)
|
||||||
|
@ -219,6 +217,8 @@ Node(func: allofterms(full, $a)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
query := fmt.Sprintf(`query { match as var(func: eq(target, "%s")) }`, target)
|
query := fmt.Sprintf(`query { match as var(func: eq(target, "%s")) }`, target)
|
||||||
|
|
||||||
pb, err := json.Marshal(models.Match{UID: "uid(match)", ID: matcher.ID, Target: target, Nodes: matcher.Nodes, NodeType: "matcher", Timestamp: rfc3339time})
|
pb, err := json.Marshal(models.Match{UID: "uid(match)", ID: matcher.ID, Target: target, Nodes: matcher.Nodes, NodeType: "matcher", Timestamp: rfc3339time})
|
||||||
|
@ -289,14 +289,14 @@ Node(func: allofterms(cn, $a)){
|
||||||
if len(matcher.Nodes) == 0 {
|
if len(matcher.Nodes) == 0 {
|
||||||
matcher.Nodes = append(matcher.Nodes, res)
|
matcher.Nodes = append(matcher.Nodes, res)
|
||||||
continue
|
continue
|
||||||
}
|
} else {
|
||||||
|
|
||||||
for _, nodes := range matcher.Nodes {
|
for _, nodes := range matcher.Nodes {
|
||||||
if res.UID != nodes.UID {
|
if res.UID != nodes.UID {
|
||||||
matcher.Nodes = append(matcher.Nodes, res)
|
matcher.Nodes = append(matcher.Nodes, res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
query := fmt.Sprintf(`query { match as var(func: eq(target, "%s")) }`, target)
|
query := fmt.Sprintf(`query { match as var(func: eq(target, "%s")) }`, target)
|
||||||
|
|
||||||
|
@ -380,8 +380,7 @@ func runShodanMatcher(target string, graphClient *dgo.Dgraph) {
|
||||||
if len(matcher.Nodes) == 0 {
|
if len(matcher.Nodes) == 0 {
|
||||||
matcher.Nodes = append(matcher.Nodes, res)
|
matcher.Nodes = append(matcher.Nodes, res)
|
||||||
continue
|
continue
|
||||||
}
|
} else {
|
||||||
|
|
||||||
for _, node := range matcher.Nodes {
|
for _, node := range matcher.Nodes {
|
||||||
if res.UID != node.UID {
|
if res.UID != node.UID {
|
||||||
matcher.Nodes = append(matcher.Nodes, res)
|
matcher.Nodes = append(matcher.Nodes, res)
|
||||||
|
@ -390,6 +389,8 @@ func runShodanMatcher(target string, graphClient *dgo.Dgraph) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
query := fmt.Sprintf(`query { match as var(func: eq(target, "%s")) }`, target)
|
query := fmt.Sprintf(`query { match as var(func: eq(target, "%s")) }`, target)
|
||||||
|
|
||||||
pb, err := json.Marshal(models.Match{UID: "uid(match)", ID: matcher.ID, Target: target, Nodes: matcher.Nodes, NodeType: "matcher", Timestamp: rfc3339time})
|
pb, err := json.Marshal(models.Match{UID: "uid(match)", ID: matcher.ID, Target: target, Nodes: matcher.Nodes, NodeType: "matcher", Timestamp: rfc3339time})
|
||||||
|
|
Loading…
Reference in a new issue