-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from wgpsec/dev
feat: support lists qiniu cloud kodo services
- Loading branch information
Showing
22 changed files
with
241 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package huaweicloud | ||
package huawei | ||
|
||
import ( | ||
"context" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package cucloud | ||
package liantong | ||
|
||
import ( | ||
"context" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package qiniu | ||
|
||
import ( | ||
"context" | ||
"github.com/projectdiscovery/gologger" | ||
"github.com/qiniu/go-sdk/v7/auth" | ||
"github.com/qiniu/go-sdk/v7/storage" | ||
"github.com/wgpsec/lc/pkg/schema" | ||
) | ||
|
||
type kodoProvider struct { | ||
id string | ||
provider string | ||
kodoClient *auth.Credentials | ||
} | ||
|
||
func (d *kodoProvider) GetResource(ctx context.Context) (*schema.Resources, error) { | ||
var request storage.BucketV4Input | ||
var list = schema.NewResources() | ||
gologger.Debug().Msg("正在获取七牛云 Kodo 对象存储信息") | ||
cfg := storage.Config{ | ||
UseHTTPS: true, | ||
} | ||
bucketManager := storage.NewBucketManager(d.kodoClient, &cfg) | ||
for { | ||
response, err := bucketManager.BucketsV4(&request) | ||
if err != nil { | ||
return nil, err | ||
} | ||
for _, bucket := range response.Buckets { | ||
list.Append(&schema.Resource{ | ||
ID: d.id, | ||
Public: true, | ||
DNSName: bucket.Name, | ||
Provider: d.provider, | ||
}) | ||
} | ||
if response.IsTruncated { | ||
response.NextMarker = request.Marker | ||
} else { | ||
break | ||
} | ||
} | ||
return list, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package qiniu | ||
|
||
import ( | ||
"context" | ||
"github.com/projectdiscovery/gologger" | ||
"github.com/qiniu/go-sdk/v7/auth" | ||
"github.com/wgpsec/lc/pkg/schema" | ||
"github.com/wgpsec/lc/utils" | ||
) | ||
|
||
type Provider struct { | ||
id string | ||
provider string | ||
kodoClient *auth.Credentials | ||
} | ||
|
||
func New(options schema.OptionBlock) (*Provider, error) { | ||
var ( | ||
kodoClient *auth.Credentials | ||
) | ||
accessKeyID, ok := options.GetMetadata(utils.AccessKey) | ||
if !ok { | ||
return nil, &utils.ErrNoSuchKey{Name: utils.AccessKey} | ||
} | ||
accessKeySecret, ok := options.GetMetadata(utils.SecretKey) | ||
if !ok { | ||
return nil, &utils.ErrNoSuchKey{Name: utils.SecretKey} | ||
} | ||
id, _ := options.GetMetadata(utils.Id) | ||
|
||
gologger.Debug().Msg("找到七牛云访问永久访问凭证") | ||
|
||
// kodo client | ||
kodoClient = auth.New(accessKeyID, accessKeySecret) | ||
|
||
return &Provider{provider: utils.QiNiu, id: id, kodoClient: kodoClient}, nil | ||
} | ||
|
||
func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { | ||
var err error | ||
kodoProvider := &kodoProvider{kodoClient: p.kodoClient, id: p.id, provider: p.provider} | ||
buckets, err := kodoProvider.GetResource(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
gologger.Info().Msgf("获取到 %d 条七牛云 Kodo 对象存储信息", len(buckets.Items)) | ||
finalList := schema.NewResources() | ||
finalList.Merge(buckets) | ||
return finalList, nil | ||
} | ||
|
||
func (p *Provider) Name() string { | ||
return p.provider | ||
} | ||
func (p *Provider) ID() string { | ||
return p.id | ||
} |
2 changes: 1 addition & 1 deletion
2
pkg/providers/tencentcloud/cos.go → pkg/providers/tencent/cos.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package tencentcloud | ||
package tencent | ||
|
||
import ( | ||
"context" | ||
|
2 changes: 1 addition & 1 deletion
2
pkg/providers/tencentcloud/cvm.go → pkg/providers/tencent/cvm.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package tencentcloud | ||
package tencent | ||
|
||
import ( | ||
"context" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package tencentcloud | ||
package tencent | ||
|
||
import ( | ||
"context" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.