add better origin checks for all activities
This commit is contained in:
parent
a11ab06762
commit
d4d2483ee0
24
activity.go
24
activity.go
|
@ -270,12 +270,6 @@ func needxonkid(user *WhatAbout, xid string) bool {
|
||||||
func savexonk(user *WhatAbout, x *Honk) {
|
func savexonk(user *WhatAbout, x *Honk) {
|
||||||
if x.What == "eradicate" {
|
if x.What == "eradicate" {
|
||||||
log.Printf("eradicating %s by %s", x.RID, x.Honker)
|
log.Printf("eradicating %s by %s", x.RID, x.Honker)
|
||||||
mh := re_unurl.FindStringSubmatch(x.Honker)
|
|
||||||
mr := re_unurl.FindStringSubmatch(x.RID)
|
|
||||||
if len(mh) < 2 || len(mr) < 2 || mh[1] != mr[1] {
|
|
||||||
log.Printf("not deleting owner mismatch")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
xonk := getxonk(user.ID, x.RID)
|
xonk := getxonk(user.ID, x.RID)
|
||||||
if xonk != nil {
|
if xonk != nil {
|
||||||
stmtZonkDonks.Exec(xonk.ID)
|
stmtZonkDonks.Exec(xonk.ID)
|
||||||
|
@ -382,6 +376,7 @@ func peeppeep() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
t, _ := jsongetstring(j, "type")
|
t, _ := jsongetstring(j, "type")
|
||||||
|
origin := originate(f.XID)
|
||||||
if t == "OrderedCollection" {
|
if t == "OrderedCollection" {
|
||||||
items, _ := jsongetarray(j, "orderedItems")
|
items, _ := jsongetarray(j, "orderedItems")
|
||||||
if items == nil {
|
if items == nil {
|
||||||
|
@ -395,7 +390,7 @@ func peeppeep() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range items {
|
for _, item := range items {
|
||||||
xonk := xonkxonk(user, item)
|
xonk := xonkxonk(user, item, origin)
|
||||||
if xonk != nil {
|
if xonk != nil {
|
||||||
savexonk(user, xonk)
|
savexonk(user, xonk)
|
||||||
}
|
}
|
||||||
|
@ -434,10 +429,10 @@ func newphone(a []string, obj map[string]interface{}) []string {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
func xonkxonk(user *WhatAbout, item interface{}) *Honk {
|
func xonkxonk(user *WhatAbout, item interface{}, origin string) *Honk {
|
||||||
depth := 0
|
depth := 0
|
||||||
maxdepth := 4
|
maxdepth := 4
|
||||||
var xonkxonkfn func(item interface{}) *Honk
|
var xonkxonkfn func(item interface{}, origin string) *Honk
|
||||||
|
|
||||||
saveoneup := func(xid string) {
|
saveoneup := func(xid string) {
|
||||||
log.Printf("getting oneup: %s", xid)
|
log.Printf("getting oneup: %s", xid)
|
||||||
|
@ -451,14 +446,14 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
depth++
|
depth++
|
||||||
xonk := xonkxonkfn(obj)
|
xonk := xonkxonkfn(obj, originate(xid))
|
||||||
if xonk != nil {
|
if xonk != nil {
|
||||||
savexonk(user, xonk)
|
savexonk(user, xonk)
|
||||||
}
|
}
|
||||||
depth--
|
depth--
|
||||||
}
|
}
|
||||||
|
|
||||||
xonkxonkfn = func(item interface{}) *Honk {
|
xonkxonkfn = func(item interface{}, origin string) *Honk {
|
||||||
// id, _ := jsongetstring(item, "id")
|
// id, _ := jsongetstring(item, "id")
|
||||||
what, _ := jsongetstring(item, "type")
|
what, _ := jsongetstring(item, "type")
|
||||||
dt, _ := jsongetstring(item, "published")
|
dt, _ := jsongetstring(item, "published")
|
||||||
|
@ -484,6 +479,7 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("error regetting: %s", err)
|
log.Printf("error regetting: %s", err)
|
||||||
}
|
}
|
||||||
|
origin = originate(xid)
|
||||||
what = "bonk"
|
what = "bonk"
|
||||||
case "Create":
|
case "Create":
|
||||||
obj, _ = jsongetmap(item, "object")
|
obj, _ = jsongetmap(item, "object")
|
||||||
|
@ -579,6 +575,10 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if originate(xid) != origin {
|
||||||
|
log.Printf("original sin: %s <> %s", xid, origin)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
audience = append(audience, who)
|
audience = append(audience, who)
|
||||||
|
|
||||||
audience = oneofakind(audience)
|
audience = oneofakind(audience)
|
||||||
|
@ -610,7 +610,7 @@ func xonkxonk(user *WhatAbout, item interface{}) *Honk {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return xonkxonkfn(item)
|
return xonkxonkfn(item, origin)
|
||||||
}
|
}
|
||||||
|
|
||||||
func rubadubdub(user *WhatAbout, req map[string]interface{}) {
|
func rubadubdub(user *WhatAbout, req map[string]interface{}) {
|
||||||
|
|
14
fun.go
14
fun.go
|
@ -252,6 +252,14 @@ func mentionize(s string) string {
|
||||||
|
|
||||||
var re_unurl = regexp.MustCompile("https://([^/]+).*/([^/]+)")
|
var re_unurl = regexp.MustCompile("https://([^/]+).*/([^/]+)")
|
||||||
|
|
||||||
|
func originate(u string) string {
|
||||||
|
m := re_unurl.FindStringSubmatch(u)
|
||||||
|
if len(m) > 2 {
|
||||||
|
return m[1]
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func honkerhandle(h string) string {
|
func honkerhandle(h string) string {
|
||||||
m := re_unurl.FindStringSubmatch(h)
|
m := re_unurl.FindStringSubmatch(h)
|
||||||
if len(m) > 2 {
|
if len(m) > 2 {
|
||||||
|
@ -427,14 +435,14 @@ func thoudostbitethythumb(userid int64, who []string, objid string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func keymatch(keyname string, actor string, what string, userid int64) bool {
|
func keymatch(keyname string, actor string) string {
|
||||||
hash := strings.IndexByte(keyname, '#')
|
hash := strings.IndexByte(keyname, '#')
|
||||||
if hash == -1 {
|
if hash == -1 {
|
||||||
hash = len(keyname)
|
hash = len(keyname)
|
||||||
}
|
}
|
||||||
owner := keyname[0:hash]
|
owner := keyname[0:hash]
|
||||||
if owner == actor {
|
if owner == actor {
|
||||||
return true
|
return originate(actor)
|
||||||
}
|
}
|
||||||
return false
|
return ""
|
||||||
}
|
}
|
||||||
|
|
5
honk.go
5
honk.go
|
@ -304,7 +304,8 @@ func inbox(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
who, _ := jsongetstring(j, "actor")
|
who, _ := jsongetstring(j, "actor")
|
||||||
if !keymatch(keyname, who, what, user.ID) {
|
origin := keymatch(keyname, who)
|
||||||
|
if origin == "" {
|
||||||
log.Printf("keyname actor mismatch: %s <> %s", keyname, who)
|
log.Printf("keyname actor mismatch: %s <> %s", keyname, who)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -357,7 +358,7 @@ func inbox(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
xonk := xonkxonk(user, j)
|
xonk := xonkxonk(user, j, origin)
|
||||||
if xonk != nil {
|
if xonk != nil {
|
||||||
savexonk(user, xonk)
|
savexonk(user, xonk)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue