From 8f17912dc73b71a2a788c6e04e57c4bfd32a3f08 Mon Sep 17 00:00:00 2001 From: adisos Date: Mon, 1 Jan 2024 11:36:29 +0200 Subject: [PATCH] issue #134 - wip Signed-off-by: adisos --- go.mod | 15 +- go.sum | 217 +++++++++++- pkg/ibmvpc/analysis_output_test.go | 10 +- pkg/ibmvpc/collector_test.go | 27 ++ pkg/ibmvpc/explainability_test.go | 7 +- pkg/ibmvpc/naclAnalysis_test.go | 8 +- pkg/ibmvpc/parser.go | 552 +++++++---------------------- 7 files changed, 364 insertions(+), 472 deletions(-) create mode 100644 pkg/ibmvpc/collector_test.go diff --git a/go.mod b/go.mod index e7cde16ff..4757d0b0e 100644 --- a/go.mod +++ b/go.mod @@ -4,29 +4,34 @@ go 1.21 require ( github.com/IBM/vpc-go-sdk v0.45.0 + github.com/np-guard/cloud-resource-collector v0.3.0 github.com/np-guard/vpc-network-config-synthesis v0.1.0 github.com/stretchr/testify v1.8.4 ) require ( + github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20230118060037-101bda076037 // indirect github.com/IBM/go-sdk-core/v5 v5.14.1 // indirect + github.com/IBM/networking-go-sdk v0.44.0 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/go-openapi/errors v0.20.3 // indirect + github.com/gabriel-vasile/mimetype v1.4.3 // indirect + github.com/go-openapi/errors v0.20.4 // indirect github.com/go-openapi/strfmt v0.21.7 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.13.0 // indirect + github.com/go-playground/validator/v10 v10.15.5 // indirect github.com/google/uuid v1.3.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-retryablehttp v0.7.2 // indirect - github.com/leodido/go-urn v1.2.3 // indirect + github.com/hashicorp/go-retryablehttp v0.7.4 // indirect + github.com/leodido/go-urn v1.2.4 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/oklog/ulid v1.3.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - go.mongodb.org/mongo-driver v1.11.4 // indirect + go.mongodb.org/mongo-driver v1.12.1 // indirect golang.org/x/crypto v0.17.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index e949572db..787438503 100644 --- a/go.sum +++ b/go.sum @@ -1,110 +1,295 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20230118060037-101bda076037 h1:C1gOsj2A5ouRUXrmKHebXjs4FXRE8ApMUC3GBUpd9Co= +github.com/IBM-Cloud/container-services-go-sdk v0.0.0-20230118060037-101bda076037/go.mod h1:xUQL9SGAjoZFd4GNjrjjtEpjpkgU7RFXRyHesbKTjiY= +github.com/IBM/go-sdk-core/v5 v5.5.1/go.mod h1:Sn+z+qTDREQvCr+UFa22TqqfXNxx3o723y8GsfLV8e0= github.com/IBM/go-sdk-core/v5 v5.14.1 h1:WR1r0zz+gDW++xzZjF41r9ueY4JyjS2vgZjiYs8lO3c= github.com/IBM/go-sdk-core/v5 v5.14.1/go.mod h1:MUvIr/1mgGh198ZXL+ByKz9Qs1JoEh80v/96x8jPXNY= +github.com/IBM/networking-go-sdk v0.44.0 h1:6acyMd6hwxcjK3bJ2suiUBTjzg8mRFAvYD76zbx0adk= +github.com/IBM/networking-go-sdk v0.44.0/go.mod h1:XtqYRInR5NHmFUXhOL6RovpDdv6PnJfZ1lPFvssA8MA= github.com/IBM/vpc-go-sdk v0.45.0 h1:RFbUZH5vBRGAEW5+jRzbDlxB+a+GvG9EBhyYO52Tvrs= github.com/IBM/vpc-go-sdk v0.45.0/go.mod h1:4Hs5d/aClmsxAzwDQkwG+ri0vW2ykPJdpM6hDLRwKcA= +github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 h1:DklsrG3dyBCFEj5IhUbnKptjxatkF07cF2ak3yi77so= github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2/go.mod h1:WaHUgvxTVq04UNunO+XhnAqY/wQc+bxr74GqbsZ/Jqw= +github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= 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= +github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= -github.com/go-openapi/errors v0.20.3 h1:rz6kiC84sqNQoqrtulzaL/VERgkoCyB6WdEkc2ujzUc= -github.com/go-openapi/errors v0.20.3/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk= +github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= +github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= +github.com/go-openapi/errors v0.19.8/go.mod h1:cM//ZKUKyO06HSwqAelJ5NsEMMcpa6VpXe8DOa1Mi1M= +github.com/go-openapi/errors v0.20.4 h1:unTcVm6PispJsMECE3zWgvG4xTiKda1LIR5rCRWLG6M= +github.com/go-openapi/errors v0.20.4/go.mod h1:Z3FlZ4I8jEGxjUK+bugx3on2mIAk4txuAOhlsB1FSgk= +github.com/go-openapi/strfmt v0.20.1/go.mod h1:43urheQI9dNtE5lTZQfuFJvjYJKPrxicATpEfZwHUNk= github.com/go-openapi/strfmt v0.21.7 h1:rspiXgNWgeUzhjo1YU01do6qsahtJNByjLVbPLNHb8k= github.com/go-openapi/strfmt v0.21.7/go.mod h1:adeGTkxE44sPyLk0JV235VQAO/ZXUr8KAzYjclFs3ew= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.13.0 h1:cFRQdfaSMCOSfGCCLB20MHvuoHb/s5G8L5pu2ppK5AQ= -github.com/go-playground/validator/v10 v10.13.0/go.mod h1:dwu7+CG8/CtBiJFZDz4e+5Upb6OLw04gtBYw0mcG/z4= +github.com/go-playground/validator/v10 v10.15.5 h1:LEBecTWb/1j5TNY1YYG2RcOUN3R7NLylN+x8TTueE24= +github.com/go-playground/validator/v10 v10.15.5/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= +github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= +github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= +github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= +github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= +github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= +github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= +github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= +github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= +github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= +github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= +github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= +github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= +github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= +github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= +github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +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= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/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/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 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/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= -github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0= -github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= +github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= +github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA= +github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= +github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= +github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.3 h1:6BE2vPT0lqoz3fmOesHZiaiFh7889ssCo2GMvLCfiuA= -github.com/leodido/go-urn v1.2.3/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= +github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= +github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= +github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/np-guard/cloud-resource-collector v0.3.0 h1:ntVDlSMIYjXh/gI8CyWd7d5OEhDkaxgdpH5myW7SVb4= +github.com/np-guard/cloud-resource-collector v0.3.0/go.mod h1:40J5EuYYQYKtCx5Vt5+LRoteKxV+E1QNuE4mLcf7LO8= github.com/np-guard/vpc-network-config-synthesis v0.1.0 h1:yAKR2w4TXcs4ir12dQwoglIll/AeQfFNcLH0NGCQIFc= github.com/np-guard/vpc-network-config-synthesis v0.1.0/go.mod h1:wQkZxRT4t8Ut0YwOOyIbZzVP8578sy6RvLoUngSUAeI= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= +github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= 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/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= -github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= +github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= -go.mongodb.org/mongo-driver v1.11.4 h1:4ayjakA013OdpGyL2K3ZqylTac/rMjrJOMZ1EHizXas= -go.mongodb.org/mongo-driver v1.11.4/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mongodb.org/mongo-driver v1.5.1/go.mod h1:gRXCHX4Jo7J0IJ1oDQyUxF7jfy19UfxniMS4xxMmUqw= +go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE= +go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +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/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +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= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/ibmvpc/analysis_output_test.go b/pkg/ibmvpc/analysis_output_test.go index 83b4bcc6f..6039dc61f 100644 --- a/pkg/ibmvpc/analysis_output_test.go +++ b/pkg/ibmvpc/analysis_output_test.go @@ -327,7 +327,7 @@ var tests = []*vpcGeneralTest{ format: vpcmodel.Text, }, // multi-vpc config examples - { + /*{ name: "experiments_env", useCases: []vpcmodel.OutputUseCase{vpcmodel.AllEndpoints}, format: vpcmodel.Text, @@ -336,7 +336,7 @@ var tests = []*vpcGeneralTest{ name: "experiments_env", useCases: []vpcmodel.OutputUseCase{vpcmodel.AllEndpoints}, format: vpcmodel.JSON, - }, + },*/ { name: "multiple_vpcs", useCases: []vpcmodel.OutputUseCase{vpcmodel.AllSubnets}, @@ -474,11 +474,7 @@ func getVPCConfigs(t *testing.T, tt *vpcGeneralTest, firstCfg bool) map[string]* inputConfig = tt.inputConfig2nd } inputConfigFile := filepath.Join(getTestsDir(), inputConfig) - inputConfigContent, err := os.ReadFile(inputConfigFile) - if err != nil { - t.Fatalf("err: %s", err) - } - rc, err := ParseResources(inputConfigContent) + rc, err := ParseResourcesFromFile(inputConfigFile) if err != nil { t.Fatalf("err: %s", err) } diff --git a/pkg/ibmvpc/collector_test.go b/pkg/ibmvpc/collector_test.go new file mode 100644 index 000000000..84ff43acd --- /dev/null +++ b/pkg/ibmvpc/collector_test.go @@ -0,0 +1,27 @@ +package ibmvpc + +import ( + "encoding/json" + "fmt" + "os" + "path/filepath" + "testing" + + "github.com/np-guard/cloud-resource-collector/pkg/ibm/datamodel" +) + +func TestCollector(t *testing.T) { + inputConfig := "input_experiments_env.json" + inputConfigFile := filepath.Join(getTestsDir(), inputConfig) + inputConfigContent, err := os.ReadFile(inputConfigFile) + if err != nil { + t.Fatalf("err: %s", err) + } + + config := datamodel.ResourcesContainerModel{} + err = json.Unmarshal(inputConfigContent, &config) + if err != nil { + t.Errorf("Unmarshal failed with error message: %v", err) + } + fmt.Println("done") +} diff --git a/pkg/ibmvpc/explainability_test.go b/pkg/ibmvpc/explainability_test.go index 6eaf61331..9279b9dac 100644 --- a/pkg/ibmvpc/explainability_test.go +++ b/pkg/ibmvpc/explainability_test.go @@ -2,7 +2,6 @@ package ibmvpc import ( "fmt" - "os" "testing" "path/filepath" @@ -164,11 +163,7 @@ func TestSimpleExternal(t *testing.T) { // getConfigs returns map[string]*vpcmodel.VPCConfig obj for the input test (config json file) func getConfig(t *testing.T, inputConfig string) *vpcmodel.VPCConfig { inputConfigFile := filepath.Join(getTestsDir(), inputConfig) - inputConfigContent, err := os.ReadFile(inputConfigFile) - if err != nil { - t.Fatalf("err: %s", err) - } - rc, err := ParseResources(inputConfigContent) + rc, err := ParseResourcesFromFile(inputConfigFile) if err != nil { t.Fatalf("err: %s", err) } diff --git a/pkg/ibmvpc/naclAnalysis_test.go b/pkg/ibmvpc/naclAnalysis_test.go index 5dc468006..d2a4a0bae 100644 --- a/pkg/ibmvpc/naclAnalysis_test.go +++ b/pkg/ibmvpc/naclAnalysis_test.go @@ -1,8 +1,8 @@ package ibmvpc import ( - _ "embed" "fmt" + "path/filepath" "testing" "github.com/stretchr/testify/require" @@ -10,12 +10,8 @@ import ( "github.com/np-guard/vpc-network-config-analyzer/pkg/common" ) -//go:embed examples/input_acl_testing3.json -var acl3Input []byte - func TestGetRules(t *testing.T) { - inputResourcesJSON := acl3Input - rc, err := ParseResources(inputResourcesJSON) + rc, err := ParseResourcesFromFile(filepath.Join(getTestsDir(), "input_acl_testing3.json")) require.Nilf(t, err, "err: %s", err) vpcConfigs, err := VPCConfigsFromResources(rc, "", false) require.Nilf(t, err, "err: %s", err) diff --git a/pkg/ibmvpc/parser.go b/pkg/ibmvpc/parser.go index 0ba6703f1..8454c1857 100644 --- a/pkg/ibmvpc/parser.go +++ b/pkg/ibmvpc/parser.go @@ -9,377 +9,139 @@ import ( vpc1 "github.com/IBM/vpc-go-sdk/vpcv1" + "github.com/np-guard/cloud-resource-collector/pkg/ibm/datamodel" "github.com/np-guard/vpc-network-config-analyzer/pkg/common" vpcmodel "github.com/np-guard/vpc-network-config-analyzer/pkg/vpcmodel" ) -const ( - protocolTCP = "tcp" - protocolUDP = "udp" - inbound = "inbound" - outbound = "outbound" - networkInterfaceResourceType = "network_interface" // used as the type within api objects (e.g. SecurityGroup.Targets.ResourceType) - vpeResourceType = "endpoint_gateway" // used as the type within api objects (e.g. SecurityGroup.Targets.ResourceType) - cidrSeparator = ", " - linesSeparator = "---------------------" -) - -// Resource types const strings, used in the generated resources of this pkg -const ( - ResourceTypeVSI = "VSI" - ResourceTypeNetworkInterface = "NetworkInterface" - ResourceTypeSubnet = "Subnet" - ResourceTypePublicGateway = "PublicGateway" - ResourceTypeFloatingIP = "FloatingIP" - ResourceTypeVPC = "VPC" - ResourceTypeSG = "SG" - ResourceTypeNACL = "NACL" - ResourceTypeIKSNode = "IKSNodeNetworkInterface" - ResourceTypeVPE = "VPE" - ResourceTypeTGW = "TGW" - ResourceTypeReservedIP = "ReservedIP" -) - -type ResourcesContainer struct { - naclList []*vpc1.NetworkACL - sgList []*vpc1.SecurityGroup - instanceList []*vpc1.Instance - subnetsList []*vpc1.Subnet - vpcsList []*vpc1.VPC - fipList []*vpc1.FloatingIP - pgwList []*vpc1.PublicGateway - vpeList []*vpc1.EndpointGateway - iksNodes []*iksNode - transitConns []*transitConnection -} - -func NewResourcesContainer() *ResourcesContainer { - res := &ResourcesContainer{ - naclList: []*vpc1.NetworkACL{}, - sgList: []*vpc1.SecurityGroup{}, - instanceList: []*vpc1.Instance{}, - subnetsList: []*vpc1.Subnet{}, - vpcsList: []*vpc1.VPC{}, - fipList: []*vpc1.FloatingIP{}, - pgwList: []*vpc1.PublicGateway{}, - iksNodes: []*iksNode{}, - transitConns: []*transitConnection{}, +// ParseResourcesFromFile returns datamodel.ResourcesContainerModel object, containing the configured resources structs +// from the input JSON file +func ParseResourcesFromFile(fileName string) (*datamodel.ResourcesContainerModel, error) { + inputConfigContent, err := os.ReadFile(fileName) + if err != nil { + return nil, err } - return res -} - -func (rc *ResourcesContainer) addNACL(n *vpc1.NetworkACL) { - rc.naclList = append(rc.naclList, n) -} - -func (rc *ResourcesContainer) addSG(n *vpc1.SecurityGroup) { - rc.sgList = append(rc.sgList, n) -} - -func (rc *ResourcesContainer) addInstance(n *vpc1.Instance) { - rc.instanceList = append(rc.instanceList, n) -} - -func (rc *ResourcesContainer) addSubnet(n *vpc1.Subnet) { - rc.subnetsList = append(rc.subnetsList, n) -} - -func (rc *ResourcesContainer) addVpc(n *vpc1.VPC) { - rc.vpcsList = append(rc.vpcsList, n) -} - -func (rc *ResourcesContainer) addFloatingIP(n *vpc1.FloatingIP) { - rc.fipList = append(rc.fipList, n) -} - -func (rc *ResourcesContainer) addPublicGateway(n *vpc1.PublicGateway) { - rc.pgwList = append(rc.pgwList, n) -} - -func (rc *ResourcesContainer) addVPE(n *vpc1.EndpointGateway) { - rc.vpeList = append(rc.vpeList, n) -} - -func (rc *ResourcesContainer) addIKSNode(n *iksNode) { - rc.iksNodes = append(rc.iksNodes, n) -} - -func (rc *ResourcesContainer) addTransitConn(n *transitConnection) { - rc.transitConns = append(rc.transitConns, n) -} - -var _ = (*ResourcesContainer).printDetails // avoiding "unused" warning - -func (rc *ResourcesContainer) printDetails() { - fmt.Printf("Has %d nacl objects\n", len(rc.naclList)) - fmt.Printf("Has %d sg objects\n", len(rc.sgList)) - fmt.Printf("Has %d instance objects\n", len(rc.instanceList)) -} - -func addParsedNACL(vList []json.RawMessage, res *ResourcesContainer) error { - for i := range vList { - obj, err := JSONNaclToObject(vList[i]) - if err != nil { - return err - } - res.addNACL(obj) + config := datamodel.ResourcesContainerModel{} + err = json.Unmarshal(inputConfigContent, &config) + if err != nil { + return nil, err } - return nil + return &config, nil } -func addParsedSG(vList []json.RawMessage, res *ResourcesContainer) error { - for i := range vList { - obj, err := JSONSgToObject(vList[i]) - if err != nil { - return err - } - res.addSG(obj) - } - return nil -} +// VPCConfigsFromResources returns a map from VPC UID (string) to its corresponding VPCConfig object, +// containing the parsed resources in the relevant model objects +func VPCConfigsFromResources(rc *datamodel.ResourcesContainerModel, vpcID string, debug bool) (map[string]*vpcmodel.VPCConfig, error) { + res := map[string]*vpcmodel.VPCConfig{} // map from VPC UID to its config + var err error -func addParsedInstances(vList []json.RawMessage, res *ResourcesContainer) error { - for i := range vList { - obj, err := JSONInstanceToObject(vList[i]) - if err != nil { - return err - } - res.addInstance(obj) + // if certain VPC to analyze is specified, skip resources configured outside that VPC + var shouldSkipByVPC = func(crn string) bool { + return vpcID != "" && crn != vpcID } - return nil -} - -type iksNode struct { - Cidr string - IPAddress string - SubnetID string - ID string -} - -type transitConnection struct { - NetworkID string // network_id is the vpc's crn connected to the tgw - Name string // name of the tgw - CRN string // crn of the tgw -} -/* -assuming the following components are within input to transitConnection: - "network_id": vpc-crn, - "transit_gateway": { - "crn": tgw-crn, - "id": tgw-id, - "name": tgw-name - }, -*/ + err = getVPCconfig(rc, res, shouldSkipByVPC) + if err != nil { + return nil, err + } -func parseTransitConn(m map[string]json.RawMessage) (*transitConnection, error) { - res := &transitConnection{} + var vpcInternalAddressRange map[string]*common.IPBlock // map from vpc name to its internal address range - err := json.Unmarshal(m["transit_gateway"], &res) + subnetNameToNetIntf := map[string][]*NetworkInterface{} + err = getInstancesConfig(rc.InstanceList, subnetNameToNetIntf, res, shouldSkipByVPC) if err != nil { return nil, err } - err = json.Unmarshal(m["network_id"], &res.NetworkID) + // pgw can be attached to multiple subnets in the zone + pgwToSubnet := map[string][]*Subnet{} // map from pgw name to its attached subnet(s) + subnetNameToSubnet := map[string]*Subnet{} + vpcInternalAddressRange, err = getSubnetsConfig(res, pgwToSubnet, subnetNameToSubnet, subnetNameToNetIntf, rc, shouldSkipByVPC) if err != nil { return nil, err } - return res, err -} - -var errIksParsing = errors.New("issue parsing IKS node") - -/* -assuming the following components are within input to parseIKSNode: -"networkInterfaces": [ - { - "cidr": "cidr-str", - "ipAddress": "ip-str", - "subnetID": "id-str" - } - ], -"id": "id-str", - -*/ - -func parseIKSNode(m map[string]json.RawMessage) (*iksNode, error) { - // parse the "networkInterfaces" section - nis, ok := m["networkInterfaces"] - if !ok { - return nil, errIksParsing - } - netInterfaces, err := JSONToList(nis) + // assign to each vpc object its internal address range, as inferred from its subnets + err = updateVPCSAddressRanges(vpcInternalAddressRange, res) if err != nil { return nil, err } - if len(netInterfaces) != 1 { - return nil, errIksParsing - } - var iksNodes []iksNode - err = json.Unmarshal(nis, &iksNodes) + err = getIKSnodesConfig(res, subnetNameToSubnet, rc, shouldSkipByVPC) if err != nil { return nil, err } - if len(iksNodes) != 1 { - return nil, errIksParsing - } - res := &iksNodes[0] - - // parse the "id" section - id, ok := m["id"] - if !ok { - return nil, errIksParsing - } - err = json.Unmarshal(id, &res.ID) + err = getPgwConfig(res, rc, pgwToSubnet, shouldSkipByVPC) if err != nil { return nil, err } - return res, nil -} - -func addParsedTransitConn(vList []json.RawMessage, res *ResourcesContainer) error { - for i := range vList { - nodesMap, err := JSONToMap(vList[i]) - if err != nil { - return err - } - obj, err := parseTransitConn(nodesMap) - if err != nil { - return err - } - res.addTransitConn(obj) - } - return nil -} - -func addParsedWorkerNodes(vList []json.RawMessage, res *ResourcesContainer) error { - for i := range vList { - nodesMap, err := JSONToMap(vList[i]) - if err != nil { - return err - } - obj, err := parseIKSNode(nodesMap) - if err != nil { - return err - } - res.addIKSNode(obj) - } - - return nil -} - -func addParsedSubnets(vList []json.RawMessage, res *ResourcesContainer) error { - for i := range vList { - obj, err := JSONSubnetToObject(vList[i]) - if err != nil { - return err - } - res.addSubnet(obj) - } - return nil -} - -func addParsedVPCs(vList []json.RawMessage, res *ResourcesContainer) error { - for i := range vList { - obj, err := JSONVpcToObject(vList[i]) - if err != nil { - return err - } - res.addVpc(obj) - } - return nil -} - -func addParsedFips(vList []json.RawMessage, res *ResourcesContainer) error { - for i := range vList { - obj, err := JSONFipToObject(vList[i]) - if err != nil { - return err - } - res.addFloatingIP(obj) + err = getFipConfig(rc, res, shouldSkipByVPC) + if err != nil { + return nil, err } - return nil -} -func addParsedPgw(vList []json.RawMessage, res *ResourcesContainer) error { - for i := range vList { - obj, err := JSONPgwTpObject(vList[i]) - if err != nil { - return err - } - res.addPublicGateway(obj) + err = getVPEconfig(rc, res, shouldSkipByVPC) + if err != nil { + return nil, err } - return nil -} -func addParsedVPE(vList []json.RawMessage, res *ResourcesContainer) error { - for i := range vList { - obj, err := JSONVpeToObject(vList[i]) - if err != nil { - return err - } - res.addVPE(obj) + err = getSGconfig(rc, res, shouldSkipByVPC) + if err != nil { + return nil, err } - return nil -} -func parseSingleResourceList(key string, vList []json.RawMessage, res *ResourcesContainer) error { - switch key { - case "network_acls": - return addParsedNACL(vList, res) - case "security_groups": - return addParsedSG(vList, res) - case "instances": - return addParsedInstances(vList, res) - case "subnets": - return addParsedSubnets(vList, res) - case "vpcs": - return addParsedVPCs(vList, res) - case "floating_ips": - return addParsedFips(vList, res) - case "public_gateways": - return addParsedPgw(vList, res) - case "endpoint_gateways": - return addParsedVPE(vList, res) - case "iks_worker_nodes": - return addParsedWorkerNodes(vList, res) - case "transit_connections": - return addParsedTransitConn(vList, res) - default: - fmt.Printf("%s resource type is not yet supported\n", key) + err = getNACLconfig(rc, res, subnetNameToSubnet, shouldSkipByVPC) + if err != nil { + return nil, err } - return nil -} -func ParseResourcesFromFile(fileName string) (*ResourcesContainer, error) { - jsonContent, err := os.ReadFile(fileName) + err = filterVPCSAndAddExternalNodes(vpcInternalAddressRange, res) if err != nil { return nil, err } - return ParseResources(jsonContent) -} -func ParseResources(resourcesJSONFile []byte) (*ResourcesContainer, error) { - var err error - res := NewResourcesContainer() - resourcesMap, err := JSONToMap(resourcesJSONFile) + tgws := getTgwObjects(rc, res) + err = addTGWbasedConfigs(tgws, res) if err != nil { return nil, err } - for k, v := range resourcesMap { - vList, err := JSONToList(v) - if err != nil { - return nil, err - } - if err := parseSingleResourceList(k, vList, res); err != nil { - return nil, err - } + + if debug { + printVPCConfigs(res) } + return res, nil } +const ( + protocolTCP = "tcp" + protocolUDP = "udp" + inbound = "inbound" + outbound = "outbound" + networkInterfaceResourceType = "network_interface" // used as the type within api objects (e.g. SecurityGroup.Targets.ResourceType) + vpeResourceType = "endpoint_gateway" // used as the type within api objects (e.g. SecurityGroup.Targets.ResourceType) + cidrSeparator = ", " + linesSeparator = "---------------------" +) + +// Resource types const strings, used in the generated resources of this pkg +const ( + ResourceTypeVSI = "VSI" + ResourceTypeNetworkInterface = "NetworkInterface" + ResourceTypeSubnet = "Subnet" + ResourceTypePublicGateway = "PublicGateway" + ResourceTypeFloatingIP = "FloatingIP" + ResourceTypeVPC = "VPC" + ResourceTypeSG = "SG" + ResourceTypeNACL = "NACL" + ResourceTypeIKSNode = "IKSNodeNetworkInterface" + ResourceTypeVPE = "VPE" + ResourceTypeTGW = "TGW" + ResourceTypeReservedIP = "ReservedIP" +) + +var errIksParsing = errors.New("issue parsing IKS node") + func getCertainNodes(allNodes []vpcmodel.Node, shouldTakeNode func(vpcmodel.Node) bool) (ret []vpcmodel.Node) { for _, s := range allNodes { if shouldTakeNode(s) { @@ -401,7 +163,7 @@ func addZone(zoneName, vpcUID string, res map[string]*vpcmodel.VPCConfig) error } func getInstancesConfig( - instanceList []*vpc1.Instance, + instanceList []*datamodel.Instance, subnetNameToNetIntf map[string][]*NetworkInterface, res map[string]*vpcmodel.VPCConfig, skipByVPC func(string) bool, @@ -461,14 +223,14 @@ func getSubnetsConfig( pgwToSubnet map[string][]*Subnet, subnetNameToSubnet map[string]*Subnet, subnetNameToNetIntf map[string][]*NetworkInterface, - rc *ResourcesContainer, + rc *datamodel.ResourcesContainerModel, skipByVPC func(string) bool, ) (vpcInternalAddressRange map[string]*common.IPBlock, err error) { vpcInternalAddressRange = map[string]*common.IPBlock{} for vpcUID := range res { vpcInternalAddressRange[vpcUID] = nil } - for _, subnet := range rc.subnetsList { + for _, subnet := range rc.SubnetList { if skipByVPC(*subnet.VPC.CRN) { continue } @@ -537,11 +299,11 @@ func getSubnetsCidrs(subnets []*Subnet) []string { func getPgwConfig( res map[string]*vpcmodel.VPCConfig, - rc *ResourcesContainer, + rc *datamodel.ResourcesContainerModel, pgwToSubnet map[string][]*Subnet, skipByVPC func(string) bool, ) error { - for _, pgw := range rc.pgwList { + for _, pgw := range rc.PublicGWList { if skipByVPC(*pgw.VPC.CRN) { continue } @@ -584,11 +346,11 @@ func ignoreFIPWarning(fipName, details string) string { } func getFipConfig( - rc *ResourcesContainer, + rc *datamodel.ResourcesContainerModel, res map[string]*vpcmodel.VPCConfig, skipByVPC func(string) bool, ) error { - for _, fip := range rc.fipList { + for _, fip := range rc.FloatingIPList { targetIntf := fip.Target var targetUID string switch target := targetIntf.(type) { @@ -661,8 +423,8 @@ func getFipConfig( return nil } -func getVPCconfig(rc *ResourcesContainer, res map[string]*vpcmodel.VPCConfig, skipByVPC func(string) bool) error { - for _, vpc := range rc.vpcsList { +func getVPCconfig(rc *datamodel.ResourcesContainerModel, res map[string]*vpcmodel.VPCConfig, skipByVPC func(string) bool) error { + for _, vpc := range rc.VpcList { if skipByVPC(*vpc.CRN) { continue // skip vpc not specified to analyze } @@ -717,13 +479,13 @@ func parseSGTargets(sgResource *SecurityGroup, } } -func getSGconfig(rc *ResourcesContainer, +func getSGconfig(rc *datamodel.ResourcesContainerModel, res map[string]*vpcmodel.VPCConfig, skipByVPC func(string) bool, ) error { sgMap := map[string]map[string]*SecurityGroup{} // map from vpc uid to map from sg name to its sg object sgLists := map[string][]*SecurityGroup{} - for _, sg := range rc.sgList { + for _, sg := range rc.SecurityGroupList { if skipByVPC(*sg.VPC.CRN) { continue } @@ -740,13 +502,13 @@ func getSGconfig(rc *ResourcesContainer, ResourceType: ResourceTypeSG, VPCRef: vpc, }, - analyzer: NewSGAnalyzer(sg), members: map[string]vpcmodel.Node{}, + analyzer: NewSGAnalyzer(&sg.SecurityGroup), members: map[string]vpcmodel.Node{}, } if _, ok := sgMap[vpcUID]; !ok { sgMap[vpcUID] = map[string]*SecurityGroup{} } sgMap[vpcUID][*sg.Name] = sgResource - parseSGTargets(sgResource, sg, res[vpcUID]) + parseSGTargets(sgResource, &sg.SecurityGroup, res[vpcUID]) sgLists[vpcUID] = append(sgLists[vpcUID], sgResource) } for vpcUID, sgListInstance := range sgLists { @@ -776,17 +538,17 @@ func getSGconfig(rc *ResourcesContainer, return nil } -func getNACLconfig(rc *ResourcesContainer, +func getNACLconfig(rc *datamodel.ResourcesContainerModel, res map[string]*vpcmodel.VPCConfig, subnetNameToSubnet map[string]*Subnet, skipByVPC func(string) bool, ) error { naclLists := map[string][]*NACL{} // map from vpc uid to its nacls - for _, nacl := range rc.naclList { + for _, nacl := range rc.NetworkACLList { if skipByVPC(*nacl.VPC.CRN) { continue } - naclAnalyzer, err := NewNACLAnalyzer(nacl) + naclAnalyzer, err := NewNACLAnalyzer(&nacl.NetworkACL) if err != nil { return err } @@ -829,13 +591,13 @@ func getNACLconfig(rc *ResourcesContainer, return nil } -func getTgwObjects(c *ResourcesContainer, +func getTgwObjects(c *datamodel.ResourcesContainerModel, res map[string]*vpcmodel.VPCConfig) map[string]*TransitGateway { tgwMap := map[string]*TransitGateway{} // collect all tgw resources - for _, tgwConn := range c.transitConns { - tgwUID := tgwConn.CRN - tgwName := tgwConn.Name - vpcUID := tgwConn.NetworkID + for _, tgwConn := range c.TransitConnectionList { + tgwUID := *tgwConn.TransitGateway.Crn + tgwName := *tgwConn.TransitGateway.Name + vpcUID := *tgwConn.NetworkID vpc, err := getVPCObjectByUID(res, vpcUID) if err != nil { fmt.Printf("warning: ignoring vpc that does not exist in tgw config, vpcID: %s\n", vpcUID) @@ -962,11 +724,11 @@ func getSubnetByIPAddress(address string, c *vpcmodel.VPCConfig) (subnet *Subnet return nil, fmt.Errorf("could not find matching subnet for address %s", address) } -func getVPEconfig(rc *ResourcesContainer, +func getVPEconfig(rc *datamodel.ResourcesContainerModel, res map[string]*vpcmodel.VPCConfig, skipByVPC func(string) bool, ) (err error) { - for _, vpe := range rc.vpeList { + for _, vpe := range rc.EndpointGWList { if skipByVPC(*vpe.VPC.CRN) { continue } @@ -1027,12 +789,18 @@ func getSubnetByCidr(m map[string]*Subnet, cidr string) (*Subnet, error) { func getIKSnodesConfig(res map[string]*vpcmodel.VPCConfig, subnetNameToSubnet map[string]*Subnet, - rc *ResourcesContainer, - skipByVPC func(string) bool) { - for _, iksNode := range rc.iksNodes { - subnet, err := getSubnetByCidr(subnetNameToSubnet, iksNode.Cidr) + rc *datamodel.ResourcesContainerModel, + skipByVPC func(string) bool) error { + for _, iksNode := range rc.IKSWorkerNodes { + if len(iksNode.NetworkInterfaces) != 1 { + return errIksParsing + } + iksNodeNetIntfObj := iksNode.NetworkInterfaces[0] + + subnet, err := getSubnetByCidr(subnetNameToSubnet, *iksNodeNetIntfObj.Cidr) if err != nil { - fmt.Printf("warning: ignoring iksNode with ID %s (could not find subnet with iksNode's CIDR: %s)\n", iksNode.ID, iksNode.Cidr) + fmt.Printf("warning: ignoring iksNode with ID %s (could not find subnet with iksNode's CIDR: %s)\n", + *iksNode.ID, *iksNodeNetIntfObj.Cidr) continue } if skipByVPC(subnet.VPC().UID()) { @@ -1043,17 +811,18 @@ func getIKSnodesConfig(res map[string]*vpcmodel.VPCConfig, nodeObject := &IKSNode{ VPCResource: vpcmodel.VPCResource{ ResourceName: "iks-node", - ResourceUID: iksNode.ID, + ResourceUID: *iksNode.ID, ResourceType: ResourceTypeIKSNode, VPCRef: vpc, }, - address: iksNode.IPAddress, + address: *iksNodeNetIntfObj.IpAddress, subnet: subnet, } res[vpcUID].Nodes = append(res[vpcUID].Nodes, nodeObject) // attach the node to the subnet subnet.nodes = append(subnet.nodes, nodeObject) } + return nil } func NewEmptyVPCConfig() *vpcmodel.VPCConfig { @@ -1067,87 +836,6 @@ func NewEmptyVPCConfig() *vpcmodel.VPCConfig { } } -// VPCConfigsFromResources returns a map from VPC UID (string) to its corresponding VPCConfig object, -// containing the parsed resources in the relevant model objects -func VPCConfigsFromResources(rc *ResourcesContainer, vpcID string, debug bool) (map[string]*vpcmodel.VPCConfig, error) { - res := map[string]*vpcmodel.VPCConfig{} // map from VPC UID to its config - var err error - - // if certain VPC to analyze is specified, skip resources configured outside that VPC - var shouldSkipByVPC = func(crn string) bool { - return vpcID != "" && crn != vpcID - } - - err = getVPCconfig(rc, res, shouldSkipByVPC) - if err != nil { - return nil, err - } - - var vpcInternalAddressRange map[string]*common.IPBlock // map from vpc name to its internal address range - - subnetNameToNetIntf := map[string][]*NetworkInterface{} - err = getInstancesConfig(rc.instanceList, subnetNameToNetIntf, res, shouldSkipByVPC) - if err != nil { - return nil, err - } - // pgw can be attached to multiple subnets in the zone - pgwToSubnet := map[string][]*Subnet{} // map from pgw name to its attached subnet(s) - subnetNameToSubnet := map[string]*Subnet{} - vpcInternalAddressRange, err = getSubnetsConfig(res, pgwToSubnet, subnetNameToSubnet, subnetNameToNetIntf, rc, shouldSkipByVPC) - if err != nil { - return nil, err - } - // assign to each vpc object its internal address range, as inferred from its subnets - err = updateVPCSAddressRanges(vpcInternalAddressRange, res) - if err != nil { - return nil, err - } - - getIKSnodesConfig(res, subnetNameToSubnet, rc, shouldSkipByVPC) - - err = getPgwConfig(res, rc, pgwToSubnet, shouldSkipByVPC) - if err != nil { - return nil, err - } - - err = getFipConfig(rc, res, shouldSkipByVPC) - if err != nil { - return nil, err - } - - err = getVPEconfig(rc, res, shouldSkipByVPC) - if err != nil { - return nil, err - } - - err = getSGconfig(rc, res, shouldSkipByVPC) - if err != nil { - return nil, err - } - - err = getNACLconfig(rc, res, subnetNameToSubnet, shouldSkipByVPC) - if err != nil { - return nil, err - } - - err = filterVPCSAndAddExternalNodes(vpcInternalAddressRange, res) - if err != nil { - return nil, err - } - - tgws := getTgwObjects(rc, res) - err = addTGWbasedConfigs(tgws, res) - if err != nil { - return nil, err - } - - if debug { - printVPCConfigs(res) - } - - return res, nil -} - // filter VPCs with empty address ranges, then add for remaining VPCs the external nodes func filterVPCSAndAddExternalNodes(vpcInternalAddressRange map[string]*common.IPBlock, res map[string]*vpcmodel.VPCConfig) error { for vpcUID, vpcConfig := range res {