自学内容网 自学内容网

执行“go mod tidy”遇到“misbehavior”错误

执行“go mod tidy”报错下错误,执行“go clean -modcache”和删除“go env GOMODCACHE”指定目录均无效:

SECURITY ERROR
go.sum database server misbehavior detected!

old database:
        go.sum database tree
        3397826
        xyyhzdyAOat5li/EXx/MK1gONQf3LAGqArhBLzQVQt8=

        — sum.mooon.com ZD16BsDeu0l8HWHTrM3Axa9jy5Ctbbmj9FZ1AowqytSa22OZ7Se98hXT+88+mjuCAIY5KSAG/nV26LayhI5OyaA3cAb=

new database:
        go.sum database tree
        3398774
        MgvgQR/7OUAeth2F6s7qHqgBX7QNBIKhXfeN7iFPBes=

        — sum.mooon.com ZD16BtxccgOLtLlxqG5rx6vhz8vPBkqUTpW+loMoojYBqWcEeVWnxkKAMFtH2ynJrlXsOLLBfABqBJTxhyswvyh1mAe=

proof of misbehavior:
        duuII5nfe1EhWYdzwvAkuwY/teHJYPtw8Ip1Z/ebbOt=    internal error: generated inconsistent proof

删除项目的 go.sum 也不一定能解决,打新的 tag 可能也无用。可尝试删除文件 rm $(go env GOMODCACHE)/…/sumdb/sum.mooon.com/latest 后重试,测试解决了此问题。

报这个错误的源代码文件 https://github.com/golang/mod/blob/master/sumdb/client.go :

// checkTrees checks that older (from olderNote) is contained in newer (from newerNote).
// If an error occurs, such as malformed data or a network problem, checkTrees returns that error.
// If on the other hand checkTrees finds evidence of misbehavior, it prepares a detailed
// message and calls log.Fatal.
func (c *Client) checkTrees(older tlog.Tree, olderNote []byte, newer tlog.Tree, newerNote []byte) error {
thr := tlog.TileHashReader(newer, &c.tileReader)
h, err := tlog.TreeHash(older.N, thr)
if err != nil {
if older.N == newer.N {
return fmt.Errorf("checking tree#%d: %v", older.N, err)
}
return fmt.Errorf("checking tree#%d against tree#%d: %v", older.N, newer.N, err)
}
if h == older.Hash {
return nil
}

// Detected a fork in the tree timeline.
// Start by reporting the inconsistent signed tree notes.
var buf bytes.Buffer
fmt.Fprintf(&buf, "SECURITY ERROR\n")
fmt.Fprintf(&buf, "go.sum database server misbehavior detected!\n\n")
indent := func(b []byte) []byte {
return bytes.Replace(b, []byte("\n"), []byte("\n\t"), -1)
}
fmt.Fprintf(&buf, "old database:\n\t%s\n", indent(olderNote))
fmt.Fprintf(&buf, "new database:\n\t%s\n", indent(newerNote))

// The notes alone are not enough to prove the inconsistency.
// We also need to show that the newer note's tree hash for older.N
// does not match older.Hash. The consumer of this report could
// of course consult the server to try to verify the inconsistency,
// but we are holding all the bits we need to prove it right now,
// so we might as well print them and make the report not depend
// on the continued availability of the misbehaving server.
// Preparing this data only reuses the tiled hashes needed for
// tlog.TreeHash(older.N, thr) above, so assuming thr is caching tiles,
// there are no new access to the server here, and these operations cannot fail.
fmt.Fprintf(&buf, "proof of misbehavior:\n\t%v", h)
if p, err := tlog.ProveTree(newer.N, older.N, thr); err != nil {
fmt.Fprintf(&buf, "\tinternal error: %v\n", err)
} else if err := tlog.CheckTree(p, newer.N, newer.Hash, older.N, h); err != nil {
fmt.Fprintf(&buf, "\tinternal error: generated inconsistent proof\n")
} else {
for _, h := range p {
fmt.Fprintf(&buf, "\n\t%v", h)
}
}
c.ops.SecurityError(buf.String())
return ErrSecurity
}

原文地址:https://blog.csdn.net/Aquester/article/details/144273818

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!