@@ -19,6 +19,7 @@ import (
1919 oam "github.com/owasp-amass/open-asset-model"
2020 oamcert "github.com/owasp-amass/open-asset-model/certificate"
2121 oamcon "github.com/owasp-amass/open-asset-model/contact"
22+ oamdns "github.com/owasp-amass/open-asset-model/dns"
2223 oamorg "github.com/owasp-amass/open-asset-model/org"
2324 oamreg "github.com/owasp-amass/open-asset-model/registration"
2425 "golang.org/x/net/publicsuffix"
@@ -48,13 +49,6 @@ func (s *Scope) IsAssociated(req *et.Association) ([]*et.Association, error) {
4849 impacted = append (impacted , im )
4950 }
5051 }
51- // review all previously seen assets that provide association for scope changes
52- for size := len (impacted ); size > 0 ; {
53- added := s .reviewAndUpdate (req )
54-
55- size = len (added )
56- impacted = append (impacted , added ... )
57- }
5852
5953 result .ImpactedAssets = impacted
6054 if len (result .ImpactedAssets ) > 0 {
@@ -80,43 +74,6 @@ func (s *Scope) addScopeChangesToRationale(result *et.Association) {
8074 result .Rationale += ". The following assets were added to the session scope: " + strings .Join (changes , ", " )
8175}
8276
83- func (s * Scope ) reviewAndUpdate (req * et.Association ) []* dbt.Entity {
84- var assocs []* dbt.Entity
85-
86- ctx , cancel := context .WithTimeout (s .Session .Ctx (), 10 * time .Second )
87- defer cancel ()
88-
89- since := s .ttlStartTime (oam .DomainRecord , oam .DomainRecord )
90- if drs , err := s .Session .DB ().FindEntitiesByType (ctx , oam .DomainRecord , since , 0 ); err == nil && len (drs ) > 0 {
91- assocs = append (assocs , drs ... )
92- }
93-
94- since = s .ttlStartTime (oam .IPNetRecord , oam .IPNetRecord )
95- if iprecs , err := s .Session .DB ().FindEntitiesByType (ctx , oam .IPNetRecord , since , 0 ); err == nil && len (iprecs ) > 0 {
96- assocs = append (assocs , iprecs ... )
97- }
98-
99- since = s .ttlStartTime (oam .AutnumRecord , oam .AutnumRecord )
100- if autnums , err := s .Session .DB ().FindEntitiesByType (ctx , oam .AutnumRecord , since , 0 ); err == nil && len (autnums ) > 0 {
101- assocs = append (assocs , autnums ... )
102- }
103-
104- since = s .ttlStartTime (oam .TLSCertificate , oam .TLSCertificate )
105- if certs , err := s .Session .DB ().FindEntitiesByType (ctx , oam .TLSCertificate , since , 0 ); err == nil && len (certs ) > 0 {
106- assocs = append (assocs , certs ... )
107- }
108-
109- var impacted []* dbt.Entity
110- for _ , assoc := range s .checkRelatedAssetsforAssoc (req , assocs ) {
111- for _ , a := range append (assoc .ImpactedAssets , assoc .Match ) {
112- if s .Add (a .Asset ) {
113- impacted = append (impacted , a )
114- }
115- }
116- }
117- return impacted
118- }
119-
12077func (s * Scope ) checkRelatedAssetsforAssoc (req * et.Association , assocs []* dbt.Entity ) []* et.Association {
12178 var results []* et.Association
12279
@@ -129,14 +86,17 @@ func (s *Scope) checkRelatedAssetsforAssoc(req *et.Association, assocs []*dbt.En
12986 if req .ScopeChange {
13087 impacted = append (impacted , asset )
13188 }
132- if match , conf := s .IsAssetInScope (asset .Asset , req .Confidence ); conf > 0 {
89+
90+ atype := asset .Asset .AssetType ()
91+ rconf := s .confidence (atype , atype )
92+ if match , conf := s .IsAssetInScope (asset .Asset , rconf ); conf > 0 {
13393 if conf > best {
13494 best = conf
13595
13696 aa := assoc .Asset
13797 sa := req .Submission .Asset
13898 msg = fmt .Sprintf ("[%s: %s] is related to an asset with associative value [%s: %s], " , sa .AssetType (), sa .Key (), aa .AssetType (), aa .Key ())
139- msg += fmt .Sprintf ("which has a related asset [%s: %s] that was determined associated with [%s: %s] at a confidence of %d out of 100" ,
99+ msg += fmt .Sprintf ("which has a related asset [%s: %s] that is in scope: matches [%s: %s] at a confidence of %d out of 100" ,
140100 asset .Asset .AssetType (), asset .Asset .Key (), match .AssetType (), match .Key (), conf )
141101 }
142102 }
@@ -168,15 +128,9 @@ func (s *Scope) assetsRelatedToAssetWithAssoc(assoc *dbt.Entity) []*dbt.Entity {
168128 var found bool
169129
170130 switch v := a .Asset .(type ) {
171- /*case *oamdns.FQDN:
172- ctx, cancel := context.WithTimeout(s.Session.Ctx(), 3*time.Second)
173- defer cancel()
174-
175- since := s.ttlStartTime(oam.FQDN, oam.FQDN)
176- if ents, err := s.Session.DB().IncomingEdges(ctx, a, since, "node"); err != nil || len(ents) == 0 {
131+ case * oamdns.FQDN :
177132 found = true
178133 results = append (results , a )
179- }*/
180134 case * oamorg.Organization :
181135 found = true
182136 if cert , ok := assoc .Asset .(* oamcert.TLSCertificate ); ! ok || s .orgNameSimilarToCommon (v , cert ) {
@@ -258,10 +212,6 @@ func (s *Scope) awayFromAssetsWithAssociation(assoc *dbt.Entity) ([]*dbt.Entity,
258212 var outRels , inRels []string
259213 var outSince , inSince time.Time
260214 switch assoc .Asset .AssetType () {
261- /*case oam.FQDN:
262- in = true
263- inRels = append(inRels, "node")
264- inSince = s.ttlStartTime(oam.FQDN, oam.FQDN)*/
265215 case oam .DomainRecord :
266216 out = true
267217 outRels = append (outRels , "registrant_contact" )
@@ -412,6 +362,15 @@ func (s *Scope) ttlStartTime(from, to oam.AssetType) time.Time {
412362 return time.Time {}
413363}
414364
365+ func (s * Scope ) confidence (from , to oam.AssetType ) int {
366+ if matches , err := s .Session .Config ().CheckTransformations (string (from ), string (to )); err == nil && matches != nil {
367+ if conf := matches .Confidence (string (to )); conf >= 0 {
368+ return conf
369+ }
370+ }
371+ return - 1
372+ }
373+
415374func (s * Scope ) orgNameSimilarToCommon (o * oamorg.Organization , cert * oamcert.TLSCertificate ) bool {
416375 swg := metrics .NewSmithWatermanGotoh ()
417376 swg .CaseSensitive = false
0 commit comments