Skip to content

Commit af6a109

Browse files
committed
chore: client update
1 parent d248137 commit af6a109

4 files changed

Lines changed: 45 additions & 6 deletions

File tree

‎cmd/sibyl/subs/server/cmd_server_scenario_test.go‎

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,49 @@ func TestMainScenario(t *testing.T) {
116116
assert.Nil(t, err)
117117
assert.NotEmpty(t, functionWithPaths)
118118

119-
for _, each := range functionWithPaths {
119+
for _, eachFunc := range functionWithPaths {
120120
core.Log.Infof("file %s hit func %s, ref: %d, refed: %d",
121-
fileName, *each.Name, len(each.Calls), len(each.ReverseCalls))
121+
fileName, *eachFunc.Name, len(eachFunc.Calls), len(eachFunc.ReverseCalls))
122+
}
123+
124+
// query their reverse call chains?
125+
for _, eachFunc := range functionWithPaths {
126+
chain, _, err := apiClient.SignatureQueryApi.
127+
ApiV1SignatureFuncctxRchainGet(ctx).
128+
Repo(projectName).
129+
Rev(head.Hash().String()).
130+
Signature(eachFunc.GetSignature()).
131+
Depth(5).
132+
Execute()
133+
assert.Nil(t, err)
134+
// chain is a tree-like object
135+
// access it with dfs/bfs
136+
if chain.ReverseCallChains != nil {
137+
for _, each := range chain.ReverseCallChains.GetChildren() {
138+
core.Log.Infof("cur: %v", each.Content)
139+
for _, eachSub := range each.GetChildren() {
140+
core.Log.Infof("cur: %v", eachSub.Content)
141+
// continue ...
142+
// eachSub.GetChildren()
143+
}
144+
}
145+
}
146+
147+
// also a normal call chain
148+
chain, _, err = apiClient.SignatureQueryApi.
149+
ApiV1SignatureFuncctxChainGet(ctx).
150+
Repo(projectName).
151+
Rev(head.Hash().String()).
152+
Signature(eachFunc.GetSignature()).
153+
Depth(5).
154+
Execute()
155+
assert.Nil(t, err)
156+
assert.NotNil(t, chain)
157+
}
122158

159+
for _, eachFunc := range functionWithPaths {
123160
// get all the calls details?
124-
for _, eachCall := range each.Calls {
161+
for _, eachCall := range eachFunc.Calls {
125162
detail, _, err := apiClient.SignatureQueryApi.
126163
ApiV1SignatureFuncGet(ctx).
127164
Repo(projectName).

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/go-git/go-git/v5 v5.4.2
1212
github.com/hashicorp/go-retryablehttp v0.7.1
1313
github.com/mitchellh/mapstructure v1.5.0
14-
github.com/opensibyl/sibyl-go-client v0.0.0-20230119061729-52bf01908f53
14+
github.com/opensibyl/sibyl-go-client v0.0.0-20230119132521-b82eaaac836d
1515
github.com/pkg/errors v0.9.1
1616
github.com/prometheus/client_golang v1.14.0
1717
github.com/segmentio/kafka-go v0.4.38

‎go.sum‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,8 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
373373
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
374374
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
375375
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
376-
github.com/opensibyl/sibyl-go-client v0.0.0-20230119061729-52bf01908f53 h1:9E3DQTMiKC3H8sCFUGEBBKUECN+JHiEoqQP/D6axxgY=
377-
github.com/opensibyl/sibyl-go-client v0.0.0-20230119061729-52bf01908f53/go.mod h1:JULBsQp2/F4n6/JXbisEkKxWVAfm/XL7qxESt2wkqQY=
376+
github.com/opensibyl/sibyl-go-client v0.0.0-20230119132521-b82eaaac836d h1:Fhrz0Qz7FnmmSyWkqjBVQKBNNRGvBs5BSyFEE2ZmZkM=
377+
github.com/opensibyl/sibyl-go-client v0.0.0-20230119132521-b82eaaac836d/go.mod h1:JULBsQp2/F4n6/JXbisEkKxWVAfm/XL7qxESt2wkqQY=
378378
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
379379
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
380380
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=

‎pkg/server/binding/binding.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Rule
3737
Rule is a query structure implemented with regex and gjson syntax.
3838
- key: gjson path syntax
3939
- value: verify function
40+
41+
full serialization is expensive.
4042
*/
4143
type Rule = map[string]func(string) bool
4244

0 commit comments

Comments
 (0)
⌂ 换网址