Skip to content

Commit

Permalink
automod: more robust misleading link detection
Browse files Browse the repository at this point in the history
  • Loading branch information
bnewbold committed Nov 29, 2023
1 parent f20a482 commit 1c05e6e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions automod/rules/misleading.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}
Expand All @@ -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 {
Expand All @@ -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
}
}
Expand Down

0 comments on commit 1c05e6e

Please sign in to comment.