diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index e87bb8d0..47835fd7 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -13,7 +13,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - go-version: [1.21.x] + go-version: [1.22.x] os: [ubuntu-latest, windows-latest, macOS-12] steps: - name: Set up Go diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index 24d556a9..3d30a22c 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -15,7 +15,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.22.x - name: Checkout code uses: actions/checkout@v4 - name: Run golangci-lint diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index 0499cb75..1be42144 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.22.x - uses: goreleaser/goreleaser-action@v5 with: diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml index 75c38030..0552e16e 100644 --- a/.github/workflows/release-test.yml +++ b/.github/workflows/release-test.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.22.x - name: release test uses: goreleaser/goreleaser-action@v5 diff --git a/go.mod b/go.mod index e2238444..887e2bcd 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/projectdiscovery/cloudlist -go 1.21 +go 1.22.2 + +toolchain go1.22.3 require ( github.com/Azure/azure-sdk-for-go v68.0.0+incompatible @@ -30,12 +32,12 @@ require ( github.com/projectdiscovery/utils v0.1.5 github.com/scaleway/scaleway-sdk-go v1.0.0-beta.14 github.com/stretchr/testify v1.9.0 - golang.org/x/oauth2 v0.12.0 + golang.org/x/oauth2 v0.15.0 google.golang.org/api v0.126.0 gopkg.in/yaml.v2 v2.4.0 - k8s.io/api v0.28.2 - k8s.io/apimachinery v0.28.2 - k8s.io/client-go v0.28.2 + k8s.io/api v0.30.0 + k8s.io/apimachinery v0.30.0 + k8s.io/client-go v0.30.0 ) require ( @@ -67,33 +69,31 @@ require ( github.com/dimchansky/utfbom v1.1.1 // indirect github.com/dlclark/regexp2 v1.8.1 // indirect github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect - github.com/emicklei/go-restful/v3 v3.9.0 // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/fatih/color v1.15.0 // indirect - github.com/go-logr/logr v1.2.4 // indirect + github.com/go-logr/logr v1.4.1 // indirect github.com/go-ole/go-ole v1.2.6 // indirect - github.com/go-openapi/jsonpointer v0.19.6 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/swag v0.22.3 // indirect + github.com/go-openapi/jsonpointer v0.20.2 // indirect + github.com/go-openapi/jsonreference v0.20.4 // indirect + github.com/go-openapi/swag v0.22.7 // indirect github.com/go-resty/resty/v2 v2.7.0 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v4 v4.2.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/gnostic-models v0.6.8 // indirect - github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-github/v30 v30.1.0 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/jsonapi v0.0.0-20201022225600-f822737867f6 // indirect github.com/google/s2a-go v0.1.4 // indirect - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/google/uuid v1.3.1 // indirect + github.com/google/uuid v1.5.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect github.com/googleapis/gax-go/v2 v2.11.0 // indirect github.com/gorilla/css v1.0.0 // indirect - github.com/gorilla/websocket v1.4.1 // indirect + github.com/gorilla/websocket v1.5.0 // indirect github.com/hashicorp/cronexpr v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.2.0 // indirect @@ -101,7 +101,7 @@ require ( github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/serf v0.10.1 // indirect - github.com/imdario/mergo v0.3.6 // indirect + github.com/imdario/mergo v0.3.16 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/klauspost/compress v1.16.7 // indirect @@ -134,10 +134,10 @@ require ( github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/projectdiscovery/blackrock v0.0.1 // indirect github.com/projectdiscovery/machineid v0.0.0-20240226150047-2e2c51e35983 // indirect - github.com/prometheus/client_golang v1.15.1 // indirect - github.com/prometheus/client_model v0.3.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect + github.com/prometheus/client_golang v1.16.0 // indirect + github.com/prometheus/client_model v0.4.0 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.10.1 // indirect github.com/rivo/uniseg v0.4.4 // indirect github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect github.com/shirou/gopsutil/v3 v3.23.7 // indirect @@ -160,14 +160,14 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect - golang.org/x/mod v0.12.0 // indirect + golang.org/x/mod v0.15.0 // indirect golang.org/x/net v0.23.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/term v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.13.0 // indirect - google.golang.org/appengine v1.6.7 // indirect + golang.org/x/time v0.5.0 // indirect + golang.org/x/tools v0.18.0 // indirect + google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect google.golang.org/grpc v1.55.0 // indirect google.golang.org/protobuf v1.33.0 // indirect @@ -175,10 +175,17 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/ini.v1 v1.66.6 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/klog/v2 v2.100.1 // indirect - k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect - k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect + k8s.io/klog/v2 v2.120.1 // indirect + k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect + k8s.io/utils v0.0.0-20240102154912-e7106e64919e // indirect + sigs.k8s.io/aws-iam-authenticator v0.6.20 sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect + sigs.k8s.io/yaml v1.4.0 // indirect +) + +require ( + github.com/gofrs/flock v0.8.1 // indirect + github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect ) diff --git a/go.sum b/go.sum index f66816ad..1b11e865 100644 --- a/go.sum +++ b/go.sum @@ -96,7 +96,6 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= 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/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= @@ -116,8 +115,8 @@ github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 h1:iFaUwBSo5Svw6L7HYpRu/0lE3e0BaElwnNO1qkNQxBY= github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj60/X5sZFNxpG4HBPDHVqxNm4DfnCKgrbZOT+s= github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY= -github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE= -github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -135,17 +134,16 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= -github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= -github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= -github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= -github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= -github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q= +github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs= +github.com/go-openapi/jsonreference v0.20.4 h1:bKlDxQxQJgwpUSgOENiMPzCTBVuc7vTdXSSgNeAhojU= +github.com/go-openapi/jsonreference v0.20.4/go.mod h1:5pZJyJP2MnYCpoeoMAql78cCHauHj0V9Lhc506VOpw4= +github.com/go-openapi/swag v0.22.7 h1:JWrc1uc/P9cSomxfnsFSVWoE1FW6bNbrVPmpQYpCcR8= +github.com/go-openapi/swag v0.22.7/go.mod h1:Gl91UqO+btAM0plGGxHqJcQZ1ZTy6jbmridBTsDy8A0= github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= @@ -153,6 +151,8 @@ github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEe github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -169,7 +169,6 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= @@ -180,8 +179,8 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -200,8 +199,9 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github/v30 v30.1.0 h1:VLDx+UolQICEOKu2m4uAoMti1SxuEBAl7RSEG16L+Oo= github.com/google/go-github/v30 v30.1.0/go.mod h1:n8jBpHl45a/rlBUtRJMOG4GhNADUQFEufcolZ95JfU8= github.com/google/go-github/v50 v50.1.0/go.mod h1:Ev4Tre8QoKiolvbpOSG3FIi4Mlon3S2Nt9W5JYqKiwA= @@ -222,8 +222,8 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaU github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= github.com/googleapis/enterprise-certificate-proxy v0.2.3/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cUUI8Ki4= @@ -232,8 +232,9 @@ github.com/gophercloud/gophercloud v1.7.0 h1:fyJGKh0LBvIZKLvBWvQdIgkaV5yTM3Jh9EY github.com/gophercloud/gophercloud v1.7.0/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM= 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/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/consul/api v1.20.0 h1:9IHTjNVSZ7MIwjlW3N3a7iGiykCMDpxZu8jsxFJh0yc= github.com/hashicorp/consul/api v1.20.0/go.mod h1:nR64eD44KQ59Of/ECwt2vUmIK2DKsDzAwTmwmLl8Wpo= @@ -291,8 +292,8 @@ github.com/heroku/heroku-go/v5 v5.5.0 h1:+pKHpiPskqkkarrPHF7RpeUveXl+mAsKLAEI/ZI github.com/heroku/heroku-go/v5 v5.5.0/go.mod h1:Uo3XhGPwaTpniR4X1e50BDjg4SzdFk2Bd2mgYZVkfHo= github.com/hetznercloud/hcloud-go v1.45.1 h1:nl0OOklFfQT5J6AaNIOhl5Ruh3fhmGmhvZEqHbibVuk= github.com/hetznercloud/hcloud-go v1.45.1/go.mod h1:aAUGxSfSnB8/lVXHNEDxtCT1jykaul8kqjD7f5KQXF8= -github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= -github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= +github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= 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= @@ -318,7 +319,6 @@ github.com/klauspost/pgzip v1.2.5/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= 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.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -398,10 +398,10 @@ github.com/nwaples/rardecode v1.1.3 h1:cWCaZwfM5H7nAD6PyEdcVnczzV8i/JtotnyW/dD9l github.com/nwaples/rardecode v1.1.3/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onsi/ginkgo/v2 v2.9.4 h1:xR7vG4IXt5RWx6FfIjyAtsoMAtnc3C/rFXBBd2AjZwE= -github.com/onsi/ginkgo/v2 v2.9.4/go.mod h1:gCQYp2Q+kSoIj7ykSVb9nskRSsR6PUj4AiLywzIhbKM= -github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= -github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= +github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= +github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= +github.com/onsi/gomega v1.31.0 h1:54UJxxj6cPInHS3a35wm6BK/F9nHYueZ1NVujHDrnXE= +github.com/onsi/gomega v1.31.0/go.mod h1:DW9aCi7U6Yi40wNVAvT6kzFnEVEI5n3DloYBiKiT6zk= github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b h1:FfH+VrHHk6Lxt9HdVS0PXzSXFyS2NbZKXv33FYPol0A= github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b/go.mod h1:AC62GU6hc0BrNm+9RK9VSiwa/EUe1bkIeFORAMcHvJU= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -434,31 +434,31 @@ github.com/projectdiscovery/utils v0.1.5/go.mod h1:NhjK2eVeoXLIZIYBJ2Z7yl6V4sB6X github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_golang v1.15.1 h1:8tXpTmJbyH5lydzFPoxSIJ0J46jdh3tylbvM1xCv0LI= -github.com/prometheus/client_golang v1.15.1/go.mod h1:e9yaBhRPU2pPNsZwE+JdQl0KEt1N9XgF6zxWmaC0xOk= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= -github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= +github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= +github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= 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= @@ -474,6 +474,8 @@ github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -568,8 +570,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -600,8 +602,8 @@ golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.5.0/go.mod h1:9/XBHVqLaWO3/BRHs5jbpYCnOZVjj5V0ndyaAM7KB4I= -golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4= -golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4= +golang.org/x/oauth2 v0.15.0 h1:s8pnnxNVzjWyrvYdFUQq5llS1PX2zhPXmccZv99h7uQ= +golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -639,6 +641,7 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/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-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -670,8 +673,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= 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.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +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-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -685,8 +688,8 @@ golang.org/x/tools v0.0.0-20200624163319-25775e59acb7/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= +golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -695,8 +698,9 @@ google.golang.org/api v0.126.0 h1:q4GJq+cAdMAC7XP7njvQ4tvohGLiSlytuL4BQxbIZ+o= google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= @@ -762,21 +766,23 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.28.2 h1:9mpl5mOb6vXZvqbQmankOfPIGiudghwCoLl1EYfUZbw= -k8s.io/api v0.28.2/go.mod h1:RVnJBsjU8tcMq7C3iaRSGMeaKt2TWEUXcpIt/90fjEg= -k8s.io/apimachinery v0.28.2 h1:KCOJLrc6gu+wV1BYgwik4AF4vXOlVJPdiqn0yAWWwXQ= -k8s.io/apimachinery v0.28.2/go.mod h1:RdzF87y/ngqk9H4z3EL2Rppv5jj95vGS/HaFXrLDApU= -k8s.io/client-go v0.28.2 h1:DNoYI1vGq0slMBN/SWKMZMw0Rq+0EQW6/AK4v9+3VeY= -k8s.io/client-go v0.28.2/go.mod h1:sMkApowspLuc7omj1FOSUxSoqjr+d5Q0Yc0LOFnYFJY= -k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= -k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk= -k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/api v0.30.0 h1:siWhRq7cNjy2iHssOB9SCGNCl2spiF1dO3dABqZ8niA= +k8s.io/api v0.30.0/go.mod h1:OPlaYhoHs8EQ1ql0R/TsUgaRPhpKNxIMrKQfWUp8QSE= +k8s.io/apimachinery v0.30.0 h1:qxVPsyDM5XS96NIh9Oj6LavoVFYff/Pon9cZeDIkHHA= +k8s.io/apimachinery v0.30.0/go.mod h1:iexa2somDaxdnj7bha06bhb43Zpa6eWH8N8dbqVjTUc= +k8s.io/client-go v0.30.0 h1:sB1AGGlhY/o7KCyCEQ0bPWzYDL0pwOZO4vAtTSh/gJQ= +k8s.io/client-go v0.30.0/go.mod h1:g7li5O5256qe6TYdAMyX/otJqMhIiGgTapdLchhmOaY= +k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw= +k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag= +k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98= +k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ= +k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/aws-iam-authenticator v0.6.20 h1:heAGFNUkYJafT165FOlTWQT1S6UULTHa61w5mHJuSXk= +sigs.k8s.io/aws-iam-authenticator v0.6.20/go.mod h1:wOXhEO/yKuFQUNIL9uq43vA+/E+k5kb/w1KoZbvEvSk= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/internal/runner/options.go b/internal/runner/options.go index 3e5ba803..a543b96e 100644 --- a/internal/runner/options.go +++ b/internal/runner/options.go @@ -7,6 +7,7 @@ import ( "os/user" "path/filepath" + "github.com/projectdiscovery/cloudlist/pkg/inventory" "github.com/projectdiscovery/cloudlist/pkg/schema" "github.com/projectdiscovery/goflags" "github.com/projectdiscovery/gologger" @@ -27,17 +28,32 @@ type Options struct { Config string // Config is the location of the config file. Output string // Output is the file to write found results too. ExcludePrivate bool // ExcludePrivate excludes private IPs from results - Provider goflags.StringSlice // Provider specifies what providers to fetch assets for. + Provider []string // Provider specifies what providers to fetch assets for. Id goflags.StringSlice // Id specifies what id's to fetch assets for. + Services []string // Services specifies what services to fetch assets for a provider. ProviderConfig string // ProviderConfig is the location of the provider config file. DisableUpdateCheck bool // DisableUpdateCheck disable automatic update check } var ( - defaultConfigLocation = filepath.Join(userHomeDir(), ".config/cloudlist/config.yaml") - defaultProviderConfigLocation = filepath.Join(userHomeDir(), ".config/cloudlist/provider-config.yaml") + defaultConfigLocation = filepath.Join(userHomeDir(), ".config/cloudlist/config.yaml") + defaultProviderConfigLocation = filepath.Join(userHomeDir(), ".config/cloudlist/provider-config.yaml") + defaultProviders, defaultServies = []goflags.EnumVariable{}, []goflags.EnumVariable{} + allowedProviders, allowedServices = goflags.AllowdTypes{}, goflags.AllowdTypes{} ) +func init() { + for i, provider := range inventory.GetProviders() { + allowedProviders[provider] = goflags.EnumVariable(i) + defaultProviders = append(defaultProviders, goflags.EnumVariable(i)) + } + + for i, service := range inventory.GetServices() { + defaultServies = append(defaultServies, goflags.EnumVariable(i)) + allowedServices[service] = goflags.EnumVariable(i) + } +} + // ParseOptions parses the command line flags provided by a user func ParseOptions() *Options { // Migrate config to provider config @@ -61,10 +77,11 @@ func ParseOptions() *Options { flagSet.StringVarP(&options.ProviderConfig, "provider-config", "pc", defaultProviderConfigLocation, "provider config file"), ) flagSet.CreateGroup("filter", "Filters", - flagSet.StringSliceVarP(&options.Provider, "provider", "p", nil, "display results for given providers (comma-separated)", goflags.NormalizedStringSliceOptions), + flagSet.EnumSliceVarP(&options.Provider, "provider", "p", defaultProviders, "display results for given providers (comma-separated)", allowedProviders), flagSet.StringSliceVar(&options.Id, "id", nil, "display results for given ids (comma-separated)", goflags.NormalizedStringSliceOptions), flagSet.BoolVar(&options.Hosts, "host", false, "display only hostnames in results"), flagSet.BoolVar(&options.IPAddress, "ip", false, "display only ips in results"), + flagSet.EnumSliceVarP(&options.Services, "service", "s", defaultServies, "query and display results from given service (comma-separated))", allowedServices), flagSet.BoolVarP(&options.ExcludePrivate, "exclude-private", "ep", false, "exclude private ips in cli output"), ) flagSet.CreateGroup("update", "Update", diff --git a/internal/runner/runner.go b/internal/runner/runner.go index 4b178345..79f6a74e 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -37,6 +37,10 @@ func New(options *Options) (*Runner, error) { // Enumerate performs the cloudlist enumeration process func (r *Runner) Enumerate() { finalConfig := schema.Options{} + services := []string{} + if r.options.Services != nil { + services = r.options.Services + } for _, item := range r.config { if item == nil { @@ -45,6 +49,9 @@ func (r *Runner) Enumerate() { if _, ok := item["id"]; !ok { item["id"] = "" } + if len(services) > 0 { + item["services"] = strings.Join(services, ",") + } // Validate and only pass the correct items to input if len(r.options.Provider) != 0 || len(r.options.Id) != 0 { if len(r.options.Provider) != 0 && !Contains(r.options.Provider, item["provider"]) { @@ -75,8 +82,8 @@ func (r *Runner) Enumerate() { builder := &bytes.Buffer{} for _, provider := range inventory.Providers { + gologger.Info().Msgf("Listing assets from provider: %s services: %s id: %s", provider.Name(), strings.Join(provider.Services(), ","), provider.ID()) - gologger.Info().Msgf("Listing assets from %s (%s) provider\n", provider.Name(), provider.ID()) instances, err := provider.Resources(context.Background()) if err != nil { gologger.Warning().Msgf("Could not get resources for provider %s %s: %s\n", provider.Name(), provider.ID(), err) diff --git a/pkg/inventory/inventory.go b/pkg/inventory/inventory.go index 9c7f0f60..77c00f50 100644 --- a/pkg/inventory/inventory.go +++ b/pkg/inventory/inventory.go @@ -21,6 +21,7 @@ import ( "github.com/projectdiscovery/cloudlist/pkg/providers/scaleway" "github.com/projectdiscovery/cloudlist/pkg/providers/terraform" "github.com/projectdiscovery/cloudlist/pkg/schema" + mapsutil "github.com/projectdiscovery/utils/maps" ) // Inventory is an inventory of providers @@ -29,10 +30,10 @@ type Inventory struct { } // New creates a new inventory of providers -func New(options schema.Options) (*Inventory, error) { +func New(optionBlocks schema.Options) (*Inventory, error) { inventory := &Inventory{} - for _, block := range options { + for _, block := range optionBlocks { value, ok := block.GetMetadata("provider") if !ok { continue @@ -46,6 +47,41 @@ func New(options schema.Options) (*Inventory, error) { return inventory, nil } +var Providers = map[string][]string{ + "aws": aws.Services, + "do": digitalocean.Services, + "digitalocean": digitalocean.Services, + "gcp": gcp.Services, + "scw": scaleway.Services, + "azure": azure.Services, + "cloudflare": cloudflare.Services, + "heroku": heroku.Services, + "linode": linode.Services, + "fastly": fastly.Services, + "alibaba": alibaba.Services, + "namecheap": namecheap.Services, + "terraform": terraform.Services, + "consul": consul.Services, + "nomad": nomad.Services, + "hetzner": hetzner.Services, + "openstack": openstack.Services, + "kubernetes": k8s.Services, +} + +func GetProviders() []string { + return mapsutil.GetKeys(Providers) +} + +func GetServices() []string { + services := make(map[string]struct{}) + for _, s := range Providers { + for _, service := range s { + services[service] = struct{}{} + } + } + return mapsutil.GetKeys(services) +} + // nameToProvider returns the provider for a name func nameToProvider(value string, block schema.OptionBlock) (schema.Provider, error) { switch value { diff --git a/pkg/providers/alibaba/alibaba.go b/pkg/providers/alibaba/alibaba.go index acc56e4a..651a556b 100644 --- a/pkg/providers/alibaba/alibaba.go +++ b/pkg/providers/alibaba/alibaba.go @@ -2,11 +2,14 @@ package alibaba import ( "context" + "strings" "github.com/aliyun/alibaba-cloud-sdk-go/services/ecs" "github.com/projectdiscovery/cloudlist/pkg/schema" ) +var Services = []string{"instance"} + const ( regionID = "alibaba_region_id" accessKeyID = "alibaba_access_key" @@ -16,8 +19,9 @@ const ( // Provider is a data provider for alibaba API type Provider struct { - id string - client *ecs.Client + id string + ecsClient *ecs.Client + services schema.ServiceMap } // New creates a new provider client for alibaba API @@ -36,17 +40,40 @@ func New(options schema.OptionBlock) (*Provider, error) { } id, _ := options.GetMetadata("id") + provider := &Provider{id: id} - client, err := ecs.NewClientWithAccessKey( - regionID, // region ID - accessKeyID, // AccessKey ID - accessKeySecret, // AccessKey secret - ) - if err != nil { - return nil, err + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } + provider.services = services - return &Provider{client: client, id: id}, nil + if services.Has("instance") { + client, err := ecs.NewClientWithAccessKey( + regionID, // region ID + accessKeyID, // AccessKey ID + accessKeySecret, // AccessKey secret + ) + if err != nil { + return nil, err + } + provider.ecsClient = client + } + + return provider, nil } // Name returns the name of the provider @@ -59,12 +86,16 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // Resources returns the provider for an resource deployment source. func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { - ecsprovider := &instanceProvider{client: p.client, id: p.id} - list, err := ecsprovider.GetResource(ctx) - if err != nil { - return nil, err + if p.ecsClient != nil { + ecsprovider := &instanceProvider{client: p.ecsClient, id: p.id} + return ecsprovider.GetResource(ctx) } - return list, nil + return nil, nil } diff --git a/pkg/providers/aws/alb.go b/pkg/providers/aws/alb.go new file mode 100644 index 00000000..1467ff32 --- /dev/null +++ b/pkg/providers/aws/alb.go @@ -0,0 +1,121 @@ +package aws + +import ( + "context" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/ec2" + "github.com/aws/aws-sdk-go/service/elbv2" + "github.com/pkg/errors" + "github.com/projectdiscovery/cloudlist/pkg/schema" +) + +// elbV2Provider is a provider for AWS Application Load Balancing (ELBV2) resources +type elbV2Provider struct { + id string + albClient *elbv2.ELBV2 + session *session.Session + regions *ec2.DescribeRegionsOutput +} + +func (ep *elbV2Provider) name() string { + return "alb" +} + +// GetResource returns all the resources in the store for a provider. +func (ep *elbV2Provider) GetResource(ctx context.Context) (*schema.Resources, error) { + list := schema.NewResources() + + for _, region := range ep.regions.Regions { + regionName := *region.RegionName + albClient := elbv2.New(ep.session, aws.NewConfig().WithRegion(regionName)) + ec2Client := ec2.New(ep.session, aws.NewConfig().WithRegion(regionName)) + if resources, err := ep.listELBV2Resources(albClient, ec2Client); err == nil { + list.Merge(resources) + } + } + return list, nil +} + +func (ep *elbV2Provider) listELBV2Resources(albClient *elbv2.ELBV2, ec2Client *ec2.EC2) (*schema.Resources, error) { + list := schema.NewResources() + + loadBalancers, err := ep.getLoadBalancers(albClient) + if err != nil { + return nil, errors.Wrap(err, "could not list load balancers") + } + + for _, lb := range loadBalancers { + albDNS := *lb.DNSName + resource := &schema.Resource{ + Provider: "aws", + ID: *lb.LoadBalancerName, + DNSName: albDNS, + Public: true, + Service: ep.name(), + } + list.Append(resource) + // Describe targets for the Load Balancer + targetsOutput, err := albClient.DescribeTargetGroups(&elbv2.DescribeTargetGroupsInput{ + LoadBalancerArn: lb.LoadBalancerArn, + }) + if err != nil { + continue + } + + for _, tg := range targetsOutput.TargetGroups { + targets, err := albClient.DescribeTargetHealth(&elbv2.DescribeTargetHealthInput{ + TargetGroupArn: tg.TargetGroupArn, + }) + if err != nil { + continue + } + + for _, target := range targets.TargetHealthDescriptions { + instanceID := *target.Target.Id + instanceOutput, err := ec2Client.DescribeInstances(&ec2.DescribeInstancesInput{ + InstanceIds: []*string{&instanceID}, + }) + if err != nil { + return nil, errors.Wrapf(err, "could not describe instance %s", instanceID) + } + // Extract private IP address + for _, reservation := range instanceOutput.Reservations { + for _, instance := range reservation.Instances { + if instance.PrivateIpAddress != nil { + resource := &schema.Resource{ + Provider: "aws", + ID: instanceID, + PrivateIpv4: *instance.PrivateIpAddress, + Public: false, + Service: ep.name(), + } + list.Append(resource) + } + } + } + } + } + } + return list, nil +} + +func (ep *elbV2Provider) getLoadBalancers(albClient *elbv2.ELBV2) ([]*elbv2.LoadBalancer, error) { + var loadBalancers []*elbv2.LoadBalancer + req := &elbv2.DescribeLoadBalancersInput{ + PageSize: aws.Int64(20), + } + for { + lbOutput, err := albClient.DescribeLoadBalancers(req) + if err != nil { + return nil, errors.Wrap(err, "could not describe load balancers") + } + loadBalancers = append(loadBalancers, lbOutput.LoadBalancers...) + if aws.StringValue(req.Marker) == "" { + break + } + req.SetMarker(aws.StringValue(req.Marker)) + } + return loadBalancers, nil +} diff --git a/pkg/providers/aws/aws.go b/pkg/providers/aws/aws.go index 998f4519..5a7c3852 100644 --- a/pkg/providers/aws/aws.go +++ b/pkg/providers/aws/aws.go @@ -2,25 +2,45 @@ package aws import ( "context" + "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/credentials" "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/apigateway" + "github.com/aws/aws-sdk-go/service/cloudfront" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/aws/aws-sdk-go/service/ecs" + "github.com/aws/aws-sdk-go/service/eks" + "github.com/aws/aws-sdk-go/service/elb" + "github.com/aws/aws-sdk-go/service/elbv2" + "github.com/aws/aws-sdk-go/service/lambda" + "github.com/aws/aws-sdk-go/service/lightsail" "github.com/aws/aws-sdk-go/service/route53" "github.com/aws/aws-sdk-go/service/s3" "github.com/pkg/errors" "github.com/projectdiscovery/cloudlist/pkg/schema" ) +var Services = []string{"ec2", "route53", "s3", "ecs", "eks", "lambda", "apigateway", "alb", "elb", "lightsail", "cloudfront"} + // Provider is a data provider for aws API type Provider struct { - id string - ec2Client *ec2.EC2 - route53Client *route53.Route53 - s3Client *s3.S3 - regions *ec2.DescribeRegionsOutput - session *session.Session + id string + ec2Client *ec2.EC2 + route53Client *route53.Route53 + s3Client *s3.S3 + ecsClient *ecs.ECS + eksClient *eks.EKS + lambdaClient *lambda.Lambda + apiGateway *apigateway.APIGateway + albClient *elbv2.ELBV2 + elbClient *elb.ELB + lightsailClient *lightsail.Lightsail + cloudFrontClient *cloudfront.CloudFront + regions *ec2.DescribeRegionsOutput + session *session.Session + services schema.ServiceMap } // New creates a new provider client for aws API @@ -34,8 +54,9 @@ func New(options schema.OptionBlock) (*Provider, error) { return nil, &schema.ErrNoSuchKey{Name: apiSecretKey} } + provider := &Provider{} token, _ := options.GetMetadata(sessionToken) - id, _ := options.GetMetadata("id") + provider.id, _ = options.GetMetadata("id") config := aws.NewConfig() config.WithRegion("us-east-1") config.WithCredentials(credentials.NewStaticCredentials(accessKey, accessToken, token)) @@ -44,16 +65,66 @@ func New(options schema.OptionBlock) (*Provider, error) { if err != nil { return nil, errors.Wrap(err, "could not extablish a session") } - - ec2Client := ec2.New(session) - route53Client := route53.New(session) - s3Client := s3.New(session) - - regions, err := ec2Client.DescribeRegions(&ec2.DescribeRegionsInput{}) + provider.session = session + rc := ec2.New(session) + regions, err := rc.DescribeRegions(&ec2.DescribeRegionsInput{}) if err != nil { return nil, errors.Wrap(err, "could not get list of regions") } - return &Provider{ec2Client: ec2Client, id: id, regions: regions, route53Client: route53Client, s3Client: s3Client, session: session}, nil + provider.regions = regions + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } + provider.services = services + + if services.Has("ec2") { + provider.ec2Client = ec2.New(session) + } + if services.Has("route53") { + provider.route53Client = route53.New(session) + } + if services.Has("s3") { + provider.s3Client = s3.New(session) + } + if services.Has("ecs") { + provider.ecsClient = ecs.New(session) + } + if services.Has("eks") { + provider.eksClient = eks.New(session) + } + if services.Has("lambda") { + provider.lambdaClient = lambda.New(session) + } + if services.Has("apigateway") { + provider.apiGateway = apigateway.New(session) + } + if services.Has("alb") { + provider.albClient = elbv2.New(session) + } + if services.Has("elb") { + provider.elbClient = elb.New(session) + } + if services.Has("lightsail") { + provider.lightsailClient = lightsail.New(session) + } + if services.Has("cloudfront") { + provider.cloudFrontClient = cloudfront.New(session) + } + return provider, nil } const apiAccessKey = "aws_access_key" @@ -71,26 +142,77 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // Resources returns the provider for an resource deployment source. func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { - ec2provider := &instanceProvider{ec2Client: p.ec2Client, id: p.id, session: p.session, regions: p.regions} - list, err := ec2provider.GetResource(ctx) - if err != nil { - return nil, err + finalList := schema.NewResources() + if p.ec2Client != nil { + ec2provider := &instanceProvider{ec2Client: p.ec2Client, id: p.id, session: p.session, regions: p.regions} + if list, err := ec2provider.GetResource(ctx); err == nil { + finalList.Merge(list) + } } - route53Provider := &route53Provider{route53: p.route53Client, id: p.id, session: p.session} - zones, err := route53Provider.GetResource(ctx) - if err != nil { - return nil, err + if p.route53Client != nil { + route53Provider := &route53Provider{route53: p.route53Client, id: p.id, session: p.session} + if zones, err := route53Provider.GetResource(ctx); err == nil { + finalList.Merge(zones) + } } - s3Provider := &s3Provider{s3: p.s3Client, id: p.id, session: p.session} - buckets, err := s3Provider.GetResource(ctx) - if err != nil { - return nil, err + if p.s3Client != nil { + s3Provider := &s3Provider{s3: p.s3Client, id: p.id, session: p.session} + if buckets, err := s3Provider.GetResource(ctx); err == nil { + finalList.Merge(buckets) + } + } + if p.ecsClient != nil { + ecsProvider := &ecsProvider{ecsClient: p.ecsClient, id: p.id, session: p.session, regions: p.regions} + if ecsResources, err := ecsProvider.GetResource(ctx); err == nil { + finalList.Merge(ecsResources) + } + } + if p.eksClient != nil { + eksProvider := &eksProvider{eksClient: p.eksClient, id: p.id, session: p.session, regions: p.regions} + if eksResources, err := eksProvider.GetResource(ctx); err == nil { + finalList.Merge(eksResources) + } + } + if p.apiGateway != nil && p.lambdaClient != nil { + lamdaAndApiGatewayProvider := &lambdaAndapiGatewayProvider{apiGateway: p.apiGateway, lambdaClient: p.lambdaClient, id: p.id, session: p.session, regions: p.regions} + if lambdaAndApiGateways, err := lamdaAndApiGatewayProvider.GetResource(ctx); err == nil { + finalList.Merge(lambdaAndApiGateways) + } + } + if p.albClient != nil { + albProvider := &elbV2Provider{albClient: p.albClient, id: p.id, session: p.session, regions: p.regions} + if albs, err := albProvider.GetResource(ctx); err == nil { + finalList.Merge(albs) + + } + } + if p.elbClient != nil { + elbProvider := &elbProvider{elbClient: p.elbClient, id: p.id, session: p.session, regions: p.regions} + if elbs, err := elbProvider.GetResource(ctx); err == nil { + finalList.Merge(elbs) + } + } + if p.lightsailClient != nil { + lsRegions, err := p.lightsailClient.GetRegions(&lightsail.GetRegionsInput{}) + if err == nil { + lightsailProvider := &lightsailProvider{lsClient: p.lightsailClient, id: p.id, session: p.session, regions: lsRegions.Regions} + if lsInstances, err := lightsailProvider.GetResource(ctx); err == nil { + finalList.Merge(lsInstances) + } + } + } + if p.cloudFrontClient != nil { + cloudfrontProvider := &cloudfrontProvider{cloudFrontClient: p.cloudFrontClient, id: p.id, session: p.session} + if cloudfrontResources, err := cloudfrontProvider.GetResource(ctx); err == nil { + finalList.Merge(cloudfrontResources) + } } - finalList := schema.NewResources() - finalList.Merge(list) - finalList.Merge(zones) - finalList.Merge(buckets) return finalList, nil } diff --git a/pkg/providers/aws/cloudfront.go b/pkg/providers/aws/cloudfront.go new file mode 100644 index 00000000..9195d33b --- /dev/null +++ b/pkg/providers/aws/cloudfront.go @@ -0,0 +1,58 @@ +package aws + +import ( + "context" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/cloudfront" + "github.com/pkg/errors" + "github.com/projectdiscovery/cloudlist/pkg/schema" +) + +// cloudfrontProvider is a provider for AWS CloudFront API +type cloudfrontProvider struct { + id string + cloudFrontClient *cloudfront.CloudFront + session *session.Session +} + +func (cp *cloudfrontProvider) name() string { + return "cloudfront" +} + +// GetResource returns all the resources in the store for a provider. +func (cp *cloudfrontProvider) GetResource(ctx context.Context) (*schema.Resources, error) { + resources, err := cp.listCloudFrontResources(cp.cloudFrontClient) + if err != nil { + return nil, errors.Wrap(err, "could not list CloudFront resources") + } + return resources, nil +} + +func (cp *cloudfrontProvider) listCloudFrontResources(cloudFrontClient *cloudfront.CloudFront) (*schema.Resources, error) { + list := schema.NewResources() + req := &cloudfront.ListDistributionsInput{MaxItems: aws.Int64(400)} + for { + distributions, err := cloudFrontClient.ListDistributions(req) + if err != nil { + return nil, errors.Wrap(err, "could not list distributions") + } + + for _, distribution := range distributions.DistributionList.Items { + resource := &schema.Resource{ + Provider: "aws", + ID: aws.StringValue(distribution.Id), + DNSName: aws.StringValue(distribution.DomainName), + Public: true, + Service: cp.name(), + } + list.Append(resource) + } + if aws.StringValue(distributions.DistributionList.NextMarker) == "" { + break + } + req.SetMarker(aws.StringValue(distributions.DistributionList.NextMarker)) + } + return list, nil +} diff --git a/pkg/providers/aws/ecs.go b/pkg/providers/aws/ecs.go new file mode 100644 index 00000000..6c0dd67b --- /dev/null +++ b/pkg/providers/aws/ecs.go @@ -0,0 +1,163 @@ +package aws + +import ( + "context" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/ec2" + "github.com/aws/aws-sdk-go/service/ecs" + "github.com/pkg/errors" + "github.com/projectdiscovery/cloudlist/pkg/schema" +) + +// ecsProvider is a provider for aws ecs API +type ecsProvider struct { + id string + ecsClient *ecs.ECS + session *session.Session + regions *ec2.DescribeRegionsOutput +} + +func (ep *ecsProvider) name() string { + return "ecs" +} + +// GetResource returns all the resources in the store for a provider. +func (ep *ecsProvider) GetResource(ctx context.Context) (*schema.Resources, error) { + list := schema.NewResources() + + for _, region := range ep.regions.Regions { + regionName := *region.RegionName + ecsClient := ecs.New(ep.session, aws.NewConfig().WithRegion(regionName)) + ec2Client := ec2.New(ep.session, aws.NewConfig().WithRegion(regionName)) + if resources, err := ep.listECSResources(ecsClient, ec2Client); err == nil { + list.Merge(resources) + } + } + return list, nil +} + +func (ep *ecsProvider) listECSResources(ecsClient *ecs.ECS, ec2Client *ec2.EC2) (*schema.Resources, error) { + list := schema.NewResources() + req := &ecs.ListClustersInput{ + MaxResults: aws.Int64(100), + } + for { + clustersOutput, err := ecsClient.ListClusters(req) + if err != nil { + return nil, errors.Wrap(err, "could not list ECS clusters") + } + + for _, clusterArn := range clustersOutput.ClusterArns { + listServicesInputReq := &ecs.ListServicesInput{ + Cluster: clusterArn, + MaxResults: aws.Int64(100), + } + for { + servicesOutput, err := ecsClient.ListServices(listServicesInputReq) + if err != nil { + return nil, errors.Wrap(err, "could not list ECS services") + } + + for _, serviceArn := range servicesOutput.ServiceArns { + listTasksInputReq := &ecs.ListTasksInput{ + Cluster: clusterArn, + ServiceName: serviceArn, + MaxResults: aws.Int64(100), + } + + for { + tasksOutput, err := ecsClient.ListTasks(listTasksInputReq) + if err != nil { + return nil, errors.Wrap(err, "could not list tasks") + } + if len(tasksOutput.TaskArns) == 0 { + break + } + describeTasksInput := &ecs.DescribeTasksInput{ + Cluster: clusterArn, + Tasks: tasksOutput.TaskArns, + } + + describeTasksOutput, err := ecsClient.DescribeTasks(describeTasksInput) + if err != nil { + return nil, errors.Wrap(err, "could not describe tasks") + } + + for _, task := range describeTasksOutput.Tasks { + if task.ContainerInstanceArn == nil { + continue + } + describeContainerInstancesInput := &ecs.DescribeContainerInstancesInput{ + Cluster: clusterArn, + ContainerInstances: []*string{task.ContainerInstanceArn}, + } + + describeContainerInstancesOutput, err := ecsClient.DescribeContainerInstances(describeContainerInstancesInput) + if err != nil { + return nil, errors.Wrap(err, "could not describe container instances") + } + + for _, containerInstance := range describeContainerInstancesOutput.ContainerInstances { + instanceID := containerInstance.Ec2InstanceId + describeInstancesInput := &ec2.DescribeInstancesInput{ + InstanceIds: []*string{instanceID}, + } + + describeInstancesOutput, err := ec2Client.DescribeInstances(describeInstancesInput) + if err != nil { + continue + } + + for _, reservation := range describeInstancesOutput.Reservations { + for _, instance := range reservation.Instances { + privateIP := aws.StringValue(instance.PrivateIpAddress) + publicIP := aws.StringValue(instance.PublicIpAddress) + + if privateIP != "" { + resource := &schema.Resource{ + ID: aws.StringValue(instance.InstanceId), + Provider: "aws", + PrivateIpv4: privateIP, + Public: false, + Service: ep.name(), + } + list.Append(resource) + } + + if publicIP != "" { + resource := &schema.Resource{ + ID: aws.StringValue(instance.InstanceId), + Provider: "aws", + PublicIPv4: publicIP, + Public: true, + Service: ep.name(), + } + list.Append(resource) + } + } + } + } + } + + if aws.StringValue(listTasksInputReq.NextToken) == "" { + break + } + listTasksInputReq.SetNextToken(*listTasksInputReq.NextToken) + } + } + + if aws.StringValue(servicesOutput.NextToken) == "" { + break + } + listServicesInputReq.SetNextToken(*servicesOutput.NextToken) + } + } + if aws.StringValue(clustersOutput.NextToken) == "" { + break + } + req.SetNextToken(*clustersOutput.NextToken) + } + return list, nil +} diff --git a/pkg/providers/aws/eks.go b/pkg/providers/aws/eks.go new file mode 100644 index 00000000..433f7f93 --- /dev/null +++ b/pkg/providers/aws/eks.go @@ -0,0 +1,146 @@ +package aws + +import ( + "context" + "encoding/base64" + "fmt" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/ec2" + "github.com/aws/aws-sdk-go/service/eks" + "github.com/pkg/errors" + "github.com/projectdiscovery/cloudlist/pkg/schema" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" + "sigs.k8s.io/aws-iam-authenticator/pkg/token" +) + +// eksProvider is a provider for AWS EKS API. +type eksProvider struct { + id string + eksClient *eks.EKS + session *session.Session + regions *ec2.DescribeRegionsOutput +} + +func (ep *eksProvider) name() string { + return "eks" +} + +// GetResource returns all the resources in the store for a provider. +func (ep *eksProvider) GetResource(ctx context.Context) (*schema.Resources, error) { + list := schema.NewResources() + for _, region := range ep.regions.Regions { + regionName := *region.RegionName + ep.eksClient = eks.New(ep.session, aws.NewConfig().WithRegion(regionName)) + if resources, err := ep.listEKSResources(ep.eksClient); err == nil { + list.Merge(resources) + } + } + return list, nil +} + +func (ep *eksProvider) listEKSResources(eksClient *eks.EKS) (*schema.Resources, error) { + list := schema.NewResources() + req := &eks.ListClustersInput{ + MaxResults: aws.Int64(100), + } + for { + clustersOutput, err := eksClient.ListClusters(req) + if err != nil { + return nil, errors.Wrap(err, "could not list EKS clusters") + } + // Iterate over each cluster + for _, clusterName := range clustersOutput.Clusters { + // describe cluster + clusterOutput, err := eksClient.DescribeCluster(&eks.DescribeClusterInput{ + Name: clusterName, + }) + if err != nil { + return nil, errors.Wrapf(err, "could not describe EKS cluster: %s", *clusterName) + } + clientset, err := newClientset(clusterOutput.Cluster) + if err != nil { + return nil, errors.Wrapf(err, "could not create clientset for EKS cluster: %s", *clusterName) + } + nodes, err := clientset.CoreV1().Nodes().List(context.Background(), metav1.ListOptions{}) + if err != nil { + return nil, errors.Wrapf(err, "could not list nodes for EKS cluster: %s", *clusterName) + } + // Iterate over each node + for _, node := range nodes.Items { + var podIPs []string + // List IP addresses of pods running on the node + pods, err := clientset.CoreV1().Pods("").List(context.Background(), metav1.ListOptions{ + FieldSelector: fmt.Sprintf("spec.nodeName=%s", node.GetName()), + }) + if err != nil { + continue + } + // Collect pod IP addresses + for _, pod := range pods.Items { + for _, podIP := range pod.Status.PodIPs { + podIPs = append(podIPs, podIP.IP) + } + } + // Node IP + nodeIP := node.Status.Addresses[0].Address + list.Append(&schema.Resource{ + Provider: providerName, + ID: node.GetName(), + PublicIPv4: nodeIP, + Public: true, + Service: ep.name(), + }) + // Pod IPs + for _, podIP := range podIPs { + list.Append(&schema.Resource{ + Provider: providerName, + ID: node.GetName(), + PrivateIpv4: podIP, + Public: false, + Service: ep.name(), + }) + } + } + } + if aws.StringValue(clustersOutput.NextToken) == "" { + break + } + req.SetNextToken(*clustersOutput.NextToken) + } + return list, nil +} + +func newClientset(cluster *eks.Cluster) (*kubernetes.Clientset, error) { + gen, err := token.NewGenerator(true, false) + if err != nil { + return nil, err + } + opts := &token.GetTokenOptions{ + ClusterID: aws.StringValue(cluster.Name), + } + tok, err := gen.GetWithOptions(opts) + if err != nil { + return nil, err + } + ca, err := base64.StdEncoding.DecodeString(aws.StringValue(cluster.CertificateAuthority.Data)) + if err != nil { + return nil, err + } + clientset, err := kubernetes.NewForConfig( + &rest.Config{ + Host: aws.StringValue(cluster.Endpoint), + BearerToken: tok.Token, + TLSClientConfig: rest.TLSClientConfig{ + CAData: ca, + }, + }, + ) + if err != nil { + return nil, err + } + return clientset, nil +} diff --git a/pkg/providers/aws/elb.go b/pkg/providers/aws/elb.go new file mode 100644 index 00000000..70bfead6 --- /dev/null +++ b/pkg/providers/aws/elb.go @@ -0,0 +1,104 @@ +package aws + +import ( + "context" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/ec2" + "github.com/aws/aws-sdk-go/service/elb" + "github.com/pkg/errors" + "github.com/projectdiscovery/cloudlist/pkg/schema" +) + +// elbProvider is a provider for AWS Elastic Load Balancing (ELB) resources +type elbProvider struct { + id string + elbClient *elb.ELB + session *session.Session + regions *ec2.DescribeRegionsOutput +} + +func (ep *elbProvider) name() string { + return "elb" +} + +// GetResource returns all the resources in the store for a provider. +func (ep *elbProvider) GetResource(ctx context.Context) (*schema.Resources, error) { + list := schema.NewResources() + + for _, region := range ep.regions.Regions { + regionName := *region.RegionName + elbClient := elb.New(ep.session, aws.NewConfig().WithRegion(regionName)) + ec2Client := ec2.New(ep.session, aws.NewConfig().WithRegion(regionName)) + if resources, err := ep.listELBResources(elbClient, ec2Client); err == nil { + list.Merge(resources) + } + } + return list, nil +} + +func (ep *elbProvider) listELBResources(elbClient *elb.ELB, ec2Client *ec2.EC2) (*schema.Resources, error) { + list := schema.NewResources() + + loadBalancerDescriptions, err := ep.getLoadBalancers(elbClient) + if err != nil { + return nil, errors.Wrap(err, "could not list load balancers") + } + + for _, lb := range loadBalancerDescriptions { + elbDNS := *lb.DNSName + resource := &schema.Resource{ + Provider: "aws", + ID: *lb.LoadBalancerName, + DNSName: elbDNS, + Public: true, + Service: ep.name(), + } + list.Append(resource) + // Describe Instances for the Load Balancer + for _, instance := range lb.Instances { + instanceID := *instance.InstanceId + instanceOutput, err := ec2Client.DescribeInstances(&ec2.DescribeInstancesInput{ + InstanceIds: []*string{&instanceID}, + }) + if err != nil { + return nil, errors.Wrapf(err, "could not describe instance %s", instanceID) + } + // Extract private IP address + for _, reservation := range instanceOutput.Reservations { + for _, instance := range reservation.Instances { + if instance.PrivateIpAddress != nil { + resource := &schema.Resource{ + Provider: "aws", + ID: instanceID, + PrivateIpv4: *instance.PrivateIpAddress, + Public: false, + Service: ep.name(), + } + list.Append(resource) + } + } + } + } + } + + return list, nil +} + +func (ep *elbProvider) getLoadBalancers(elbClient *elb.ELB) ([]*elb.LoadBalancerDescription, error) { + var loadBalancers []*elb.LoadBalancerDescription + req := &elb.DescribeLoadBalancersInput{} + for { + lbOutput, err := elbClient.DescribeLoadBalancers(req) + if err != nil { + return nil, errors.Wrap(err, "could not describe load balancers") + } + loadBalancers = append(loadBalancers, lbOutput.LoadBalancerDescriptions...) + if aws.StringValue(lbOutput.NextMarker) == "" { + break + } + req.SetMarker(aws.StringValue(lbOutput.NextMarker)) + } + return loadBalancers, nil +} diff --git a/pkg/providers/aws/lambda-api-gateway.go b/pkg/providers/aws/lambda-api-gateway.go new file mode 100644 index 00000000..69aeafa7 --- /dev/null +++ b/pkg/providers/aws/lambda-api-gateway.go @@ -0,0 +1,142 @@ +package aws + +import ( + "context" + "fmt" + "strings" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/apigateway" + "github.com/aws/aws-sdk-go/service/ec2" + "github.com/aws/aws-sdk-go/service/lambda" + "github.com/pkg/errors" + "github.com/projectdiscovery/cloudlist/pkg/schema" +) + +// apiGatewayProvider is a provider for AWS API Gateway resources +type lambdaAndapiGatewayProvider struct { + id string + lambdaClient *lambda.Lambda + apiGateway *apigateway.APIGateway + session *session.Session + regions *ec2.DescribeRegionsOutput +} + +// GetResource returns all the resources in the store for a provider. +func (ap *lambdaAndapiGatewayProvider) GetResource(ctx context.Context) (*schema.Resources, error) { + list := schema.NewResources() + + for _, region := range ap.regions.Regions { + regionName := *region.RegionName + ap.apiGateway = apigateway.New(ap.session, aws.NewConfig().WithRegion(regionName)) + ap.lambdaClient = lambda.New(ap.session, aws.NewConfig().WithRegion(regionName)) + if resources, err := ap.listAPIGatewayResources(ap.apiGateway, regionName, ap.lambdaClient); err == nil { + list.Merge(resources) + } + } + return list, nil +} + +func (ap *lambdaAndapiGatewayProvider) listAPIGatewayResources(apiGateway *apigateway.APIGateway, regionName string, lambdaClient *lambda.Lambda) (*schema.Resources, error) { + list := schema.NewResources() + apis, err := apiGateway.GetRestApis(&apigateway.GetRestApisInput{Limit: aws.Int64(500)}) + if err != nil { + return nil, errors.Wrap(err, "could not list APIs") + } + // List Lambda functions and create a mapping of function ARN to function name + lambdaFunctions, err := ap.getLambdaFunctions(lambdaClient) + if err != nil { + return nil, errors.Wrap(err, "could not list Lambda functions") + } + lambdaFunctionMapping := make(map[string]string) + for _, lambdaFunction := range lambdaFunctions { + lambdaFunctionMapping[*lambdaFunction.FunctionArn] = *lambdaFunction.FunctionName + } + // Iterate over each API Gateway resource + for _, api := range apis.Items { + apiBaseURL := fmt.Sprintf("https://%s.execute-api.%s.amazonaws.com", *api.Id, regionName) + list.Append(&schema.Resource{ + Provider: "aws", + ID: *api.Id, + DNSName: apiBaseURL, + Public: true, + Service: "apigateway", + }) + // Get resources for the API + resourceReq := &apigateway.GetResourcesInput{ + RestApiId: api.Id, + Limit: aws.Int64(100), + } + for { + resources, err := apiGateway.GetResources(resourceReq) + if err != nil { + return nil, errors.Wrapf(err, "could not get resources for API %s", *api.Id) + } + + for _, resource := range resources.Items { + // List methods for the resource + for _, method := range resource.ResourceMethods { + if method == nil || method.HttpMethod == nil { + continue + } + integration, err := apiGateway.GetIntegration(&apigateway.GetIntegrationInput{ + RestApiId: api.Id, + ResourceId: resource.Id, + HttpMethod: aws.String(*method.HttpMethod), + }) + if err != nil { + continue + } + // Check if the integration type is AWS_PROXY (indicating Lambda integration) + if integration.Type != nil && *integration.Type == "AWS_PROXY" { + functionARN := extractLambdaARN(*integration.Uri) + if functionName, ok := lambdaFunctionMapping[functionARN]; ok { + apiURLWithLambda := fmt.Sprintf("%s/lambda/%s", apiBaseURL, functionName) + list.Append(&schema.Resource{ + Provider: "aws", + ID: *api.Id, + DNSName: apiURLWithLambda, + Public: true, + Service: "lambda", + }) + } + } + } + } + + if aws.StringValue(resources.Position) == "" { + break + } + resourceReq.SetPosition(*resources.Position) + } + } + return list, nil +} + +func (ap *lambdaAndapiGatewayProvider) getLambdaFunctions(lambdaClient *lambda.Lambda) ([]*lambda.FunctionConfiguration, error) { + var lambdaFunctions []*lambda.FunctionConfiguration + lambdaReq := &lambda.ListFunctionsInput{MaxItems: aws.Int64(20)} + for { + lambdaFuncs, err := lambdaClient.ListFunctions(lambdaReq) + if err != nil { + return nil, errors.Wrap(err, "could not list Lambda functions") + } + lambdaFunctions = append(lambdaFunctions, lambdaFuncs.Functions...) + if aws.StringValue(lambdaFuncs.NextMarker) == "" { + break + } + lambdaReq.SetMarker(*lambdaFuncs.NextMarker) + } + return lambdaFunctions, nil +} + +// extract Lambda function ARN from integration URI +// Example URI: "arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:my-function/invocations" +func extractLambdaARN(uri string) string { + parts := strings.Split(uri, "/") + if len(parts) >= 5 { + return parts[3] + } + return "" +} diff --git a/pkg/providers/aws/lightsail.go b/pkg/providers/aws/lightsail.go new file mode 100644 index 00000000..c7e0d91a --- /dev/null +++ b/pkg/providers/aws/lightsail.go @@ -0,0 +1,65 @@ +package aws + +import ( + "context" + "fmt" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/lightsail" + "github.com/pkg/errors" + "github.com/projectdiscovery/cloudlist/pkg/schema" +) + +// lightsailProvider is an instance provider for AWS Lightsail API +type lightsailProvider struct { + id string + lsClient *lightsail.Lightsail + session *session.Session + regions []*lightsail.Region +} + +func (d *lightsailProvider) name() string { + return "lightsail" +} + +// GetResource returns all the resources in the store for a provider. +func (d *lightsailProvider) GetResource(ctx context.Context) (*schema.Resources, error) { + list := schema.NewResources() + + for _, region := range d.regions { + endpoint := fmt.Sprintf("https://lightsail.%s.amazonaws.com", aws.StringValue(region.Name)) + + lsClient := lightsail.New( + d.session, + aws.NewConfig().WithEndpoint(endpoint), + aws.NewConfig().WithRegion(aws.StringValue(region.Name)), + ) + req := &lightsail.GetInstancesInput{} + for { + resp, err := lsClient.GetInstances(req) + if err != nil { + return nil, errors.Wrap(err, "could not describe instances") + } + + for _, instance := range resp.Instances { + privateIPv4 := aws.StringValue(instance.PrivateIpAddress) + publicIPv4 := aws.StringValue(instance.PublicIpAddress) + resource := &schema.Resource{ + ID: d.id, + Provider: providerName, + PrivateIpv4: privateIPv4, + PublicIPv4: publicIPv4, + Public: publicIPv4 != "", + Service: d.name(), + } + list.Append(resource) + } + if aws.StringValue(resp.NextPageToken) == "" { + break + } + req.PageToken = resp.NextPageToken + } + } + return list, nil +} diff --git a/pkg/providers/azure/azure.go b/pkg/providers/azure/azure.go index 121ac722..03d6e87f 100644 --- a/pkg/providers/azure/azure.go +++ b/pkg/providers/azure/azure.go @@ -3,6 +3,7 @@ package azure import ( "context" "fmt" + "strings" "github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest/azure/auth" @@ -21,11 +22,14 @@ const ( providerName = "azure" ) +var Services = []string{"vm", "publicip"} + // Provider is a data provider for Azure API type Provider struct { id string SubscriptionID string Authorizer autorest.Authorizer + services schema.ServiceMap } // New creates a new provider client for Azure API @@ -69,7 +73,24 @@ func New(options schema.OptionBlock) (*Provider, error) { } } - return &Provider{Authorizer: authorizer, SubscriptionID: SubscriptionID, id: ID}, nil + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } + return &Provider{Authorizer: authorizer, SubscriptionID: SubscriptionID, id: ID, services: services}, nil } @@ -83,24 +104,32 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // Resources returns the provider for an resource deployment source. func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { - vmp := &vmProvider{Authorizer: p.Authorizer, SubscriptionID: p.SubscriptionID, id: p.id} - - vmIPs, err := vmp.GetResource(ctx) - if err != nil { - return nil, fmt.Errorf("error listing VM public ips: %s", err) - } + resources := &schema.Resources{} - publicIPp := &publicIPProvider{Authorizer: p.Authorizer, SubscriptionID: p.SubscriptionID, id: p.id} - publicIPs, err := publicIPp.GetResource(ctx) - if err != nil { - return nil, fmt.Errorf("error listing public ips: %s", err) + if p.services.Has("vm") { + vmp := &vmProvider{Authorizer: p.Authorizer, SubscriptionID: p.SubscriptionID, id: p.id} + vmIPs, err := vmp.GetResource(ctx) + if err != nil { + return nil, fmt.Errorf("error listing VM public ips: %s", err) + } + resources.Merge(vmIPs) } - resources := &schema.Resources{} - resources.Merge(vmIPs) - resources.Merge(publicIPs) + if p.services.Has("publicip") { - return resources, err + publicIPp := &publicIPProvider{Authorizer: p.Authorizer, SubscriptionID: p.SubscriptionID, id: p.id} + publicIPs, err := publicIPp.GetResource(ctx) + if err != nil { + return nil, fmt.Errorf("error listing public ips: %s", err) + } + resources.Merge(publicIPs) + } + return resources, nil } diff --git a/pkg/providers/cloudflare/cloudflare.go b/pkg/providers/cloudflare/cloudflare.go index bd40106e..3bdf0cbb 100644 --- a/pkg/providers/cloudflare/cloudflare.go +++ b/pkg/providers/cloudflare/cloudflare.go @@ -2,15 +2,19 @@ package cloudflare import ( "context" + "strings" "github.com/cloudflare/cloudflare-go" "github.com/projectdiscovery/cloudlist/pkg/schema" ) +var Services = []string{"dns"} + // Provider is a data provider for cloudflare API type Provider struct { - id string - client *cloudflare.API + id string + client *cloudflare.API + services schema.ServiceMap } // New creates a new provider client for cloudflare API @@ -41,7 +45,27 @@ func New(options schema.OptionBlock) (*Provider, error) { if err != nil { return nil, err } - return &Provider{id: id, client: api}, nil + + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } + + return &Provider{id: id, client: api, services: services}, nil } // apiToken is a cloudflare scoped API token @@ -60,12 +84,16 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // Resources returns the provider for an resource deployment source. func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { - dnsProvider := &dnsProvider{id: p.id, client: p.client} - list, err := dnsProvider.GetResource(ctx) - if err != nil { - return nil, err + if p.services.Has("dns") { + dnsProvider := &dnsProvider{id: p.id, client: p.client} + return dnsProvider.GetResource(ctx) } - return list, nil + return nil, nil } diff --git a/pkg/providers/consul/consul.go b/pkg/providers/consul/consul.go index 0a643ba7..dbc33c4e 100644 --- a/pkg/providers/consul/consul.go +++ b/pkg/providers/consul/consul.go @@ -11,10 +11,13 @@ import ( "github.com/projectdiscovery/cloudlist/pkg/schema" ) +var Services = []string{"consul"} + // Provider is a data provider for consul resources type Provider struct { - id string - client *api.Client + id string + client *api.Client + services schema.ServiceMap } // New creates a new provider client for consul resources API @@ -82,7 +85,12 @@ func New(options schema.OptionBlock) (*Provider, error) { return nil, errors.Wrap(err, "could not create consul api client") } id, _ := options.GetMetadata("id") - return &Provider{id: id, client: conn}, nil + + services := make(schema.ServiceMap) + for _, s := range Services { + services[s] = struct{}{} + } + return &Provider{id: id, client: conn, services: services}, nil } const providerName = "consul" @@ -97,6 +105,11 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + const ( consulURL = "consul_url" consulHTTPToken = "consul_http_token" diff --git a/pkg/providers/digitalocean/digitalocean.go b/pkg/providers/digitalocean/digitalocean.go index de0a541c..dedf3978 100644 --- a/pkg/providers/digitalocean/digitalocean.go +++ b/pkg/providers/digitalocean/digitalocean.go @@ -2,15 +2,19 @@ package digitalocean import ( "context" + "strings" "github.com/digitalocean/godo" "github.com/projectdiscovery/cloudlist/pkg/schema" ) +var Services = []string{"droplet", "app", "instance"} + // Provider is a data provider for digitalocean API type Provider struct { - id string - client *godo.Client + id string + client *godo.Client + services schema.ServiceMap } // New creates a new provider client for digitalocean API @@ -20,7 +24,25 @@ func New(options schema.OptionBlock) (*Provider, error) { return nil, &schema.ErrNoSuchKey{Name: apiKey} } id, _ := options.GetMetadata("id") - return &Provider{id: id, client: godo.NewFromToken(token)}, nil + + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } + return &Provider{id: id, client: godo.NewFromToken(token), services: services}, nil } const providerName = "digitalocean" @@ -35,24 +57,34 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + const apiKey = "digitalocean_token" // Resources returns the provider for an resource deployment source. func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { - instanceprovider := &instanceProvider{client: p.client, id: p.id} - instances, err := instanceprovider.GetResource(ctx) - if err != nil { - return nil, err + finalList := schema.NewResources() + + if p.services.Has("droplet") || p.services.Has("instance") { + instanceprovider := &instanceProvider{client: p.client, id: p.id} + instances, err := instanceprovider.GetResource(ctx) + if err != nil { + return nil, err + } + finalList.Merge(instances) } - appprovider := &appsProvider{client: p.client, id: p.id} - apps, err := appprovider.GetResource(ctx) - if err != nil { - return nil, err + if p.services.Has("app") { + appprovider := &appsProvider{client: p.client, id: p.id} + apps, err := appprovider.GetResource(ctx) + if err != nil { + return nil, err + } + finalList.Merge(apps) } - finalList := schema.NewResources() - finalList.Merge(instances) - finalList.Merge(apps) return finalList, nil } diff --git a/pkg/providers/fastly/fastly.go b/pkg/providers/fastly/fastly.go index 6dbdfdc4..df95cb4d 100644 --- a/pkg/providers/fastly/fastly.go +++ b/pkg/providers/fastly/fastly.go @@ -8,6 +8,8 @@ import ( "github.com/projectdiscovery/cloudlist/pkg/schema" ) +var Services = []string{"fastly"} + const ( apiKey = "fastly_api_key" providerName = "fastly" @@ -15,8 +17,9 @@ const ( // Provider is a data provider for fastly API type Provider struct { - client *fastly.Client - id string + client *fastly.Client + id string + services schema.ServiceMap } // New creates a new provider client for fastly API @@ -31,7 +34,17 @@ func New(options schema.OptionBlock) (*Provider, error) { if err != nil { return nil, err } - return &Provider{client: client, id: id}, err + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + + services := make(schema.ServiceMap) + for _, s := range Services { + services[s] = struct{}{} + } + + return &Provider{client: client, id: id, services: services}, err } // Name returns the name of the provider @@ -44,6 +57,11 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // Resources returns the provider for an resource deployment source. func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { serviceProvider := &serviceProvider{client: p.client, id: p.id} diff --git a/pkg/providers/gcp/function.go b/pkg/providers/gcp/function.go index f80ae6f0..fc87dc84 100644 --- a/pkg/providers/gcp/function.go +++ b/pkg/providers/gcp/function.go @@ -16,7 +16,7 @@ type cloudFunctionsProvider struct { } func (d *cloudFunctionsProvider) name() string { - return "cloud-functions" + return "cloud-function" } // GetResource returns all the Cloud Function resources in the store for a provider. diff --git a/pkg/providers/gcp/gcp.go b/pkg/providers/gcp/gcp.go index d47d18c3..4325dd4f 100644 --- a/pkg/providers/gcp/gcp.go +++ b/pkg/providers/gcp/gcp.go @@ -2,6 +2,7 @@ package gcp import ( "context" + "strings" "github.com/projectdiscovery/cloudlist/pkg/schema" "github.com/projectdiscovery/gologger" @@ -23,10 +24,13 @@ type Provider struct { storage *storage.Service functions *cloudfunctions.Service run *run.APIService + services schema.ServiceMap id string projects []string } +var Services = []string{"dns", "gke", "compute", "s3", "cloud-function", "cloud-run"} + const serviceAccountJSON = "gcp_service_account_key" const providerName = "gcp" @@ -40,44 +44,87 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // New creates a new provider client for gcp API func New(options schema.OptionBlock) (*Provider, error) { - var saKeyBytes []byte - saKeyString, ok := options.GetMetadata(serviceAccountJSON) - if ok { - saKeyBytes = []byte(saKeyString) + JSONData, ok := options.GetMetadata(serviceAccountJSON) + if !ok { + return nil, errorutil.New("could not get API Key") } - id, _ := options.GetMetadata("id") - creds, err := register(context.Background(), []byte(saKeyBytes)) - if err != nil { - return nil, errorutil.NewWithErr(err).Msgf("could not register gcp service account") + provider := &Provider{id: id} + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } } + provider.services = services - dnsService, err := dns.NewService(context.Background(), creds) + creds, err := register(context.Background(), []byte(JSONData)) if err != nil { - return nil, errorutil.NewWithErr(err).Msgf("could not create dns service with api key") + return nil, errorutil.NewWithErr(err).Msgf("could not register gcp service account") } - computeService, err := compute.NewService(context.Background(), creds) - if err != nil { - return nil, errorutil.NewWithErr(err).Msgf("could not create compute service with api key") + if services.Has("dns") { + dnsService, err := dns.NewService(context.Background(), creds) + if err != nil { + return nil, errorutil.NewWithErr(err).Msgf("could not create dns service with api key") + } + provider.dns = dnsService } - containerService, err := container.NewService(context.Background(), creds) - if err != nil { - return nil, errorutil.NewWithErr(err).Msgf("could not create container service with api key") + if services.Has("compute") { + computeService, err := compute.NewService(context.Background(), creds) + if err != nil { + return nil, errorutil.NewWithErr(err).Msgf("could not create compute service with api key") + } + provider.compute = computeService } - storageService, err := storage.NewService(context.Background(), creds) - if err != nil { - return nil, errorutil.NewWithErr(err).Msgf("could not create storage service with api key") + + if services.Has("gke") { + containerService, err := container.NewService(context.Background(), creds) + if err != nil { + return nil, errorutil.NewWithErr(err).Msgf("could not create container service with api key") + } + provider.gke = containerService } - functionsService, err := cloudfunctions.NewService(context.Background(), creds) - if err != nil { - return nil, errorutil.NewWithErr(err).Msgf("could not create functions service with api key") + + if services.Has("s3") { + storageService, err := storage.NewService(context.Background(), creds) + if err != nil { + return nil, errorutil.NewWithErr(err).Msgf("could not create storage service with api key") + } + provider.storage = storageService } - cloudRunService, err := run.NewService(context.Background(), creds) - if err != nil { - return nil, errorutil.NewWithErr(err).Msgf("could not create cloud run service with api key") + if services.Has("cloud-function") { + functionsService, err := cloudfunctions.NewService(context.Background(), creds) + if err != nil { + return nil, errorutil.NewWithErr(err).Msgf("could not create functions service with api key") + } + provider.functions = functionsService + } + + if services.Has("cloud-run") { + cloudRunService, err := run.NewService(context.Background(), creds) + if err != nil { + return nil, errorutil.NewWithErr(err).Msgf("could not create cloud run service with api key") + } + provider.run = cloudRunService } projects := []string{} @@ -92,54 +139,67 @@ func New(options schema.OptionBlock) (*Provider, error) { } return nil }) - return &Provider{dns: dnsService, gke: containerService, projects: projects, id: id, compute: computeService, storage: storageService, functions: functionsService, run: cloudRunService}, err + provider.projects = projects + return provider, err } // Resources returns the provider for an resource deployment source. func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { finalList := schema.NewResources() - cloudDNSProvider := &cloudDNSProvider{dns: p.dns, id: p.id, projects: p.projects} - zones, err := cloudDNSProvider.GetResource(ctx) - if err != nil { - return nil, err + if p.dns != nil { + cloudDNSProvider := &cloudDNSProvider{dns: p.dns, id: p.id, projects: p.projects} + zones, err := cloudDNSProvider.GetResource(ctx) + if err != nil { + return nil, err + } + finalList.Merge(zones) } - finalList.Merge(zones) - GKEProvider := &gkeProvider{svc: p.gke, id: p.id, projects: p.projects} - gkeData, err := GKEProvider.GetResource(ctx) - if err != nil { - gologger.Warning().Msgf("Could not get GKE resources: %s\n", err) + if p.gke != nil { + GKEProvider := &gkeProvider{svc: p.gke, id: p.id, projects: p.projects} + gkeData, err := GKEProvider.GetResource(ctx) + if err != nil { + gologger.Warning().Msgf("Could not get GKE resources: %s\n", err) + } + finalList.Merge(gkeData) } - finalList.Merge(gkeData) - VMProvider := &cloudVMProvider{compute: p.compute, id: p.id, projects: p.projects} - vmData, err := VMProvider.GetResource(ctx) - if err != nil { - return nil, err + if p.compute != nil { + VMProvider := &cloudVMProvider{compute: p.compute, id: p.id, projects: p.projects} + vmData, err := VMProvider.GetResource(ctx) + if err != nil { + return nil, err + } + finalList.Merge(vmData) } - finalList.Merge(vmData) - cloudStorageProvider := &cloudStorageProvider{id: p.id, storage: p.storage, projects: p.projects} - storageData, err := cloudStorageProvider.GetResource(ctx) - if err != nil { - return nil, err + if p.storage != nil { + cloudStorageProvider := &cloudStorageProvider{id: p.id, storage: p.storage, projects: p.projects} + storageData, err := cloudStorageProvider.GetResource(ctx) + if err != nil { + return nil, err + } + finalList.Merge(storageData) } - finalList.Merge(storageData) - cloudFunctionsProvider := &cloudFunctionsProvider{id: p.id, functions: p.functions, projects: p.projects} - functionsData, err := cloudFunctionsProvider.GetResource(ctx) - if err != nil { - return nil, err + if p.functions != nil { + cloudFunctionsProvider := &cloudFunctionsProvider{id: p.id, functions: p.functions, projects: p.projects} + functionsData, err := cloudFunctionsProvider.GetResource(ctx) + if err != nil { + return nil, err + } + finalList.Merge(functionsData) } - finalList.Merge(functionsData) - cloudRunProvider := &cloudRunProvider{id: p.id, run: p.run, projects: p.projects} - cloudRunData, err := cloudRunProvider.GetResource(ctx) - if err != nil { - return nil, err + if p.run != nil { + cloudRunProvider := &cloudRunProvider{id: p.id, run: p.run, projects: p.projects} + cloudRunData, err := cloudRunProvider.GetResource(ctx) + if err != nil { + return nil, err + } + finalList.Merge(cloudRunData) } - finalList.Merge(cloudRunData) return finalList, nil } diff --git a/pkg/providers/heroku/heroku.go b/pkg/providers/heroku/heroku.go index 8dfd393f..7b541fe1 100644 --- a/pkg/providers/heroku/heroku.go +++ b/pkg/providers/heroku/heroku.go @@ -2,12 +2,15 @@ package heroku import ( "context" + "strings" heroku "github.com/heroku/heroku-go/v5" "github.com/projectdiscovery/cloudlist/pkg/schema" ) +var Services = []string{"app"} + const ( apiKey = "heroku_api_token" providerName = "heroku" @@ -15,8 +18,9 @@ const ( // Provider is a data provider for Heroku API type Provider struct { - id string - client *heroku.Service + id string + client *heroku.Service + services schema.ServiceMap } // New creates a new provider client for Heroku API @@ -29,7 +33,25 @@ func New(options schema.OptionBlock) (*Provider, error) { heroku.DefaultTransport.BearerToken = token - return &Provider{id: id, client: heroku.NewService(heroku.DefaultClient)}, nil + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } + + return &Provider{id: id, client: heroku.NewService(heroku.DefaultClient), services: services}, nil } // Name returns the name of the provider @@ -42,8 +64,16 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // Resources returns the provider for an resource deployment source. func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { - provider := &instanceProvider{client: p.client, id: p.id} - return provider.GetResource(ctx) + if p.services.Has("app") { + provider := &instanceProvider{client: p.client, id: p.id} + return provider.GetResource(ctx) + } + return nil, nil } diff --git a/pkg/providers/hetzner/hetzner.go b/pkg/providers/hetzner/hetzner.go index 4b3e6b0d..038a7d6d 100644 --- a/pkg/providers/hetzner/hetzner.go +++ b/pkg/providers/hetzner/hetzner.go @@ -2,10 +2,14 @@ package hetzner import ( "context" + "strings" + hetzner "github.com/hetznercloud/hcloud-go/hcloud" "github.com/projectdiscovery/cloudlist/pkg/schema" ) +var Services = []string{"instance"} + const ( authToken = "auth_token" providerName = "hetzner" @@ -13,8 +17,9 @@ const ( // Provider is a data provider for Hetzner Cloud API type Provider struct { - id string - client *hetzner.Client + id string + client *hetzner.Client + services schema.ServiceMap } // New creates a new provider client for Hetzner Cloud API @@ -26,7 +31,25 @@ func New(options schema.OptionBlock) (*Provider, error) { id, _ := options.GetMetadata("id") opts := hetzner.WithToken(token) - return &Provider{id: id, client: hetzner.NewClient(opts)}, nil + + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } + return &Provider{id: id, client: hetzner.NewClient(opts), services: services}, nil } // Name returns the name of the provider @@ -39,8 +62,16 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // Resources returns the provider for an resource func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { - provider := &instanceProvider{client: p.client, id: p.id} - return provider.GetResource(ctx) + if p.services.Has("instance") { + provider := &instanceProvider{client: p.client, id: p.id} + return provider.GetResource(ctx) + } + return nil, nil } diff --git a/pkg/providers/k8s/kubernetes.go b/pkg/providers/k8s/kubernetes.go index b52029d4..ddd11518 100644 --- a/pkg/providers/k8s/kubernetes.go +++ b/pkg/providers/k8s/kubernetes.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "fmt" + "strings" "github.com/projectdiscovery/cloudlist/pkg/schema" errorutil "github.com/projectdiscovery/utils/errors" @@ -13,10 +14,13 @@ import ( "k8s.io/client-go/tools/clientcmd" ) +var Services = []string{"service", "ingress"} + // Provider is a data provider for gcp API type Provider struct { id string clientSet *kubernetes.Clientset + services schema.ServiceMap } const ( @@ -58,7 +62,25 @@ func New(options schema.OptionBlock) (*Provider, error) { if err != nil { return nil, errorutil.NewWithErr(err).Msgf("could not create kubernetes clientset") } - return &Provider{id: id, clientSet: clientset}, nil + + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } + return &Provider{id: id, clientSet: clientset, services: services}, nil } // Name returns the name of the provider @@ -71,6 +93,11 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // Resources returns the provider for an resource deployment source. func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { finalList := schema.NewResources() @@ -78,17 +105,21 @@ func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { if err != nil { return nil, errorutil.NewWithErr(err).Msgf("could not list kubernetes services") } - k8sServiceProvider := K8sServiceProvider{serviceClient: services, id: p.id} - serviceIPs, _ := k8sServiceProvider.GetResource(ctx) - finalList.Merge(serviceIPs) + if p.services.Has("service") { + k8sServiceProvider := K8sServiceProvider{serviceClient: services, id: p.id} + serviceIPs, _ := k8sServiceProvider.GetResource(ctx) + finalList.Merge(serviceIPs) + } - ingress, err := p.clientSet.NetworkingV1().Ingresses("").List(ctx, metav1.ListOptions{}) - if err != nil { - return nil, errorutil.NewWithErr(err).Msgf("could not list kubernetes ingress") + if p.services.Has("ingress") { + ingress, err := p.clientSet.NetworkingV1().Ingresses("").List(ctx, metav1.ListOptions{}) + if err != nil { + return nil, errorutil.NewWithErr(err).Msgf("could not list kubernetes ingress") + } + k8sIngressProvider := K8sIngressProvider{ingress: ingress, id: p.id} + ingressHosts, _ := k8sIngressProvider.GetResource(ctx) + finalList.Merge(ingressHosts) } - k8sIngressProvider := K8sIngressProvider{ingress: ingress, id: p.id} - ingressHosts, _ := k8sIngressProvider.GetResource(ctx) - finalList.Merge(ingressHosts) return finalList, nil } diff --git a/pkg/providers/linode/linode.go b/pkg/providers/linode/linode.go index b468e0b9..730a52cd 100644 --- a/pkg/providers/linode/linode.go +++ b/pkg/providers/linode/linode.go @@ -3,12 +3,15 @@ package linode import ( "context" "net/http" + "strings" "github.com/linode/linodego" "github.com/projectdiscovery/cloudlist/pkg/schema" "golang.org/x/oauth2" ) +var Services = []string{"instance"} + const ( apiKey = "linode_personal_access_token" providerName = "linode" @@ -16,8 +19,9 @@ const ( // Provider is a data provider for linode API type Provider struct { - id string - client *linodego.Client + id string + client *linodego.Client + services schema.ServiceMap } // New creates a new provider client for linode API @@ -38,7 +42,24 @@ func New(options schema.OptionBlock) (*Provider, error) { client := linodego.NewClient(oc) - return &Provider{id: id, client: &client}, nil + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } + return &Provider{id: id, client: &client, services: services}, nil } // Name returns the name of the provider @@ -51,8 +72,16 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // Resources returns the provider for an resource deployment source. func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { - provider := &instanceProvider{client: p.client, id: p.id} - return provider.GetResource(ctx) + if p.services.Has("instance") { + provider := &instanceProvider{client: p.client, id: p.id} + return provider.GetResource(ctx) + } + return nil, nil } diff --git a/pkg/providers/namecheap/namecheap.go b/pkg/providers/namecheap/namecheap.go index 090b1721..3bdb3ae2 100644 --- a/pkg/providers/namecheap/namecheap.go +++ b/pkg/providers/namecheap/namecheap.go @@ -2,6 +2,7 @@ package namecheap import ( "context" + "strings" "github.com/namecheap/go-namecheap-sdk/v2/namecheap" @@ -15,10 +16,13 @@ const ( providerName = "namecheap" ) +var Services = []string{"domain"} + // Provider is a data provider for NameCheap API type Provider struct { - id string - client *namecheap.Client + id string + client *namecheap.Client + services schema.ServiceMap } // New creates a new provider client for NameCheap API @@ -48,7 +52,25 @@ func New(options schema.OptionBlock) (*Provider, error) { UseSandbox: false, } - return &Provider{id: id, client: namecheap.NewClient(&clientOptions)}, nil + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } + + return &Provider{id: id, client: namecheap.NewClient(&clientOptions), services: services}, nil } // Name returns the name of the provider @@ -61,8 +83,16 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // Resources returns the provider for an resource func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { - provider := &domainProvider{client: p.client, id: p.id} - return provider.GetResource(ctx) + if p.services.Has("domain") { + provider := &domainProvider{client: p.client, id: p.id} + return provider.GetResource(ctx) + } + return nil, nil } diff --git a/pkg/providers/nomad/nomad.go b/pkg/providers/nomad/nomad.go index 40e4b7ee..7148ac5d 100644 --- a/pkg/providers/nomad/nomad.go +++ b/pkg/providers/nomad/nomad.go @@ -10,10 +10,13 @@ import ( "github.com/projectdiscovery/cloudlist/pkg/schema" ) +var Services = []string{"nomad"} + // Provider is a data provider for nomad resources type Provider struct { - id string - client *api.Client + id string + client *api.Client + services schema.ServiceMap } // New creates a new provider client for nomad resources API @@ -70,7 +73,11 @@ func New(options schema.OptionBlock) (*Provider, error) { return nil, errors.Wrap(err, "could not create nomad api client") } id, _ := options.GetMetadata("id") - return &Provider{id: id, client: conn}, nil + services := make(schema.ServiceMap) + for _, s := range Services { + services[s] = struct{}{} + } + return &Provider{id: id, client: conn, services: services}, nil } const providerName = "nomad" @@ -85,6 +92,11 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + const ( nomadURL = "nomad_url" nomadCAFile = "nomad_ca_file" diff --git a/pkg/providers/openstack/openstack.go b/pkg/providers/openstack/openstack.go index 5f812b30..1c359b0e 100644 --- a/pkg/providers/openstack/openstack.go +++ b/pkg/providers/openstack/openstack.go @@ -2,6 +2,7 @@ package openstack import ( "context" + "strings" "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack" @@ -20,10 +21,13 @@ const ( providerName = "openstack" ) +var Services = []string{"instance"} + // Provider is a data provider for Openstack API type Provider struct { - id string - client *gophercloud.ServiceClient + id string + client *gophercloud.ServiceClient + services schema.ServiceMap } // New creates a new provider client for Openstack API @@ -78,7 +82,24 @@ func New(options schema.OptionBlock) (*Provider, error) { return nil, err } - return &Provider{id: id, client: client}, nil + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } + return &Provider{id: id, client: client, services: services}, nil } // Name returns the name of the provider @@ -91,8 +112,16 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // Resources returns the provider for an resource func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { - provider := &instanceProvider{id: p.id, client: p.client} - return provider.GetResource(ctx) + if p.services.Has("instance") { + provider := &instanceProvider{id: p.id, client: p.client} + return provider.GetResource(ctx) + } + return nil, nil } diff --git a/pkg/providers/scaleway/scaleway.go b/pkg/providers/scaleway/scaleway.go index 68531dcc..01f0d970 100644 --- a/pkg/providers/scaleway/scaleway.go +++ b/pkg/providers/scaleway/scaleway.go @@ -2,16 +2,20 @@ package scaleway import ( "context" + "strings" "github.com/projectdiscovery/cloudlist/pkg/schema" "github.com/scaleway/scaleway-sdk-go/api/instance/v1" "github.com/scaleway/scaleway-sdk-go/scw" ) +var Services = []string{"instance"} + // Provider is a data provider for scaleway API type Provider struct { - id string - client *scw.Client + id string + client *scw.Client + services schema.ServiceMap } // New creates a new provider client for scaleway API @@ -25,12 +29,29 @@ func New(options schema.OptionBlock) (*Provider, error) { return nil, &schema.ErrNoSuchKey{Name: apiAccessToken} } id, _ := options.GetMetadata("id") + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } client, err := scw.NewClient(scw.WithAuth(accessKey, accessToken)) if err != nil { return nil, err } - return &Provider{client: client, id: id}, nil + return &Provider{client: client, id: id, services: services}, nil } const providerName = "scw" @@ -45,11 +66,19 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + const apiAccessKey = "scaleway_access_key" const apiAccessToken = "scaleway_access_token" // Resources returns the provider for an resource deployment source. func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { - provider := &instanceProvider{instanceAPI: instance.NewAPI(p.client), id: p.id} - return provider.GetResource(ctx) + if p.services.Has("instance") { + provider := &instanceProvider{instanceAPI: instance.NewAPI(p.client), id: p.id} + return provider.GetResource(ctx) + } + return nil, nil } diff --git a/pkg/providers/terraform/terraform.go b/pkg/providers/terraform/terraform.go index 301bb670..fa0a90b0 100644 --- a/pkg/providers/terraform/terraform.go +++ b/pkg/providers/terraform/terraform.go @@ -2,10 +2,13 @@ package terraform import ( "context" + "strings" "github.com/projectdiscovery/cloudlist/pkg/schema" ) +var Services = []string{"instance"} + const ( statePathFile = "tf_state_file" providerName = "terraform" @@ -13,8 +16,9 @@ const ( // Provider is a data provider for Terraform type Provider struct { - id string - path string + id string + path string + services schema.ServiceMap } // New creates a new provider client for Terraform @@ -24,7 +28,25 @@ func New(options schema.OptionBlock) (*Provider, error) { return nil, &schema.ErrNoSuchKey{Name: statePathFile} } id, _ := options.GetMetadata("id") - return &Provider{path: StatePathFile, id: id}, nil + + supportedServicesMap := make(map[string]struct{}) + for _, s := range Services { + supportedServicesMap[s] = struct{}{} + } + services := make(schema.ServiceMap) + if ss, ok := options.GetMetadata("services"); ok { + for _, s := range strings.Split(ss, ",") { + if _, ok := supportedServicesMap[s]; ok { + services[s] = struct{}{} + } + } + } + if len(services) == 0 { + for _, s := range Services { + services[s] = struct{}{} + } + } + return &Provider{path: StatePathFile, id: id, services: services}, nil } // Name returns the name of the provider @@ -37,8 +59,16 @@ func (p *Provider) ID() string { return p.id } +// Services returns the provider services +func (p *Provider) Services() []string { + return p.services.Keys() +} + // Resources returns the provider for an resource deployment source. func (p *Provider) Resources(ctx context.Context) (*schema.Resources, error) { - provider := &instanceProvider{path: p.path, id: p.id} - return provider.GetResource(ctx) + if p.services.Has("instance") { + provider := &instanceProvider{path: p.path, id: p.id} + return provider.GetResource(ctx) + } + return nil, nil } diff --git a/pkg/schema/schema.go b/pkg/schema/schema.go index 21bb008b..b369bdb8 100644 --- a/pkg/schema/schema.go +++ b/pkg/schema/schema.go @@ -7,6 +7,7 @@ import ( "sync" "github.com/projectdiscovery/cloudlist/pkg/schema/validate" + mapsutil "github.com/projectdiscovery/utils/maps" ) // Provider is an interface implemented by any cloud service provider. @@ -20,6 +21,9 @@ type Provider interface { ID() string // Resources returns the provider for an resource deployment source. Resources(ctx context.Context) (*Resources, error) + // Services returns the services provided by the Provider. + // If no services set, it will return all the supported services. + Services() []string } // Resources is a container of multiple resource returned from providers @@ -156,3 +160,14 @@ func (o OptionBlock) GetMetadata(key string) (string, bool) { } return data, true } + +type ServiceMap map[string]struct{} + +func (s ServiceMap) Has(service string) bool { + _, ok := s[service] + return ok +} + +func (s ServiceMap) Keys() []string { + return mapsutil.GetKeys(s) +}