From e16fc5965f27d43b3ed5b3c261abd43d530f6525 Mon Sep 17 00:00:00 2001 From: teamssix Date: Sat, 20 Apr 2024 20:36:21 +0800 Subject: [PATCH] feat: support lists qiniu cloud kodo services --- CHANGELOG.md | 3 +- README.md | 25 ++++---- cmd/configFile.go | 21 ++++--- go.mod | 3 + go.sum | 58 ++++++++++++++++++- pkg/inventory/inventory.go | 33 ++++++----- .../baiducloud.go => baidu/baidu.go} | 4 +- pkg/providers/{baiducloud => baidu}/bcc.go | 3 +- pkg/providers/{baiducloud => baidu}/bos.go | 4 +- .../huaweicloud.go => huawei/huawei.go} | 4 +- pkg/providers/{huaweicloud => huawei}/obs.go | 2 +- .../cucloud.go => liantong/liantong.go} | 4 +- pkg/providers/{cucloud => liantong}/oss.go | 2 +- pkg/providers/qiniu/kodo.go | 45 ++++++++++++++ pkg/providers/qiniu/qiniu.go | 57 ++++++++++++++++++ .../{tencentcloud => tencent}/cos.go | 2 +- .../{tencentcloud => tencent}/cvm.go | 2 +- pkg/providers/{tencentcloud => tencent}/lh.go | 2 +- .../tencentcloud.go => tencent/tencent.go} | 4 +- pkg/providers/{ctyun => tianyi}/oos.go | 8 ++- .../{ctyun/ctyun.go => tianyi/tianyi.go} | 8 +-- utils/const.go | 13 +++-- 22 files changed, 241 insertions(+), 66 deletions(-) rename pkg/providers/{baiducloud/baiducloud.go => baidu/baidu.go} (95%) rename pkg/providers/{baiducloud => baidu}/bcc.go (99%) rename pkg/providers/{baiducloud => baidu}/bos.go (87%) rename pkg/providers/{huaweicloud/huaweicloud.go => huawei/huawei.go} (94%) rename pkg/providers/{huaweicloud => huawei}/obs.go (97%) rename pkg/providers/{cucloud/cucloud.go => liantong/liantong.go} (94%) rename pkg/providers/{cucloud => liantong}/oss.go (99%) create mode 100644 pkg/providers/qiniu/kodo.go create mode 100644 pkg/providers/qiniu/qiniu.go rename pkg/providers/{tencentcloud => tencent}/cos.go (97%) rename pkg/providers/{tencentcloud => tencent}/cvm.go (99%) rename pkg/providers/{tencentcloud => tencent}/lh.go (99%) rename pkg/providers/{tencentcloud/tencentcloud.go => tencent/tencent.go} (95%) rename pkg/providers/{ctyun => tianyi}/oos.go (75%) rename pkg/providers/{ctyun/ctyun.go => tianyi/tianyi.go} (84%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c493726..4447169 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ # Change Log -## [v1.0.0](https://github.com/wgpsec/lc/releases/tag/v1.0.0) +## [v1.0.0](https://github.com/wgpsec/lc/releases/tag/v1.0.0) 2024.4.20 * 支持列出阿里云 RDS 数据库服务 * 支持列出腾讯云 COS 对象存储服务 +* 支持列出七牛云 Kodo 对象存储服务 * 增加详细日志输出 ## [v0.0.1](https://github.com/wgpsec/lc/releases/tag/v0.0.1) 2024.4.6 diff --git a/README.md b/README.md index eb3edbf..b2b6726 100644 --- a/README.md +++ b/README.md @@ -36,18 +36,19 @@ LC(List Cloud)是一个多云攻击面资产梳理的工具,使用 LC 可 ### 支持列出的云服务 | 序号 | 云服务商 | 服务名称 | -|:--:| :------: |:----------:| -| 1 | 阿里云 | ECS 云服务器 | -| 2 | 阿里云 | OSS 对象存储 | -| 3 | 阿里云 | RDS 数据库 | -| 4 | 腾讯云 | CVM 云服务器 | -| 5 | 腾讯云 | LH 轻量应用服务器 | -| 6 | 腾讯云 | COS 对象存储 | -| 7 | 华为云 | OBS 对象存储 | -| 8 | 天翼云 | OOS 对象存储 | -| 9 | 百度云 | BOS 对象存储 | -| 10 | 百度云 | BCC 云服务器 | -| 11 | 联通云 | OSS 对象存储 | +|:--:|:----:|:----------:| +| 1 | 阿里云 | ECS 云服务器 | +| 2 | 阿里云 | OSS 对象存储 | +| 3 | 阿里云 | RDS 数据库 | +| 4 | 腾讯云 | CVM 云服务器 | +| 5 | 腾讯云 | LH 轻量应用服务器 | +| 6 | 腾讯云 | COS 对象存储 | +| 7 | 华为云 | OBS 对象存储 | +| 8 | 天翼云 | OOS 对象存储 | +| 9 | 百度云 | BOS 对象存储 | +| 10 | 百度云 | BCC 云服务器 | +| 11 | 联通云 | OSS 对象存储 | +| 12 | 七牛云 | Kodo 对象存储 | ## 使用手册 diff --git a/cmd/configFile.go b/cmd/configFile.go index d9082b1..5db8eee 100644 --- a/cmd/configFile.go +++ b/cmd/configFile.go @@ -25,7 +25,7 @@ const defaultConfigFile = `# # lc (list cloud) 的云服务商配置文件 # # 腾讯云 # # 访问凭证获取地址:https://console.cloud.tencent.com/cam -# - provider: tencent cloud +# - provider: tencent # id: tencent_cloud_default # access_key: # secret_key: @@ -33,7 +33,7 @@ const defaultConfigFile = `# # lc (list cloud) 的云服务商配置文件 # # 华为云 # # 访问凭证获取地址:https://console.huaweicloud.com/iam -# - provider: huawei cloud +# - provider: huawei # id: huawei_cloud_default # access_key: # secret_key: @@ -41,14 +41,14 @@ const defaultConfigFile = `# # lc (list cloud) 的云服务商配置文件 # # 天翼云 # # 访问凭证获取地址:https://oos-cn.ctyun.cn/oos/ctyun/iam/dist/index.html#/certificate -# - provider: ctyun -# id: ctyun_default +# - provider: tianyi +# id: tianyi_cloud_default # access_key: # secret_key: # # 百度云 # # 访问凭证获取地址:https://console.bce.baidu.com/iam/ -# - provider: baidu cloud +# - provider: baidu # id: baidu_cloud_default # access_key: # secret_key: @@ -56,9 +56,16 @@ const defaultConfigFile = `# # lc (list cloud) 的云服务商配置文件 # # 联通云 # # 访问凭证获取地址:https://console.cucloud.cn/console/uiam -# - provider: cu cloud -# id: cu_cloud_default +# - provider: liantong +# id: liantong_cloud_default # access_key: # secret_key: # session_token: + +# # 七牛云 +# # 访问凭证获取地址:https://portal.qiniu.com/developer/user/key +# - provider: qiniu +# id: qiniu_cloud_default +# access_key: +# secret_key: ` diff --git a/go.mod b/go.mod index c7ccdfa..fb34caa 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/projectdiscovery/goflags v0.1.46 github.com/projectdiscovery/gologger v1.1.12 github.com/projectdiscovery/utils v0.0.87 + github.com/qiniu/go-sdk/v7 v7.20.0 github.com/teamssix/oos-go-sdk v0.0.1 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.893 github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.893 @@ -26,6 +27,7 @@ require ( github.com/clbanning/mxj v1.8.4 // indirect github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 // indirect github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect + github.com/gofrs/flock v0.8.1 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/gorilla/css v1.0.0 // indirect @@ -55,6 +57,7 @@ require ( golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.20.0 // indirect + golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect diff --git a/go.sum b/go.sum index 0a7b863..6058724 100644 --- a/go.sum +++ b/go.sum @@ -23,6 +23,7 @@ github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5P github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 h1:ox2F0PSMlrAAiAdknSRMDrAr8mfxPCfSZolH+/qQnyQ= github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08/go.mod h1:pCxVEbcm3AMg7ejXyorUXi6HQCzOIBf7zEDVPtw0/U4= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/dave/jennifer v1.6.1/go.mod h1:nXbxhEmQfOZhWml3D1cDK5M1FLnMSozpbFN/m3RmGZc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -32,6 +33,14 @@ github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj6 github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.8.0/go.mod h1:9JhgTzTaE31GZDpH/HSvHiRJrJ3iKAgqqH0Bl/Ocjdk= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -53,6 +62,7 @@ github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= github.com/huaweicloud/huaweicloud-sdk-go-obs v3.23.12+incompatible h1:6WXo8ZNdlLKO1drIRTaoArVwyMqvG1gXU30VmNHxqk8= github.com/huaweicloud/huaweicloud-sdk-go-obs v3.23.12+incompatible/go.mod h1:l7VUhRbTKCzdOacdT4oWCwATKyvZqUOlOqr0Ous3k4s= +github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= @@ -67,10 +77,15 @@ github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQs github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE= github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo= @@ -88,7 +103,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mozillazg/go-httpheader v0.2.1 h1:geV7TrjbL8KXSyvghnFm+NyTux/hxwueTSrwhe88TQQ= github.com/mozillazg/go-httpheader v0.2.1/go.mod h1:jJ8xECTlalr6ValeXYdOF8fFUISeBAdw6E61aqQma60= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9lEc= @@ -97,6 +111,7 @@ github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b h1:Ff github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b/go.mod h1:AC62GU6hc0BrNm+9RK9VSiwa/EUe1bkIeFORAMcHvJU= github.com/pierrec/lz4/v4 v4.1.2 h1:qvY3YFXRQE/XB8MlLzJH7mSzBs74eA2gg52YTk6jUPM= github.com/pierrec/lz4/v4 v4.1.2/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -109,10 +124,18 @@ github.com/projectdiscovery/gologger v1.1.12 h1:uX/QkQdip4PubJjjG0+uk5DtyAi1ANPJ github.com/projectdiscovery/gologger v1.1.12/go.mod h1:DI8nywPLERS5mo8QEA9E7gd5HZ3Je14SjJBH3F5/kLw= github.com/projectdiscovery/utils v0.0.87 h1:9+RiTEhpUB/vk6XJUVpysNWJ2aCTD7WuyoyAcNnbIzk= github.com/projectdiscovery/utils v0.0.87/go.mod h1:jGK450sL9AVDTjaPwEs9za8NVeEC9xE97IWNoK138kI= +github.com/qiniu/dyn v1.3.0/go.mod h1:E8oERcm8TtwJiZvkQPbcAh0RL8jO1G0VXJMW3FAWdkk= +github.com/qiniu/go-sdk/v7 v7.20.0 h1:pK2tk2qWpNtY0MWjc32oRlf3EHt6BaeWexl74jXkOTg= +github.com/qiniu/go-sdk/v7 v7.20.0/go.mod h1:ZnEP1rOOi7weF+yzM2qZMHI0z1ht+KjVuNAuKTQW3aM= +github.com/qiniu/x v1.10.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d h1:hrujxIzL1woJ7AwssoOcM/tq5JjjG2yYOc8odClEiXA= github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= @@ -144,10 +167,14 @@ github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8= github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo= github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -160,28 +187,51 @@ golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMx golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -192,15 +242,19 @@ gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/djherbis/times.v1 v1.3.0 h1:uxMS4iMtH6Pwsxog094W0FYldiNnfY/xba00vq6C2+o= gopkg.in/djherbis/times.v1 v1.3.0/go.mod h1:AQlg6unIsrsCEdQYhTzERy542dz6SFdQFZFv6mUY0P8= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/inventory/inventory.go b/pkg/inventory/inventory.go index a5d51a4..eb2ede9 100644 --- a/pkg/inventory/inventory.go +++ b/pkg/inventory/inventory.go @@ -3,11 +3,12 @@ package inventory import ( "fmt" "github.com/wgpsec/lc/pkg/providers/aliyun" - "github.com/wgpsec/lc/pkg/providers/baiducloud" - "github.com/wgpsec/lc/pkg/providers/ctyun" - "github.com/wgpsec/lc/pkg/providers/cucloud" - "github.com/wgpsec/lc/pkg/providers/huaweicloud" - "github.com/wgpsec/lc/pkg/providers/tencentcloud" + "github.com/wgpsec/lc/pkg/providers/baidu" + "github.com/wgpsec/lc/pkg/providers/huawei" + "github.com/wgpsec/lc/pkg/providers/liantong" + "github.com/wgpsec/lc/pkg/providers/qiniu" + "github.com/wgpsec/lc/pkg/providers/tencent" + "github.com/wgpsec/lc/pkg/providers/tianyi" "github.com/wgpsec/lc/pkg/schema" "github.com/wgpsec/lc/utils" ) @@ -37,16 +38,18 @@ func nameToProvider(value string, block schema.OptionBlock) (schema.Provider, er switch value { case utils.Aliyun: return aliyun.New(block) - case utils.TencentCloud: - return tencentcloud.New(block) - case utils.HuaweiCloud: - return huaweicloud.New(block) - case utils.Ctyun: - return ctyun.New(block) - case utils.BaiduCloud: - return baiducloud.New(block) - case utils.CuCloud: - return cucloud.New(block) + case utils.Tencent: + return tencent.New(block) + case utils.Huawei: + return huawei.New(block) + case utils.TianYi: + return tianyi.New(block) + case utils.Baidu: + return baidu.New(block) + case utils.LianTong: + return liantong.New(block) + case utils.QiNiu: + return qiniu.New(block) default: return nil, fmt.Errorf("发现无效的云服务商名: %s", value) } diff --git a/pkg/providers/baiducloud/baiducloud.go b/pkg/providers/baidu/baidu.go similarity index 95% rename from pkg/providers/baiducloud/baiducloud.go rename to pkg/providers/baidu/baidu.go index 6cf5a7d..fd64f3a 100644 --- a/pkg/providers/baiducloud/baiducloud.go +++ b/pkg/providers/baidu/baidu.go @@ -1,4 +1,4 @@ -package baiducloud +package baidu import ( "context" @@ -80,7 +80,7 @@ func New(options schema.OptionBlock) (*Provider, error) { okST: okST, } - return &Provider{provider: utils.BaiduCloud, id: id, bosClient: bosClient, config: config}, nil + return &Provider{provider: utils.Baidu, id: id, bosClient: bosClient, config: config}, nil } func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { diff --git a/pkg/providers/baiducloud/bcc.go b/pkg/providers/baidu/bcc.go similarity index 99% rename from pkg/providers/baiducloud/bcc.go rename to pkg/providers/baidu/bcc.go index 8911d28..7f70bc8 100644 --- a/pkg/providers/baiducloud/bcc.go +++ b/pkg/providers/baidu/bcc.go @@ -1,4 +1,4 @@ -package baiducloud +package baidu import ( "context" @@ -61,7 +61,6 @@ func (d *instanceProvider) describeInstances(ch <-chan string, wg *sync.WaitGrou bccClient *bcc.Client ) for endpoint := range ch { - if d.config.okST { bccClient, err = bcc.NewClient(d.config.accessKeyID, d.config.accessKeySecret, "") if err != nil { diff --git a/pkg/providers/baiducloud/bos.go b/pkg/providers/baidu/bos.go similarity index 87% rename from pkg/providers/baiducloud/bos.go rename to pkg/providers/baidu/bos.go index 019c20d..717c72e 100644 --- a/pkg/providers/baiducloud/bos.go +++ b/pkg/providers/baidu/bos.go @@ -1,8 +1,9 @@ -package baiducloud +package baidu import ( "context" "github.com/baidubce/bce-sdk-go/services/bos" + "github.com/projectdiscovery/gologger" "github.com/wgpsec/lc/pkg/schema" "strings" ) @@ -15,6 +16,7 @@ type bosProvider struct { func (d *bosProvider) GetResource(ctx context.Context) (*schema.Resources, error) { var list = schema.NewResources() + gologger.Debug().Msg("正在获取百度云 BOS 资源信息") response, err := d.bosClient.ListBuckets() if err != nil { return nil, err diff --git a/pkg/providers/huaweicloud/huaweicloud.go b/pkg/providers/huawei/huawei.go similarity index 94% rename from pkg/providers/huaweicloud/huaweicloud.go rename to pkg/providers/huawei/huawei.go index 87a8152..e95c94e 100644 --- a/pkg/providers/huaweicloud/huaweicloud.go +++ b/pkg/providers/huawei/huawei.go @@ -1,4 +1,4 @@ -package huaweicloud +package huawei import ( "context" @@ -47,7 +47,7 @@ func New(options schema.OptionBlock) (*Provider, error) { return nil, err } - return &Provider{provider: utils.HuaweiCloud, id: id, obsClient: obsClient}, nil + return &Provider{provider: utils.Huawei, id: id, obsClient: obsClient}, nil } func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { diff --git a/pkg/providers/huaweicloud/obs.go b/pkg/providers/huawei/obs.go similarity index 97% rename from pkg/providers/huaweicloud/obs.go rename to pkg/providers/huawei/obs.go index 528a95f..219931f 100644 --- a/pkg/providers/huaweicloud/obs.go +++ b/pkg/providers/huawei/obs.go @@ -1,4 +1,4 @@ -package huaweicloud +package huawei import ( "context" diff --git a/pkg/providers/cucloud/cucloud.go b/pkg/providers/liantong/liantong.go similarity index 94% rename from pkg/providers/cucloud/cucloud.go rename to pkg/providers/liantong/liantong.go index 73fc708..461f2cb 100644 --- a/pkg/providers/cucloud/cucloud.go +++ b/pkg/providers/liantong/liantong.go @@ -1,4 +1,4 @@ -package cucloud +package liantong import ( "context" @@ -38,7 +38,7 @@ func New(options schema.OptionBlock) (*Provider, error) { accessKeySecret: accessKeySecret, sessionToken: sessionToken, } - return &Provider{id: id, provider: utils.CuCloud, config: config}, nil + return &Provider{id: id, provider: utils.LianTong, config: config}, nil } func (p *Provider) Name() string { diff --git a/pkg/providers/cucloud/oss.go b/pkg/providers/liantong/oss.go similarity index 99% rename from pkg/providers/cucloud/oss.go rename to pkg/providers/liantong/oss.go index e4ca2b1..a95429e 100644 --- a/pkg/providers/cucloud/oss.go +++ b/pkg/providers/liantong/oss.go @@ -1,4 +1,4 @@ -package cucloud +package liantong import ( "context" diff --git a/pkg/providers/qiniu/kodo.go b/pkg/providers/qiniu/kodo.go new file mode 100644 index 0000000..40e8b7b --- /dev/null +++ b/pkg/providers/qiniu/kodo.go @@ -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 +} diff --git a/pkg/providers/qiniu/qiniu.go b/pkg/providers/qiniu/qiniu.go new file mode 100644 index 0000000..aa08edf --- /dev/null +++ b/pkg/providers/qiniu/qiniu.go @@ -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 +} diff --git a/pkg/providers/tencentcloud/cos.go b/pkg/providers/tencent/cos.go similarity index 97% rename from pkg/providers/tencentcloud/cos.go rename to pkg/providers/tencent/cos.go index 6c560ca..6481e6a 100644 --- a/pkg/providers/tencentcloud/cos.go +++ b/pkg/providers/tencent/cos.go @@ -1,4 +1,4 @@ -package tencentcloud +package tencent import ( "context" diff --git a/pkg/providers/tencentcloud/cvm.go b/pkg/providers/tencent/cvm.go similarity index 99% rename from pkg/providers/tencentcloud/cvm.go rename to pkg/providers/tencent/cvm.go index 892d98b..e50cc3e 100644 --- a/pkg/providers/tencentcloud/cvm.go +++ b/pkg/providers/tencent/cvm.go @@ -1,4 +1,4 @@ -package tencentcloud +package tencent import ( "context" diff --git a/pkg/providers/tencentcloud/lh.go b/pkg/providers/tencent/lh.go similarity index 99% rename from pkg/providers/tencentcloud/lh.go rename to pkg/providers/tencent/lh.go index 3f66fda..0734223 100644 --- a/pkg/providers/tencentcloud/lh.go +++ b/pkg/providers/tencent/lh.go @@ -1,4 +1,4 @@ -package tencentcloud +package tencent import ( "context" diff --git a/pkg/providers/tencentcloud/tencentcloud.go b/pkg/providers/tencent/tencent.go similarity index 95% rename from pkg/providers/tencentcloud/tencentcloud.go rename to pkg/providers/tencent/tencent.go index 9d9cdd9..93d227e 100644 --- a/pkg/providers/tencentcloud/tencentcloud.go +++ b/pkg/providers/tencent/tencent.go @@ -1,4 +1,4 @@ -package tencentcloud +package tencent import ( "context" @@ -84,7 +84,7 @@ func New(options schema.OptionBlock) (*Provider, error) { }, }) - return &Provider{id: id, provider: utils.TencentCloud, credential: credential, cvmRegions: cvmRegions, lhRegions: lhRegions, cosClient: cosClient}, nil + return &Provider{id: id, provider: utils.Tencent, credential: credential, cvmRegions: cvmRegions, lhRegions: lhRegions, cosClient: cosClient}, nil } func (p *Provider) Name() string { diff --git a/pkg/providers/ctyun/oos.go b/pkg/providers/tianyi/oos.go similarity index 75% rename from pkg/providers/ctyun/oos.go rename to pkg/providers/tianyi/oos.go index 1f23f0d..7f54594 100644 --- a/pkg/providers/ctyun/oos.go +++ b/pkg/providers/tianyi/oos.go @@ -1,20 +1,22 @@ -package ctyun +package tianyi import ( "context" + "github.com/projectdiscovery/gologger" "github.com/teamssix/oos-go-sdk/oos" "github.com/wgpsec/lc/pkg/schema" "strings" ) -type obsProvider struct { +type oosProvider struct { id string provider string oosClient *oos.Client } -func (d *obsProvider) GetResource(ctx context.Context) (*schema.Resources, error) { +func (d *oosProvider) GetResource(ctx context.Context) (*schema.Resources, error) { var list = schema.NewResources() + gologger.Debug().Msg("正在获取天翼云 OOS 资源信息") response, err := d.oosClient.ListBuckets() if err != nil { return nil, err diff --git a/pkg/providers/ctyun/ctyun.go b/pkg/providers/tianyi/tianyi.go similarity index 84% rename from pkg/providers/ctyun/ctyun.go rename to pkg/providers/tianyi/tianyi.go index 6d5a200..ca7c139 100644 --- a/pkg/providers/ctyun/ctyun.go +++ b/pkg/providers/tianyi/tianyi.go @@ -1,4 +1,4 @@ -package ctyun +package tianyi import ( "context" @@ -39,17 +39,17 @@ func New(options schema.OptionBlock) (*Provider, error) { return nil, err } - return &Provider{provider: utils.Ctyun, id: id, oosClient: oosClient}, nil + return &Provider{provider: utils.TianYi, id: id, oosClient: oosClient}, nil } func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { var err error - oosProvider := &obsProvider{oosClient: p.oosClient, id: p.id, provider: p.provider} + oosProvider := &oosProvider{oosClient: p.oosClient, id: p.id, provider: p.provider} buckets, err := oosProvider.GetResource(ctx) if err != nil { return nil, err } - gologger.Info().Msgf("获取到 %d 条天翼云 OOS 信息", len(buckets.Items)) + gologger.Info().Msgf("获取到 %d 条天翼云 OOS 对象存储信息", len(buckets.Items)) finalList := schema.NewResources() finalList.Merge(buckets) return finalList, nil diff --git a/utils/const.go b/utils/const.go index daef2c2..e98a09f 100644 --- a/utils/const.go +++ b/utils/const.go @@ -9,10 +9,11 @@ const ( ) const ( - Aliyun = "aliyun" - TencentCloud = "tencent cloud" - HuaweiCloud = "huawei cloud" - Ctyun = "ctyun" - BaiduCloud = "baidu cloud" - CuCloud = "cu cloud" + Aliyun = "aliyun" + Tencent = "tencent" + Huawei = "huawei" + TianYi = "tianyi" + Baidu = "baidu" + LianTong = "liantong" + QiNiu = "qiniu" )