Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
chainmaker.org/NingQing/store-couchdb/v2
type config struct {
host string
port string
user string
password string
timeOut time.Duration // 超时时间 s
maxRetries int // 最大重试次数
retryWaitTime time.Duration // 重试等待时间 ms 下次等待时间 = 这次等待时间*2
}
type Client struct {
ctx context.Context
dbName string
conf *config
client *http.Client
logger protocol.Logger
cancel context.CancelFunc
}
CreateDatabaseIfNotExist()
如果数据库不存在则创建。getDocRev
获取文档最新版本号,如若不存在则返回空Has
查看文档是否存在{"data": "value1" }
Put
插入一个文档,先获取文档最新版本号,如果不存在直接插入,存在则更新最新版本如果发生冲突,重新获取版本号,重新插入,只尝试一次
Get
获取最新版本的文档Delete
删除最新版本的文档,需要提供文档版本号暂未实现,假设当前删除的是v1,但是由于更新变成v2,那是否要删除v2
{"keys":["key1","key2"]}
GetKeys
批量获取文档{"docs":[{"_id":"key1","_rev":"v1","_deleted":true},{"_id":"key2","_rev":"v1"}]}
BatchUpdate
批量更新,如果没有版本号则是插入,有版本号则是更新,_deleted
为true则是删除发生冲突,对冲突文档进行重试一次
RangeKeys
遍历文档, 范围[startkey,endkey), size = limit{"selector":{"_id":{"$regex":"key+"}},"fields":["_id","_rev","data"]}
RangePrefix
通过前缀遍历文档,前缀通过正则表达式匹配 // .......
waitDuration := c.conf.retryWaitTime
for {
select {
case <-ctx.Done():
// 超时
return nil, CancelErr
default:
// ......
if maxRetries-1 < 1 {
// 错误处理
}
maxRetries--
time.Sleep(waitDuration)
waitDuration *= 2
}
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.