File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,35 @@ or go to https://{domain}/me/pending-invites to manage all of your crate ownersh
9191 self . send ( email, subject, & body)
9292 }
9393
94+ /// Attempts to send a notification that a new crate may be typosquatting another crate.
95+ pub fn send_possible_typosquat_notification (
96+ & self ,
97+ email : & str ,
98+ crate_name : & str ,
99+ squats : & [ typomania:: checks:: Squat ] ,
100+ ) -> AppResult < ( ) > {
101+ let domain = crate :: config:: domain_name ( ) ;
102+ let subject = "Possible typosquatting in new crate" ;
103+ let body = format ! (
104+ "New crate {crate_name} may be typosquatting one or more other crates.\n
105+ Visit https://{domain}/crates/{crate_name} to see the offending crate.\n
106+ \n
107+ Specific squat checks that triggered:\n
108+ \n
109+ {squats}" ,
110+ squats = squats
111+ . iter( )
112+ . map( |squat| format!(
113+ "- {squat} (https://{domain}/crates/{crate_name})\n " ,
114+ crate_name = squat. package( )
115+ ) )
116+ . collect:: <Vec <_>>( )
117+ . join( "" ) ,
118+ ) ;
119+
120+ self . send ( email, subject, & body)
121+ }
122+
94123 /// Attempts to send an API token exposure notification email
95124 pub fn send_token_exposed_notification (
96125 & self ,
You can’t perform that action at this time.
0 commit comments