diff --git a/.copywrite.hcl b/.copywrite.hcl index ed2142c12a..3ba90e9d1e 100644 --- a/.copywrite.hcl +++ b/.copywrite.hcl @@ -13,5 +13,6 @@ project { "**/testdata/**", "**/*.pb.go", "**/*_string.go", + ".git/**", ] -} \ No newline at end of file +} diff --git a/go.mod b/go.mod index bbaf5c4f9b..6f63c222bd 100644 --- a/go.mod +++ b/go.mod @@ -236,7 +236,7 @@ require ( github.com/denis-tingaikin/go-header v0.5.0 // indirect github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.1 // indirect - github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/ettle/strcase v0.2.0 // indirect @@ -419,18 +419,20 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect ) +require github.com/moby/buildkit v0.13.1 + require ( cloud.google.com/go/auth v0.2.2 // indirect cloud.google.com/go/auth/oauth2adapt v0.2.1 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect - github.com/containerd/log v0.1.0 // indirect + github.com/agext/levenshtein v1.2.3 // indirect + github.com/containerd/typeurl/v2 v2.1.1 // indirect github.com/creack/pty v1.1.18 // indirect github.com/go-errors/errors v1.5.0 // indirect github.com/go-jose/go-jose/v4 v4.0.1 // indirect github.com/go-test/deep v1.1.0 // indirect github.com/gopherjs/gopherjs v1.17.2 // indirect github.com/jtolds/gls v4.20.0+incompatible // indirect - github.com/moby/term v0.5.0 // indirect github.com/smarty/assertions v1.15.1 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0 // indirect go.opentelemetry.io/otel/sdk v1.25.0 // indirect diff --git a/go.sum b/go.sum index 1d3c3723d4..972a404327 100644 --- a/go.sum +++ b/go.sum @@ -126,6 +126,8 @@ github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0k github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/alecthomas/assert/v2 v2.3.0 h1:mAsH2wmvjsuvyBvAmCtm7zFsBlb8mIHx5ySLVdDZXL0= github.com/alecthomas/assert/v2 v2.3.0/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= github.com/alecthomas/go-check-sumtype v0.1.4 h1:WCvlB3l5Vq5dZQTFmodqL2g68uHiSwwlWcT5a2FGK0c= @@ -302,6 +304,8 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/containerd/stargz-snapshotter/estargz v0.15.1 h1:eXJjw9RbkLFgioVaTG+G/ZW/0kEe2oEKCdS/ZxIyoCU= github.com/containerd/stargz-snapshotter/estargz v0.15.1/go.mod h1:gr2RNwukQ/S9Nv33Lt6UC7xEx58C+LHRdoqbEKjz1Kk= +github.com/containerd/typeurl/v2 v2.1.1 h1:3Q4Pt7i8nYwy2KmQWIw2+1hTvwTE/6w9FqcttATPO/4= +github.com/containerd/typeurl/v2 v2.1.1/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -341,8 +345,8 @@ github.com/docker/docker v26.0.2+incompatible h1:yGVmKUFGgcxA6PXWAokO0sQL22BrQ67 github.com/docker/docker v26.0.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -851,6 +855,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mitchellh/mapstructure v1.4.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/moby/buildkit v0.13.1 h1:L8afOFhPq2RPJJSr/VyzbufwID7jquZVB7oFHbPRcPE= +github.com/moby/buildkit v0.13.1/go.mod h1:aNmNQKLBFYAOFuzQjR3VA27/FijlvtBD1pjNwTSN37k= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= diff --git a/providers-sdk/v1/lr/lr_test.go b/providers-sdk/v1/lr/lr_test.go index a571f5fb88..6b21dcddb4 100644 --- a/providers-sdk/v1/lr/lr_test.go +++ b/providers-sdk/v1/lr/lr_test.go @@ -168,7 +168,12 @@ func TestParse(t *testing.T) { embed os.any }`) fields := []*Field{ - {BasicField: &BasicField{isEmbedded: true, ID: "os", Type: Type{SimpleType: &SimpleType{Type: "os.any"}}, Args: &FieldArgs{}}}, + {BasicField: &BasicField{ + isEmbedded: true, + ID: "os", + Type: Type{SimpleType: &SimpleType{Type: "os.any"}}, + Args: &FieldArgs{}, + }}, } assert.Equal(t, "name.no", res.Resources[0].ID) @@ -182,7 +187,12 @@ func TestParse(t *testing.T) { embed os.any as testx }`) fields := []*Field{ - {BasicField: &BasicField{isEmbedded: true, ID: "testx", Type: Type{SimpleType: &SimpleType{Type: "os.any"}}, Args: &FieldArgs{}}}, + {BasicField: &BasicField{ + isEmbedded: true, + ID: "testx", + Type: Type{SimpleType: &SimpleType{Type: "os.any"}}, + Args: &FieldArgs{}, + }}, } assert.Equal(t, "name.no", res.Resources[0].ID) diff --git a/providers/aws/go.mod b/providers/aws/go.mod index 6fca42c55f..4e2ce81c76 100644 --- a/providers/aws/go.mod +++ b/providers/aws/go.mod @@ -134,6 +134,7 @@ require ( github.com/ckaznocha/intrange v0.1.2 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.5 // indirect + github.com/containerd/log v0.1.0 // indirect github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/daixiang0/gci v0.13.4 // indirect @@ -145,7 +146,7 @@ require ( github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker v26.0.2+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.1 // indirect - github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/ettle/strcase v0.2.0 // indirect diff --git a/providers/aws/go.sum b/providers/aws/go.sum index 0707b2c150..4d14eea2c2 100644 --- a/providers/aws/go.sum +++ b/providers/aws/go.sum @@ -321,8 +321,8 @@ github.com/docker/docker v26.0.2+incompatible h1:yGVmKUFGgcxA6PXWAokO0sQL22BrQ67 github.com/docker/docker v26.0.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dvsekhvalnov/jose2go v1.7.0 h1:bnQc8+GMnidJZA8zc6lLEAb4xNrIqHwO+9TzqvtQZPo= @@ -674,8 +674,8 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= -github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= -github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= +github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= +github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= diff --git a/providers/azure/go.mod b/providers/azure/go.mod index 8abe740494..03443c8b1a 100644 --- a/providers/azure/go.mod +++ b/providers/azure/go.mod @@ -31,6 +31,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azcertificates v1.1.0 github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.1.0 github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v1.1.0 + github.com/DataDog/gostackparse v0.7.0 github.com/cockroachdb/errors v1.11.1 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.32.0 @@ -113,6 +114,7 @@ require ( github.com/ckaznocha/intrange v0.1.2 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.5 // indirect + github.com/containerd/log v0.1.0 // indirect github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/daixiang0/gci v0.13.4 // indirect @@ -124,7 +126,7 @@ require ( github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker v26.0.2+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.1 // indirect - github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/ettle/strcase v0.2.0 // indirect diff --git a/providers/azure/go.sum b/providers/azure/go.sum index 766a3c1d9d..c6268ae8e6 100644 --- a/providers/azure/go.sum +++ b/providers/azure/go.sum @@ -133,6 +133,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DataDog/gostackparse v0.7.0 h1:i7dLkXHvYzHV308hnkvVGDL3BR4FWl7IsXNPz/IGQh4= +github.com/DataDog/gostackparse v0.7.0/go.mod h1:lTfqcJKqS9KnXQGnyQMCugq3u1FP6UZMfWR0aitKFMM= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= github.com/GaijinEntertainment/go-exhaustruct/v3 v3.2.0 h1:sATXp1x6/axKxz2Gjxv8MALP0bXaNRfQinEwyfMcx8c= @@ -291,8 +293,8 @@ github.com/docker/docker v26.0.2+incompatible h1:yGVmKUFGgcxA6PXWAokO0sQL22BrQ67 github.com/docker/docker v26.0.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dvsekhvalnov/jose2go v1.7.0 h1:bnQc8+GMnidJZA8zc6lLEAb4xNrIqHwO+9TzqvtQZPo= @@ -644,8 +646,8 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= -github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= -github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= +github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= +github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= diff --git a/providers/defaults.go b/providers/defaults.go index f406c77967..991d4e804e 100644 --- a/providers/defaults.go +++ b/providers/defaults.go @@ -264,7 +264,7 @@ var DefaultProviders Providers = map[string]*Provider{ Provider: &plugin.Provider{ Name: "os", ID: "go.mondoo.com/cnquery/v9/providers/os", - ConnectionTypes: []string{"local", "ssh", "tar", "docker-snapshot", "vagrant", "docker-image", "docker-container", "docker-registry", "container-registry", "registry-image", "filesystem"}, + ConnectionTypes: []string{"local", "ssh", "tar", "docker-snapshot", "vagrant", "docker-image", "docker-container", "docker-file", "docker-registry", "container-registry", "registry-image", "filesystem"}, Connectors: []plugin.Connector{ { Name: "local", diff --git a/providers/gcp/go.mod b/providers/gcp/go.mod index f58d3ee903..4ba3ca302c 100644 --- a/providers/gcp/go.mod +++ b/providers/gcp/go.mod @@ -108,6 +108,7 @@ require ( github.com/ckaznocha/intrange v0.1.2 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.5 // indirect + github.com/containerd/log v0.1.0 // indirect github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/daixiang0/gci v0.13.4 // indirect @@ -119,7 +120,7 @@ require ( github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker v26.0.2+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.1 // indirect - github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect github.com/ettle/strcase v0.2.0 // indirect diff --git a/providers/gcp/go.sum b/providers/gcp/go.sum index f35dc1ba7c..6c79857784 100644 --- a/providers/gcp/go.sum +++ b/providers/gcp/go.sum @@ -265,8 +265,8 @@ github.com/docker/docker v26.0.2+incompatible h1:yGVmKUFGgcxA6PXWAokO0sQL22BrQ67 github.com/docker/docker v26.0.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dvsekhvalnov/jose2go v1.7.0 h1:bnQc8+GMnidJZA8zc6lLEAb4xNrIqHwO+9TzqvtQZPo= @@ -624,8 +624,8 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= -github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= -github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= +github.com/moby/term v0.0.0-20221205130635-1aeaba878587 h1:HfkjXDfhgVaN5rmueG8cL8KKeFNecRCXFhaJ2qZ5SKA= +github.com/moby/term v0.0.0-20221205130635-1aeaba878587/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= diff --git a/providers/github/go.mod b/providers/github/go.mod index a63b18c340..f0377d60de 100644 --- a/providers/github/go.mod +++ b/providers/github/go.mod @@ -51,6 +51,7 @@ require ( github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/StackExchange/wmi v1.2.1 // indirect + github.com/agext/levenshtein v1.2.3 // indirect github.com/alecthomas/go-check-sumtype v0.1.4 // indirect github.com/alecthomas/participle v0.3.0 // indirect github.com/alecthomas/participle/v2 v2.1.1 // indirect @@ -103,6 +104,7 @@ require ( github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect + github.com/containerd/typeurl/v2 v2.1.1 // indirect github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/daixiang0/gci v0.13.4 // indirect @@ -114,7 +116,7 @@ require ( github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker v26.0.2+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.1 // indirect - github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect @@ -240,6 +242,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/moby/buildkit v0.13.1 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect diff --git a/providers/github/go.sum b/providers/github/go.sum index 8ae6698e33..a77efbcc6b 100644 --- a/providers/github/go.sum +++ b/providers/github/go.sum @@ -119,6 +119,8 @@ github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0k github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/alecthomas/assert/v2 v2.3.0 h1:mAsH2wmvjsuvyBvAmCtm7zFsBlb8mIHx5ySLVdDZXL0= github.com/alecthomas/assert/v2 v2.3.0/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= github.com/alecthomas/go-check-sumtype v0.1.4 h1:WCvlB3l5Vq5dZQTFmodqL2g68uHiSwwlWcT5a2FGK0c= @@ -273,6 +275,8 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/containerd/stargz-snapshotter/estargz v0.15.1 h1:eXJjw9RbkLFgioVaTG+G/ZW/0kEe2oEKCdS/ZxIyoCU= github.com/containerd/stargz-snapshotter/estargz v0.15.1/go.mod h1:gr2RNwukQ/S9Nv33Lt6UC7xEx58C+LHRdoqbEKjz1Kk= +github.com/containerd/typeurl/v2 v2.1.1 h1:3Q4Pt7i8nYwy2KmQWIw2+1hTvwTE/6w9FqcttATPO/4= +github.com/containerd/typeurl/v2 v2.1.1/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -309,8 +313,8 @@ github.com/docker/docker v26.0.2+incompatible h1:yGVmKUFGgcxA6PXWAokO0sQL22BrQ67 github.com/docker/docker v26.0.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -790,6 +794,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mitchellh/mapstructure v1.4.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/moby/buildkit v0.13.1 h1:L8afOFhPq2RPJJSr/VyzbufwID7jquZVB7oFHbPRcPE= +github.com/moby/buildkit v0.13.1/go.mod h1:aNmNQKLBFYAOFuzQjR3VA27/FijlvtBD1pjNwTSN37k= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= @@ -1099,8 +1105,8 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0 h1:cEPbyTS go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0/go.mod h1:DKdbWcT4GH1D0Y3Sqt/PFXt2naRKDWtU+eE6oLdFNA8= go.opentelemetry.io/otel v1.25.0 h1:gldB5FfhRl7OJQbUHt/8s0a7cE8fbsPAtdpRaApKy4k= go.opentelemetry.io/otel v1.25.0/go.mod h1:Wa2ds5NOXEMkCmUou1WA7ZBfLTHWIsp034OVD7AO+Vg= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0/go.mod h1:zgBdWWAu7oEEMC06MMKc5NLbA/1YDXV1sMpSqEeLQLg= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0 h1:Mbi5PKN7u322woPa85d7ebZ+SOvEoPvoiBu+ryHWgfA= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0/go.mod h1:e7ciERRhZaOZXVjx5MiL8TK5+Xv7G5Gv5PA2ZDEJdL8= go.opentelemetry.io/otel/metric v1.25.0 h1:LUKbS7ArpFL/I2jJHdJcqMGxkRdxpPHE0VU/D4NuEwA= diff --git a/providers/google-workspace/go.mod b/providers/google-workspace/go.mod index eae700011e..60a37d5cd9 100644 --- a/providers/google-workspace/go.mod +++ b/providers/google-workspace/go.mod @@ -47,6 +47,7 @@ require ( github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/StackExchange/wmi v1.2.1 // indirect + github.com/agext/levenshtein v1.2.3 // indirect github.com/alecthomas/go-check-sumtype v0.1.4 // indirect github.com/alecthomas/participle v0.3.0 // indirect github.com/alecthomas/participle/v2 v2.1.1 // indirect @@ -100,6 +101,7 @@ require ( github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect + github.com/containerd/typeurl/v2 v2.1.1 // indirect github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/daixiang0/gci v0.13.4 // indirect @@ -111,7 +113,7 @@ require ( github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker v26.0.2+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.1 // indirect - github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect @@ -235,6 +237,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/moby/buildkit v0.13.1 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect diff --git a/providers/google-workspace/go.sum b/providers/google-workspace/go.sum index 3a482a8452..e08fb29b49 100644 --- a/providers/google-workspace/go.sum +++ b/providers/google-workspace/go.sum @@ -119,6 +119,8 @@ github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0k github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/alecthomas/assert/v2 v2.3.0 h1:mAsH2wmvjsuvyBvAmCtm7zFsBlb8mIHx5ySLVdDZXL0= github.com/alecthomas/assert/v2 v2.3.0/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= github.com/alecthomas/go-check-sumtype v0.1.4 h1:WCvlB3l5Vq5dZQTFmodqL2g68uHiSwwlWcT5a2FGK0c= @@ -273,6 +275,8 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/containerd/stargz-snapshotter/estargz v0.15.1 h1:eXJjw9RbkLFgioVaTG+G/ZW/0kEe2oEKCdS/ZxIyoCU= github.com/containerd/stargz-snapshotter/estargz v0.15.1/go.mod h1:gr2RNwukQ/S9Nv33Lt6UC7xEx58C+LHRdoqbEKjz1Kk= +github.com/containerd/typeurl/v2 v2.1.1 h1:3Q4Pt7i8nYwy2KmQWIw2+1hTvwTE/6w9FqcttATPO/4= +github.com/containerd/typeurl/v2 v2.1.1/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -309,8 +313,8 @@ github.com/docker/docker v26.0.2+incompatible h1:yGVmKUFGgcxA6PXWAokO0sQL22BrQ67 github.com/docker/docker v26.0.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -786,6 +790,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mitchellh/mapstructure v1.4.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/moby/buildkit v0.13.1 h1:L8afOFhPq2RPJJSr/VyzbufwID7jquZVB7oFHbPRcPE= +github.com/moby/buildkit v0.13.1/go.mod h1:aNmNQKLBFYAOFuzQjR3VA27/FijlvtBD1pjNwTSN37k= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= @@ -1093,8 +1099,8 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0 h1:cEPbyTS go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.50.0/go.mod h1:DKdbWcT4GH1D0Y3Sqt/PFXt2naRKDWtU+eE6oLdFNA8= go.opentelemetry.io/otel v1.25.0 h1:gldB5FfhRl7OJQbUHt/8s0a7cE8fbsPAtdpRaApKy4k= go.opentelemetry.io/otel v1.25.0/go.mod h1:Wa2ds5NOXEMkCmUou1WA7ZBfLTHWIsp034OVD7AO+Vg= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 h1:cl5P5/GIfFh4t6xyruOgJP5QiA1pw4fYYdv6nc6CBWw= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0/go.mod h1:zgBdWWAu7oEEMC06MMKc5NLbA/1YDXV1sMpSqEeLQLg= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0 h1:Mbi5PKN7u322woPa85d7ebZ+SOvEoPvoiBu+ryHWgfA= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.25.0/go.mod h1:e7ciERRhZaOZXVjx5MiL8TK5+Xv7G5Gv5PA2ZDEJdL8= go.opentelemetry.io/otel/metric v1.25.0 h1:LUKbS7ArpFL/I2jJHdJcqMGxkRdxpPHE0VU/D4NuEwA= diff --git a/providers/k8s/go.mod b/providers/k8s/go.mod index 31fb6abbba..5417814903 100644 --- a/providers/k8s/go.mod +++ b/providers/k8s/go.mod @@ -69,6 +69,7 @@ require ( github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/StackExchange/wmi v1.2.1 // indirect + github.com/agext/levenshtein v1.2.3 // indirect github.com/alecthomas/go-check-sumtype v0.1.4 // indirect github.com/alecthomas/participle v0.3.0 // indirect github.com/alecthomas/participle/v2 v2.1.1 // indirect @@ -121,6 +122,7 @@ require ( github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/redact v1.1.5 // indirect github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect + github.com/containerd/typeurl/v2 v2.1.1 // indirect github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/daixiang0/gci v0.13.4 // indirect @@ -132,7 +134,7 @@ require ( github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker v26.0.2+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.1 // indirect - github.com/docker/go-connections v0.4.0 // indirect + github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/dvsekhvalnov/jose2go v1.7.0 // indirect @@ -267,6 +269,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/moby/buildkit v0.13.1 // indirect github.com/moby/docker-image-spec v1.3.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect diff --git a/providers/k8s/go.sum b/providers/k8s/go.sum index 7393d17ab6..ee686577b4 100644 --- a/providers/k8s/go.sum +++ b/providers/k8s/go.sum @@ -119,6 +119,8 @@ github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0k github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo= +github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= github.com/alecthomas/assert/v2 v2.3.0 h1:mAsH2wmvjsuvyBvAmCtm7zFsBlb8mIHx5ySLVdDZXL0= github.com/alecthomas/assert/v2 v2.3.0/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= github.com/alecthomas/go-check-sumtype v0.1.4 h1:WCvlB3l5Vq5dZQTFmodqL2g68uHiSwwlWcT5a2FGK0c= @@ -273,6 +275,8 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/containerd/stargz-snapshotter/estargz v0.15.1 h1:eXJjw9RbkLFgioVaTG+G/ZW/0kEe2oEKCdS/ZxIyoCU= github.com/containerd/stargz-snapshotter/estargz v0.15.1/go.mod h1:gr2RNwukQ/S9Nv33Lt6UC7xEx58C+LHRdoqbEKjz1Kk= +github.com/containerd/typeurl/v2 v2.1.1 h1:3Q4Pt7i8nYwy2KmQWIw2+1hTvwTE/6w9FqcttATPO/4= +github.com/containerd/typeurl/v2 v2.1.1/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU= github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -309,8 +313,8 @@ github.com/docker/docker v26.0.2+incompatible h1:yGVmKUFGgcxA6PXWAokO0sQL22BrQ67 github.com/docker/docker v26.0.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= -github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= +github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= +github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -806,6 +810,8 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mitchellh/mapstructure v1.4.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/moby/buildkit v0.13.1 h1:L8afOFhPq2RPJJSr/VyzbufwID7jquZVB7oFHbPRcPE= +github.com/moby/buildkit v0.13.1/go.mod h1:aNmNQKLBFYAOFuzQjR3VA27/FijlvtBD1pjNwTSN37k= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= diff --git a/providers/os/config/config.go b/providers/os/config/config.go index e8a41bbfe9..2a6f8c3ad7 100644 --- a/providers/os/config/config.go +++ b/providers/os/config/config.go @@ -20,8 +20,9 @@ var Config = plugin.Provider{ shared.Type_Tar.String(), shared.Type_DockerSnapshot.String(), shared.Type_Vagrant.String(), - shared.Type_DockerImage.String(), shared.Type_DockerContainer.String(), + shared.Type_DockerImage.String(), + shared.Type_DockerFile.String(), shared.Type_DockerRegistry.String(), shared.Type_ContainerRegistry.String(), shared.Type_RegistryImage.String(), diff --git a/providers/os/connection/docker/container_connection.go b/providers/os/connection/docker/container_connection.go index 8b146dfc2e..0e53754097 100644 --- a/providers/os/connection/docker/container_connection.go +++ b/providers/os/connection/docker/container_connection.go @@ -11,10 +11,9 @@ import ( "strconv" "strings" - "github.com/google/go-containerregistry/pkg/v1/mutate" - "github.com/docker/docker/client" "github.com/google/go-containerregistry/pkg/name" + "github.com/google/go-containerregistry/pkg/v1/mutate" "github.com/rs/zerolog/log" "github.com/spf13/afero" "go.mondoo.com/cnquery/v11/providers-sdk/v1/inventory" diff --git a/providers/os/connection/docker/docker.go b/providers/os/connection/docker/docker.go index ae160e8ca6..f31a5dbd86 100644 --- a/providers/os/connection/docker/docker.go +++ b/providers/os/connection/docker/docker.go @@ -8,6 +8,7 @@ package docker // - docker containers // - docker images // - docker snapshots +// - dockerfiles // // Each of these types of connections is implemented as a separate connection type, since the data format is different. // All of these connections are based on the tar connection, which is a generic connection type that can handle tar diff --git a/providers/os/connection/docker/dockerfile.go b/providers/os/connection/docker/dockerfile.go new file mode 100644 index 0000000000..470f8a5916 --- /dev/null +++ b/providers/os/connection/docker/dockerfile.go @@ -0,0 +1,95 @@ +// Copyright (c) Mondoo, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package docker + +import ( + "crypto/sha256" + "encoding/hex" + "errors" + "os" + "path/filepath" + + "go.mondoo.com/cnquery/v11/providers-sdk/v1/inventory" + "go.mondoo.com/cnquery/v11/providers/os/connection/fs" + "go.mondoo.com/cnquery/v11/providers/os/connection/shared" + "go.mondoo.com/cnquery/v11/utils/multierr" + "go.mondoo.com/cnquery/v11/utils/urlx" +) + +var _ shared.Connection = &DockerfileConnection{} + +type DockerfileConnection struct { + *fs.FileSystemConnection + Filename string +} + +func NewDockerfile(id uint32, conf *inventory.Config, asset *inventory.Asset) (*DockerfileConnection, error) { + if conf == nil { + return nil, errors.New("missing configuration to create dockerfile connection") + } + + src := conf.Path + if src == "" { + return nil, errors.New("please specify a target path for the dockerfile connection") + } + + absSrc, err := filepath.Abs(src) + if err != nil { + return nil, multierr.Wrap(err, "can't get absolute path for dockerfile") + } + + stat, err := os.Stat(absSrc) + if err != nil { + return nil, err + } + + // if we have a regular file, we need to point the fs.Connection to + // look at the folder instead and store the filename separately + var filename string + if !stat.IsDir() { + filename = filepath.Base(absSrc) + absSrc = filepath.Dir(absSrc) + conf.Path = absSrc + } + + fsconn, err := fs.NewConnection(id, conf, asset) + if err != nil { + return nil, err + } + + asset.Platform = &inventory.Platform{ + Name: "dockerfile", + Title: "Dockerfile", + Family: []string{"docker"}, + Kind: "code", + Runtime: "docker", + } + + url, ok := asset.Connections[0].Options["ssh-url"] + if ok { + domain, org, repo, err := urlx.ParseGitSshUrl(url) + if err != nil { + return nil, err + } + platformID := "//platformid.api.mondoo.app/runtime/dockerfile/domain/" + domain + "/org/" + org + "/repo/" + repo + asset.Connections[0].PlatformId = platformID + asset.PlatformIds = []string{platformID} + asset.Name = "Dockerfile analysis " + org + "/" + repo + + } else { + h := sha256.New() + h.Write([]byte(absSrc)) + hash := hex.EncodeToString(h.Sum(nil)) + platformID := "//platformid.api.mondoo.app/runtime/dockerfile/hash/" + hash + + asset.Connections[0].PlatformId = platformID + asset.PlatformIds = []string{platformID} + asset.Name = "Dockerfile analysis " + filename + } + + return &DockerfileConnection{ + FileSystemConnection: fsconn, + Filename: filename, + }, nil +} diff --git a/providers/os/connection/shared/shared.go b/providers/os/connection/shared/shared.go index 5ed840f06a..87048a657f 100644 --- a/providers/os/connection/shared/shared.go +++ b/providers/os/connection/shared/shared.go @@ -33,12 +33,13 @@ const ( Type_SSH ConnectionType = "ssh" Type_Tar ConnectionType = "tar" Type_FileSystem ConnectionType = "filesystem" - Type_DockerSnapshot ConnectionType = "docker-snapshot" Type_Winrm ConnectionType = "winrm" Type_Vagrant ConnectionType = "vagrant" - Type_DockerImage ConnectionType = "docker-image" Type_DockerContainer ConnectionType = "docker-container" + Type_DockerImage ConnectionType = "docker-image" + Type_DockerFile ConnectionType = "docker-file" Type_DockerRegistry ConnectionType = "docker-registry" + Type_DockerSnapshot ConnectionType = "docker-snapshot" Type_ContainerRegistry ConnectionType = "container-registry" Type_RegistryImage ConnectionType = "registry-image" ) @@ -73,6 +74,7 @@ type Command struct { type Capabilities byte const ( + Capability_None Capabilities = 0 Capability_RunCommand Capabilities = 1 << iota Capability_File Capability_FindFile diff --git a/providers/os/provider/provider.go b/providers/os/provider/provider.go index eb9420e6c1..98e841e2e2 100644 --- a/providers/os/provider/provider.go +++ b/providers/os/provider/provider.go @@ -94,6 +94,9 @@ func (s *Service) ParseCLI(req *plugin.ParseCLIReq) (*plugin.ParseCLIRes, error) case "container": conf.Type = shared.Type_DockerContainer.String() conf.Host = req.Args[1] + case "file": + conf.Type = shared.Type_DockerFile.String() + conf.Path = req.Args[1] } } else { connType, err := docker.FindDockerObjectConnectionType(req.Args[0]) @@ -375,11 +378,14 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba return nil, err } + case shared.Type_DockerContainer.String(): + conn, err = docker.NewDockerEngineContainer(connId, conf, asset) + case shared.Type_DockerImage.String(): conn, err = docker.NewContainerImageConnection(connId, conf, asset) - case shared.Type_DockerContainer.String(): - conn, err = docker.NewDockerEngineContainer(connId, conf, asset) + case shared.Type_DockerFile.String(): + conn, err = docker.NewDockerfile(connId, conf, asset) case shared.Type_DockerRegistry.String(), shared.Type_ContainerRegistry.String(): conn, err = container.NewRegistryConnection(connId, asset) diff --git a/providers/os/resources/dockerfile.go b/providers/os/resources/dockerfile.go new file mode 100644 index 0000000000..a1297e843f --- /dev/null +++ b/providers/os/resources/dockerfile.go @@ -0,0 +1,306 @@ +// Copyright (c) Mondoo, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package resources + +import ( + "errors" + "slices" + "strconv" + "strings" + "sync" + + "github.com/moby/buildkit/frontend/dockerfile/instructions" + "github.com/moby/buildkit/frontend/dockerfile/parser" + "github.com/rs/zerolog/log" + "go.mondoo.com/cnquery/v11/llx" + "go.mondoo.com/cnquery/v11/providers-sdk/v1/plugin" + "go.mondoo.com/cnquery/v11/providers/os/connection/docker" + "go.mondoo.com/cnquery/v11/types" + "go.mondoo.com/cnquery/v11/utils/multierr" +) + +func initDockerFile(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) { + // if users supply a file, we don't have to run any fancy initialization, + // since most of this function deals with trying to find the dockerfile + if _, ok := args["file"]; ok { + return args, nil, nil + } + + var path string + + // init from path + if rawPath, ok := args["path"]; ok { + delete(args, "path") + path, ok = rawPath.Value.(string) + if !ok { + return nil, nil, errors.New("path must be supplied as a string") + } + } else if dfc, ok := runtime.Connection.(*docker.DockerfileConnection); ok { + path = dfc.Filename + } + + // we assume the default name for the dockerfile if it was not provided + if path == "" { + path = "Dockerfile" + } + + raw, err := CreateResource(runtime, "file", map[string]*llx.RawData{ + "path": llx.StringData(path), + }) + if err != nil { + return nil, nil, err + } + mqlFile, _ := raw.(*mqlFile) + args["file"] = llx.ResourceData(mqlFile, "file") + return args, nil, nil +} + +type mqlDockerFileInternal struct { + lock sync.Mutex +} + +func (p *mqlDockerFile) id() (string, error) { + if p.File.Data == nil { + return "", errors.New("no file provided, can't determine ID for dockerfile") + } + return p.File.Data.id() +} + +func (p *mqlDockerFile) file() (*mqlFile, error) { + return nil, errors.New("missing underlying file, please specify a path of file") +} + +func (p *mqlDockerFile) parse(file *mqlFile) error { + p.lock.Lock() + defer p.lock.Unlock() + + setError := func(err error) error { + p.Instructions.Error = err + p.Stages.Error = err + return err + } + + content := file.GetContent() + if content.Error != nil { + return setError(content.Error) + } + + reader := strings.NewReader(content.Data) + ast, err := parser.Parse(reader) + if err != nil { + return setError(multierr.Wrap(err, "failed to parse dockerfile "+file.Path.Data)) + } + + if ast.AST != nil { + instructions := make([]any, len(ast.AST.Children)) + for i := range ast.AST.Children { + node := ast.AST.Children[i] + instructions[i] = map[string]any{ + "original": node.Original, + } + } + p.Instructions = plugin.TValue[any]{ + Data: instructions, + State: plugin.StateIsSet, + } + } else { + p.Instructions = plugin.TValue[any]{ + Data: []any{}, + State: plugin.StateIsSet, + } + } + + parsedStages, meta, err := instructions.Parse(ast.AST) + if err != nil { + return setError(multierr.Wrap(err, "failed to parse dockerfile instructions in "+file.Path.Data)) + } + + stages := make([]any, len(parsedStages)) + var stagesErr error + for i := range parsedStages { + stages[i], err = p.stage2resource(parsedStages[i]) + if err != nil { + stagesErr = multierr.Wrap(err, "failed to parse stage in dockerfile "+file.Path.Data) + break + } + } + p.Stages = plugin.TValue[[]any]{ + Data: stages, + Error: stagesErr, + State: plugin.StateIsSet, + } + + // FIXME: add meta data + _ = meta + + return nil +} + +func (p *mqlDockerFile) stage2resource(stage instructions.Stage) (*mqlDockerFileStage, error) { + var image string + var tag string + var digest string + if idx := strings.Index(stage.BaseName, ":"); idx != -1 { + image = stage.BaseName[:idx] + if len(stage.BaseName) > idx+1 { + tag = stage.BaseName[idx+1:] + } + } else if idx := strings.Index(stage.BaseName, "@"); idx != -1 { + image = stage.BaseName[:idx] + if len(stage.BaseName) > idx+1 { + tag = stage.BaseName[idx+1:] + } + } else { + image = stage.BaseName + } + + stageID := p.locationID(stage.Location) + + rawFrom, err := CreateResource(p.MqlRuntime, "docker.file.from", map[string]*llx.RawData{ + "__id": llx.StringData(stageID), + "platform": llx.StringData(stage.Platform), + "image": llx.StringData(image), + "tag": llx.StringData(tag), + "digest": llx.StringData(digest), + "name": llx.StringData(stage.Name), + }) + if err != nil { + return nil, err + } + + env := map[string]any{} + var runs []any + var copy []any + var add []any + var unsupported []string + var entrypointRaw *instructions.EntrypointCommand + var cmdRaw *instructions.CmdCommand + for i := range stage.Commands { + switch v := stage.Commands[i].(type) { + case *instructions.EnvCommand: + for _, kv := range v.Env { + env[kv.Key] = strings.Trim(kv.Value, "\"") + } + + case *instructions.RunCommand: + script := strings.Join(v.ShellDependantCmdLine.CmdLine, "\n") + runResource, err := CreateResource(p.MqlRuntime, "docker.file.run", map[string]*llx.RawData{ + "__id": llx.StringData(p.locationID(v.Location())), + "script": llx.StringData(script), + }) + if err != nil { + return nil, err + } + runs = append(runs, runResource) + + case *instructions.EntrypointCommand: + entrypointRaw = v + + case *instructions.CmdCommand: + cmdRaw = v + + case *instructions.CopyCommand: + src := make([]any, len(v.SourcesAndDest.SourcePaths)) + for i := range v.SourcesAndDest.SourcePaths { + src[i] = v.SourcesAndDest.SourcePaths[i] + } + resource, err := CreateResource(p.MqlRuntime, "docker.file.copy", map[string]*llx.RawData{ + "src": llx.ArrayData(src, types.String), + "dst": llx.StringData(v.SourcesAndDest.DestPath), + }) + if err != nil { + return nil, err + } + copy = append(copy, resource) + + case *instructions.AddCommand: + src := make([]any, len(v.SourcesAndDest.SourcePaths)) + for i := range v.SourcesAndDest.SourcePaths { + src[i] = v.SourcesAndDest.SourcePaths[i] + } + resource, err := CreateResource(p.MqlRuntime, "docker.file.add", map[string]*llx.RawData{ + "src": llx.ArrayData(src, types.String), + "dst": llx.StringData(v.SourcesAndDest.DestPath), + "chown": llx.StringData(v.Chown), + "chmod": llx.StringData(v.Chmod), + }) + if err != nil { + return nil, err + } + add = append(add, resource) + + default: + cmd := stage.Commands[i] + unsupported = append(unsupported, cmd.Name()) + } + } + + if len(unsupported) != 0 { + slices.Sort(unsupported) + log.Warn().Strs("commands", slices.Compact(unsupported)).Msg("unsuppoprted dockerfile commands") + } + + args := map[string]*llx.RawData{ + "__id": llx.StringData(stageID), + "from": llx.ResourceData(rawFrom, "docker.file.from"), + "file": llx.ResourceData(p, "docker.file"), + "env": llx.MapData(env, types.String), + "run": llx.ArrayData(runs, types.Resource("docker.file.run")), + "add": llx.ArrayData(add, types.Resource("docker.file.add")), + "copy": llx.ArrayData(copy, types.Resource("docker.file.copy")), + } + + if entrypointRaw != nil { + script := strings.Join(entrypointRaw.ShellDependantCmdLine.CmdLine, "\n") + runResource, err := CreateResource(p.MqlRuntime, "docker.file.run", map[string]*llx.RawData{ + "__id": llx.StringData(p.locationID(entrypointRaw.Location())), + "script": llx.StringData(script), + }) + if err != nil { + return nil, err + } + args["entrypoint"] = llx.ResourceData(runResource, "docker.file.run") + } else { + args["entrypoint"] = llx.NilData + } + + if cmdRaw != nil { + script := strings.Join(cmdRaw.ShellDependantCmdLine.CmdLine, "\n") + cmdResource, err := CreateResource(p.MqlRuntime, "docker.file.run", map[string]*llx.RawData{ + "__id": llx.StringData(p.locationID(cmdRaw.Location())), + "script": llx.StringData(script), + }) + if err != nil { + return nil, err + } + args["cmd"] = llx.ResourceData(cmdResource, "docker.file.run") + } else { + args["cmd"] = llx.NilData + } + + rawStage, err := CreateResource(p.MqlRuntime, "docker.file.stage", args) + if err != nil { + return nil, err + } + + return rawStage.(*mqlDockerFileStage), nil +} + +func (p *mqlDockerFile) locationID(location []parser.Range) string { + var line int + var char int + if len(location) != 0 { + line = location[0].Start.Line + char = location[0].Start.Character + } + return "dockerfile/" + p.File.Data.Path.Data + "/" + strconv.FormatInt(int64(line), 10) + ":" + strconv.FormatInt(int64(char), 10) +} + +func (p *mqlDockerFile) instructions(file *mqlFile) (any, error) { + return nil, p.parse(file) +} + +func (p *mqlDockerFile) stages(file *mqlFile) ([]any, error) { + return nil, p.parse(file) +} diff --git a/providers/os/resources/os.lr b/providers/os/resources/os.lr index 2677f8c319..a9ab46dc02 100644 --- a/providers/os/resources/os.lr +++ b/providers/os/resources/os.lr @@ -757,6 +757,57 @@ docker { containers() []docker.container } +docker.file @defaults("file.path instructions.length stages.length") { + init(path string) + // File information about this Dockerfile + embed file + // List of instructions in the order they appear + instructions(file) dict + // All stages included in this Dockerfile + stages(file) []docker.file.stage +} + +docker.file.stage @defaults("from.name") { + // The source of this stage, specified via `FROM` in Dockerfiles + from docker.file.from + // Contains the reference to the Dockerfile this stage belongs to + file docker.file + // Environment variables configured in the Dockerfile + env map[string]string + // Run instructions in this Dockerfile + run []docker.file.run + cmd docker.file.run + entrypoint docker.file.run + add []docker.file.add + copy []docker.file.copy +} + +docker.file.from @defaults("name image tag") { + platform string + image string + tag string + digest string + name string +} + +docker.file.run @defaults("script") { + script string +} + +docker.file.add @defaults("src dst") { + src []string + dst string + chown string + chmod string +} + +docker.file.copy @defaults("src dst") { + src []string + dst string + chown string + chmod string +} + // Docker image docker.image { // Image ID diff --git a/providers/os/resources/os.lr.go b/providers/os/resources/os.lr.go index ecb3ef3ab4..d03a6ca73b 100644 --- a/providers/os/resources/os.lr.go +++ b/providers/os/resources/os.lr.go @@ -246,6 +246,30 @@ func init() { // to override args, implement: initDocker(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) Create: createDocker, }, + "docker.file": { + Init: initDockerFile, + Create: createDockerFile, + }, + "docker.file.stage": { + // to override args, implement: initDockerFileStage(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createDockerFileStage, + }, + "docker.file.from": { + // to override args, implement: initDockerFileFrom(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createDockerFileFrom, + }, + "docker.file.run": { + // to override args, implement: initDockerFileRun(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createDockerFileRun, + }, + "docker.file.add": { + // to override args, implement: initDockerFileAdd(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createDockerFileAdd, + }, + "docker.file.copy": { + // to override args, implement: initDockerFileCopy(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) + Create: createDockerFileCopy, + }, "docker.image": { // to override args, implement: initDockerImage(runtime *plugin.Runtime, args map[string]*llx.RawData) (map[string]*llx.RawData, plugin.Resource, error) Create: createDockerImage, @@ -1267,6 +1291,81 @@ var getDataFields = map[string]func(r plugin.Resource) *plugin.DataRes{ "docker.containers": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlDocker).GetContainers()).ToDataRes(types.Array(types.Resource("docker.container"))) }, + "docker.file.file": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFile).GetFile()).ToDataRes(types.Resource("file")) + }, + "docker.file.instructions": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFile).GetInstructions()).ToDataRes(types.Dict) + }, + "docker.file.stages": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFile).GetStages()).ToDataRes(types.Array(types.Resource("docker.file.stage"))) + }, + "docker.file.stage.from": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileStage).GetFrom()).ToDataRes(types.Resource("docker.file.from")) + }, + "docker.file.stage.file": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileStage).GetFile()).ToDataRes(types.Resource("docker.file")) + }, + "docker.file.stage.env": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileStage).GetEnv()).ToDataRes(types.Map(types.String, types.String)) + }, + "docker.file.stage.run": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileStage).GetRun()).ToDataRes(types.Array(types.Resource("docker.file.run"))) + }, + "docker.file.stage.cmd": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileStage).GetCmd()).ToDataRes(types.Resource("docker.file.run")) + }, + "docker.file.stage.entrypoint": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileStage).GetEntrypoint()).ToDataRes(types.Resource("docker.file.run")) + }, + "docker.file.stage.add": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileStage).GetAdd()).ToDataRes(types.Array(types.Resource("docker.file.add"))) + }, + "docker.file.stage.copy": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileStage).GetCopy()).ToDataRes(types.Array(types.Resource("docker.file.copy"))) + }, + "docker.file.from.platform": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileFrom).GetPlatform()).ToDataRes(types.String) + }, + "docker.file.from.image": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileFrom).GetImage()).ToDataRes(types.String) + }, + "docker.file.from.tag": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileFrom).GetTag()).ToDataRes(types.String) + }, + "docker.file.from.digest": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileFrom).GetDigest()).ToDataRes(types.String) + }, + "docker.file.from.name": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileFrom).GetName()).ToDataRes(types.String) + }, + "docker.file.run.script": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileRun).GetScript()).ToDataRes(types.String) + }, + "docker.file.add.src": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileAdd).GetSrc()).ToDataRes(types.Array(types.String)) + }, + "docker.file.add.dst": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileAdd).GetDst()).ToDataRes(types.String) + }, + "docker.file.add.chown": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileAdd).GetChown()).ToDataRes(types.String) + }, + "docker.file.add.chmod": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileAdd).GetChmod()).ToDataRes(types.String) + }, + "docker.file.copy.src": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileCopy).GetSrc()).ToDataRes(types.Array(types.String)) + }, + "docker.file.copy.dst": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileCopy).GetDst()).ToDataRes(types.String) + }, + "docker.file.copy.chown": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileCopy).GetChown()).ToDataRes(types.String) + }, + "docker.file.copy.chmod": func(r plugin.Resource) *plugin.DataRes { + return (r.(*mqlDockerFileCopy).GetChmod()).ToDataRes(types.String) + }, "docker.image.id": func(r plugin.Resource) *plugin.DataRes { return (r.(*mqlDockerImage).GetId()).ToDataRes(types.String) }, @@ -3322,6 +3421,130 @@ var setDataFields = map[string]func(r plugin.Resource, v *llx.RawData) bool { r.(*mqlDocker).Containers, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) return }, + "docker.file.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFile).__id, ok = v.Value.(string) + return + }, + "docker.file.file": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFile).File, ok = plugin.RawToTValue[*mqlFile](v.Value, v.Error) + return + }, + "docker.file.instructions": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFile).Instructions, ok = plugin.RawToTValue[interface{}](v.Value, v.Error) + return + }, + "docker.file.stages": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFile).Stages, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) + return + }, + "docker.file.stage.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileStage).__id, ok = v.Value.(string) + return + }, + "docker.file.stage.from": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileStage).From, ok = plugin.RawToTValue[*mqlDockerFileFrom](v.Value, v.Error) + return + }, + "docker.file.stage.file": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileStage).File, ok = plugin.RawToTValue[*mqlDockerFile](v.Value, v.Error) + return + }, + "docker.file.stage.env": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileStage).Env, ok = plugin.RawToTValue[map[string]interface{}](v.Value, v.Error) + return + }, + "docker.file.stage.run": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileStage).Run, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) + return + }, + "docker.file.stage.cmd": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileStage).Cmd, ok = plugin.RawToTValue[*mqlDockerFileRun](v.Value, v.Error) + return + }, + "docker.file.stage.entrypoint": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileStage).Entrypoint, ok = plugin.RawToTValue[*mqlDockerFileRun](v.Value, v.Error) + return + }, + "docker.file.stage.add": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileStage).Add, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) + return + }, + "docker.file.stage.copy": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileStage).Copy, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) + return + }, + "docker.file.from.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileFrom).__id, ok = v.Value.(string) + return + }, + "docker.file.from.platform": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileFrom).Platform, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "docker.file.from.image": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileFrom).Image, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "docker.file.from.tag": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileFrom).Tag, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "docker.file.from.digest": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileFrom).Digest, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "docker.file.from.name": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileFrom).Name, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "docker.file.run.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileRun).__id, ok = v.Value.(string) + return + }, + "docker.file.run.script": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileRun).Script, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "docker.file.add.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileAdd).__id, ok = v.Value.(string) + return + }, + "docker.file.add.src": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileAdd).Src, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) + return + }, + "docker.file.add.dst": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileAdd).Dst, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "docker.file.add.chown": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileAdd).Chown, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "docker.file.add.chmod": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileAdd).Chmod, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "docker.file.copy.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileCopy).__id, ok = v.Value.(string) + return + }, + "docker.file.copy.src": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileCopy).Src, ok = plugin.RawToTValue[[]interface{}](v.Value, v.Error) + return + }, + "docker.file.copy.dst": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileCopy).Dst, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "docker.file.copy.chown": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileCopy).Chown, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, + "docker.file.copy.chmod": func(r plugin.Resource, v *llx.RawData) (ok bool) { + r.(*mqlDockerFileCopy).Chmod, ok = plugin.RawToTValue[string](v.Value, v.Error) + return + }, "docker.image.__id": func(r plugin.Resource, v *llx.RawData) (ok bool) { r.(*mqlDockerImage).__id, ok = v.Value.(string) return @@ -9145,6 +9368,406 @@ func (c *mqlDocker) GetContainers() *plugin.TValue[[]interface{}] { }) } +// mqlDockerFile for the docker.file resource +type mqlDockerFile struct { + MqlRuntime *plugin.Runtime + __id string + mqlDockerFileInternal + File plugin.TValue[*mqlFile] + Instructions plugin.TValue[interface{}] + Stages plugin.TValue[[]interface{}] +} + +// createDockerFile creates a new instance of this resource +func createDockerFile(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlDockerFile{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + if res.__id == "" { + res.__id, err = res.id() + if err != nil { + return nil, err + } + } + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("docker.file", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlDockerFile) MqlName() string { + return "docker.file" +} + +func (c *mqlDockerFile) MqlID() string { + return c.__id +} + +func (c *mqlDockerFile) GetFile() *plugin.TValue[*mqlFile] { + return plugin.GetOrCompute[*mqlFile](&c.File, func() (*mqlFile, error) { + if c.MqlRuntime.HasRecording { + d, err := c.MqlRuntime.FieldResourceFromRecording("docker.file", c.__id, "file") + if err != nil { + return nil, err + } + if d != nil { + return d.Value.(*mqlFile), nil + } + } + + return c.file() + }) +} + +func (c *mqlDockerFile) GetInstructions() *plugin.TValue[interface{}] { + return plugin.GetOrCompute[interface{}](&c.Instructions, func() (interface{}, error) { + vargFile := c.GetFile() + if vargFile.Error != nil { + return nil, vargFile.Error + } + + return c.instructions(vargFile.Data) + }) +} + +func (c *mqlDockerFile) GetStages() *plugin.TValue[[]interface{}] { + return plugin.GetOrCompute[[]interface{}](&c.Stages, func() ([]interface{}, error) { + if c.MqlRuntime.HasRecording { + d, err := c.MqlRuntime.FieldResourceFromRecording("docker.file", c.__id, "stages") + if err != nil { + return nil, err + } + if d != nil { + return d.Value.([]interface{}), nil + } + } + + vargFile := c.GetFile() + if vargFile.Error != nil { + return nil, vargFile.Error + } + + return c.stages(vargFile.Data) + }) +} + +// mqlDockerFileStage for the docker.file.stage resource +type mqlDockerFileStage struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlDockerFileStageInternal it will be used here + From plugin.TValue[*mqlDockerFileFrom] + File plugin.TValue[*mqlDockerFile] + Env plugin.TValue[map[string]interface{}] + Run plugin.TValue[[]interface{}] + Cmd plugin.TValue[*mqlDockerFileRun] + Entrypoint plugin.TValue[*mqlDockerFileRun] + Add plugin.TValue[[]interface{}] + Copy plugin.TValue[[]interface{}] +} + +// createDockerFileStage creates a new instance of this resource +func createDockerFileStage(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlDockerFileStage{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("docker.file.stage", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlDockerFileStage) MqlName() string { + return "docker.file.stage" +} + +func (c *mqlDockerFileStage) MqlID() string { + return c.__id +} + +func (c *mqlDockerFileStage) GetFrom() *plugin.TValue[*mqlDockerFileFrom] { + return &c.From +} + +func (c *mqlDockerFileStage) GetFile() *plugin.TValue[*mqlDockerFile] { + return &c.File +} + +func (c *mqlDockerFileStage) GetEnv() *plugin.TValue[map[string]interface{}] { + return &c.Env +} + +func (c *mqlDockerFileStage) GetRun() *plugin.TValue[[]interface{}] { + return &c.Run +} + +func (c *mqlDockerFileStage) GetCmd() *plugin.TValue[*mqlDockerFileRun] { + return &c.Cmd +} + +func (c *mqlDockerFileStage) GetEntrypoint() *plugin.TValue[*mqlDockerFileRun] { + return &c.Entrypoint +} + +func (c *mqlDockerFileStage) GetAdd() *plugin.TValue[[]interface{}] { + return &c.Add +} + +func (c *mqlDockerFileStage) GetCopy() *plugin.TValue[[]interface{}] { + return &c.Copy +} + +// mqlDockerFileFrom for the docker.file.from resource +type mqlDockerFileFrom struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlDockerFileFromInternal it will be used here + Platform plugin.TValue[string] + Image plugin.TValue[string] + Tag plugin.TValue[string] + Digest plugin.TValue[string] + Name plugin.TValue[string] +} + +// createDockerFileFrom creates a new instance of this resource +func createDockerFileFrom(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlDockerFileFrom{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("docker.file.from", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlDockerFileFrom) MqlName() string { + return "docker.file.from" +} + +func (c *mqlDockerFileFrom) MqlID() string { + return c.__id +} + +func (c *mqlDockerFileFrom) GetPlatform() *plugin.TValue[string] { + return &c.Platform +} + +func (c *mqlDockerFileFrom) GetImage() *plugin.TValue[string] { + return &c.Image +} + +func (c *mqlDockerFileFrom) GetTag() *plugin.TValue[string] { + return &c.Tag +} + +func (c *mqlDockerFileFrom) GetDigest() *plugin.TValue[string] { + return &c.Digest +} + +func (c *mqlDockerFileFrom) GetName() *plugin.TValue[string] { + return &c.Name +} + +// mqlDockerFileRun for the docker.file.run resource +type mqlDockerFileRun struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlDockerFileRunInternal it will be used here + Script plugin.TValue[string] +} + +// createDockerFileRun creates a new instance of this resource +func createDockerFileRun(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlDockerFileRun{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("docker.file.run", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlDockerFileRun) MqlName() string { + return "docker.file.run" +} + +func (c *mqlDockerFileRun) MqlID() string { + return c.__id +} + +func (c *mqlDockerFileRun) GetScript() *plugin.TValue[string] { + return &c.Script +} + +// mqlDockerFileAdd for the docker.file.add resource +type mqlDockerFileAdd struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlDockerFileAddInternal it will be used here + Src plugin.TValue[[]interface{}] + Dst plugin.TValue[string] + Chown plugin.TValue[string] + Chmod plugin.TValue[string] +} + +// createDockerFileAdd creates a new instance of this resource +func createDockerFileAdd(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlDockerFileAdd{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("docker.file.add", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlDockerFileAdd) MqlName() string { + return "docker.file.add" +} + +func (c *mqlDockerFileAdd) MqlID() string { + return c.__id +} + +func (c *mqlDockerFileAdd) GetSrc() *plugin.TValue[[]interface{}] { + return &c.Src +} + +func (c *mqlDockerFileAdd) GetDst() *plugin.TValue[string] { + return &c.Dst +} + +func (c *mqlDockerFileAdd) GetChown() *plugin.TValue[string] { + return &c.Chown +} + +func (c *mqlDockerFileAdd) GetChmod() *plugin.TValue[string] { + return &c.Chmod +} + +// mqlDockerFileCopy for the docker.file.copy resource +type mqlDockerFileCopy struct { + MqlRuntime *plugin.Runtime + __id string + // optional: if you define mqlDockerFileCopyInternal it will be used here + Src plugin.TValue[[]interface{}] + Dst plugin.TValue[string] + Chown plugin.TValue[string] + Chmod plugin.TValue[string] +} + +// createDockerFileCopy creates a new instance of this resource +func createDockerFileCopy(runtime *plugin.Runtime, args map[string]*llx.RawData) (plugin.Resource, error) { + res := &mqlDockerFileCopy{ + MqlRuntime: runtime, + } + + err := SetAllData(res, args) + if err != nil { + return res, err + } + + // to override __id implement: id() (string, error) + + if runtime.HasRecording { + args, err = runtime.ResourceFromRecording("docker.file.copy", res.__id) + if err != nil || args == nil { + return res, err + } + return res, SetAllData(res, args) + } + + return res, nil +} + +func (c *mqlDockerFileCopy) MqlName() string { + return "docker.file.copy" +} + +func (c *mqlDockerFileCopy) MqlID() string { + return c.__id +} + +func (c *mqlDockerFileCopy) GetSrc() *plugin.TValue[[]interface{}] { + return &c.Src +} + +func (c *mqlDockerFileCopy) GetDst() *plugin.TValue[string] { + return &c.Dst +} + +func (c *mqlDockerFileCopy) GetChown() *plugin.TValue[string] { + return &c.Chown +} + +func (c *mqlDockerFileCopy) GetChmod() *plugin.TValue[string] { + return &c.Chmod +} + // mqlDockerImage for the docker.image resource type mqlDockerImage struct { MqlRuntime *plugin.Runtime diff --git a/providers/os/resources/os.lr.manifest.yaml b/providers/os/resources/os.lr.manifest.yaml index 757dd6c27e..6649497a23 100644 --- a/providers/os/resources/os.lr.manifest.yaml +++ b/providers/os/resources/os.lr.manifest.yaml @@ -122,6 +122,50 @@ resources: state: {} status: {} min_mondoo_version: 5.15.0 + docker.file: + fields: + file: {} + instructions: {} + os: {} + stages: {} + min_mondoo_version: latest + docker.file.add: + fields: + chmod: {} + chown: {} + dst: {} + src: {} + min_mondoo_version: latest + docker.file.copy: + fields: + chmod: {} + chown: {} + dst: {} + src: {} + min_mondoo_version: latest + docker.file.from: + fields: + digest: {} + image: {} + name: {} + platform: {} + tag: {} + min_mondoo_version: latest + docker.file.run: + fields: + script: {} + min_mondoo_version: latest + docker.file.stage: + fields: + add: {} + cmd: {} + copy: {} + entrypoint: {} + env: {} + file: {} + from: {} + run: {} + min_mondoo_version: latest docker.image: fields: id: {} diff --git a/providers/terraform/provider/detector.go b/providers/terraform/provider/detector.go index d6640d82c1..d4882e4c3d 100644 --- a/providers/terraform/provider/detector.go +++ b/providers/terraform/provider/detector.go @@ -7,7 +7,6 @@ import ( "crypto/sha256" "encoding/hex" "errors" - "fmt" "os" "path" "path/filepath" @@ -15,6 +14,7 @@ import ( "go.mondoo.com/cnquery/v11/providers-sdk/v1/inventory" "go.mondoo.com/cnquery/v11/providers/terraform/connection" + "go.mondoo.com/cnquery/v11/utils/urlx" ) func (s *Service) detect(asset *inventory.Asset, conn *connection.Connection) error { @@ -53,7 +53,7 @@ func (s *Service) detect(asset *inventory.Asset, conn *connection.Connection) er // we always prefer the git url since it is more reliable url, ok := asset.Connections[0].Options["ssh-url"] if ok { - domain, org, repo, err := parseSSHURL(url) + domain, org, repo, err := urlx.ParseGitSshUrl(url) if err != nil { return err } @@ -111,26 +111,3 @@ func parseNameFromPath(file string) string { return name } - -func parseSSHURL(url string) (string, string, string, error) { - parts := strings.Split(url, "@") - if len(parts) != 2 { - return "", "", "", fmt.Errorf("malformed URL") - } - - // Get the provider - providerParts := strings.Split(parts[1], ":") - if len(providerParts) != 2 { - return "", "", "", fmt.Errorf("malformed URL") - } - provider := providerParts[0] - - // Now split the second part at the slash to separate the org and repo - orgRepoParts := strings.Split(providerParts[1], "/") - - // The repo name is the last part after the split. It includes .git, - // so we remove that - repo := strings.TrimSuffix(orgRepoParts[len(orgRepoParts)-1], ".git") - - return provider, orgRepoParts[0], repo, nil -} diff --git a/providers/terraform/provider/detector_test.go b/providers/terraform/provider/detector_test.go index ddaa9c4282..71be453bb4 100644 --- a/providers/terraform/provider/detector_test.go +++ b/providers/terraform/provider/detector_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.mondoo.com/cnquery/v11/utils/urlx" ) func TestDetectNameFromFile_Directory(t *testing.T) { @@ -22,7 +23,7 @@ func TestDetectNameFromFile_File(t *testing.T) { func TestDetectNameFromSsh(t *testing.T) { url := "git@gitlab.com:exampleorg/example-gitlab.git" - domain, org, repo, err := parseSSHURL(url) + domain, org, repo, err := urlx.ParseGitSshUrl(url) require.NoError(t, err) assert.Equal(t, "gitlab.com", domain) assert.Equal(t, "exampleorg", org) @@ -31,7 +32,7 @@ func TestDetectNameFromSsh(t *testing.T) { func TestDetectNameFromSsh_GitlabSubgroups(t *testing.T) { url := "git@gitlab.example.com:exampleorg/group/example-gitlab.git" - domain, org, repo, err := parseSSHURL(url) + domain, org, repo, err := urlx.ParseGitSshUrl(url) require.NoError(t, err) assert.Equal(t, "gitlab.example.com", domain) assert.Equal(t, "exampleorg", org) diff --git a/utils/urlx/urlx.go b/utils/urlx/urlx.go new file mode 100644 index 0000000000..158badf4b5 --- /dev/null +++ b/utils/urlx/urlx.go @@ -0,0 +1,33 @@ +// Copyright (c) Mondoo, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package urlx + +import ( + "fmt" + "strings" +) + +// ParseGitSshUrl retrieves the provider, org, and repo of a git/ssh-url +func ParseGitSshUrl(url string) (string, string, string, error) { + parts := strings.Split(url, "@") + if len(parts) != 2 { + return "", "", "", fmt.Errorf("malformed URL") + } + + // Get the provider + providerParts := strings.Split(parts[1], ":") + if len(providerParts) != 2 { + return "", "", "", fmt.Errorf("malformed URL") + } + provider := providerParts[0] + + // Now split the second part at the slash to separate the org and repo + orgRepoParts := strings.Split(providerParts[1], "/") + + // The repo name is the last part after the split. It includes .git, + // so we remove that + repo := strings.TrimSuffix(orgRepoParts[len(orgRepoParts)-1], ".git") + + return provider, orgRepoParts[0], repo, nil +} diff --git a/utils/urlx/urlx_test.go b/utils/urlx/urlx_test.go new file mode 100644 index 0000000000..2af579ca2a --- /dev/null +++ b/utils/urlx/urlx_test.go @@ -0,0 +1,34 @@ +// Copyright (c) Mondoo, Inc. +// SPDX-License-Identifier: BUSL-1.1 + +package urlx + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestParseGitSshUrl(t *testing.T) { + tests := []struct { + url string + provider string + org string + repo string + }{ + {"git@github.com:mondoohq/lunalectric.git", "github.com", "mondoohq", "lunalectric"}, + {"git@github.com:mondoohq/lunalectric", "github.com", "mondoohq", "lunalectric"}, + } + + for i := range tests { + cur := tests[i] + t.Run(cur.url, func(t *testing.T) { + a, b, c, err := ParseGitSshUrl(cur.url) + require.NoError(t, err) + assert.Equal(t, cur.provider, a) + assert.Equal(t, cur.org, b) + assert.Equal(t, cur.repo, c) + }) + } +}