From 1c05e6ea5608212887edd5b90d3b197bf92550cd Mon Sep 17 00:00:00 2001 From: bryan newbold Date: Wed, 29 Nov 2023 00:13:01 -0800 Subject: [PATCH] automod: more robust misleading link detection --- automod/rules/misleading.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/automod/rules/misleading.go b/automod/rules/misleading.go index 52eff25d9..db97e7ae8 100644 --- a/automod/rules/misleading.go +++ b/automod/rules/misleading.go @@ -48,9 +48,9 @@ func MisleadingURLPostRule(evt *automod.RecordEvent, post *appbsky.FeedPost) err // this public code will obviously get discovered and bypassed. this doesn't earn you any security cred! linkHost := strings.ToLower(linkURL.Host) textHost := strings.ToLower(textURL.Host) - if textHost != linkHost && textHost != "www."+linkURL.Host { + if textHost != linkHost && textHost != "www."+linkURL.Host && "www."+textHost != linkURL.Host { evt.Logger.Warn("misleading mismatched domains", "linkHost", linkURL.Host, "textHost", textURL.Host, "text", facet.Text) - evt.AddRecordFlag("misleading") + evt.AddRecordFlag("misleading-link") } } } @@ -63,7 +63,8 @@ func MisleadingMentionPostRule(evt *automod.RecordEvent, post *appbsky.FeedPost) facets, err := ExtractFacets(post) if err != nil { evt.Logger.Warn("invalid facets", "err", err) - evt.AddRecordFlag("invalid") // TODO: or some other "this record is corrupt" indicator? + // TODO: or some other "this record is corrupt" indicator? + //evt.AddRecordFlag("invalid") return nil } for _, facet := range facets { @@ -88,7 +89,7 @@ func MisleadingMentionPostRule(evt *automod.RecordEvent, post *appbsky.FeedPost) // TODO: check if mentioned DID was recently updated? might be a caching issue if mentioned.DID.String() != *facet.DID { evt.Logger.Warn("misleading mention", "text", txt, "did", facet.DID) - evt.AddRecordFlag("misleading") + evt.AddRecordFlag("misleading-mention") continue } }