diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index afa64862..87b68b18 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -25,6 +25,8 @@ jobs: name: Build and publish artifacts needs: create-release runs-on: ${{ matrix.os }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] @@ -76,14 +78,14 @@ jobs: asset_name: kubescape-${{ matrix.os }}-sha256 asset_content_type: application/octet-stream - publish-image: - if: ${{ github.repository == 'kubescape/kubescape' }} # TODO - uses: ./.github/workflows/build-image.yaml - needs: create-release - with: - client: "image-release" - image_name: "quay.io/${{ github.repository_owner }}/kubescape" - image_tag: "v2.0.${{ github.run_number }}" - support_platforms: true - cosign: true - secrets: inherit + # publish-image: + # if: ${{ github.repository == 'kubescape/kubescape' }} # TODO + # uses: ./.github/workflows/build-image.yaml + # needs: create-release + # with: + # client: "image-release" + # image_name: "quay.io/${{ github.repository_owner }}/kubescape" + # image_tag: "v2.0.${{ github.run_number }}" + # support_platforms: true + # cosign: true + # secrets: inherit diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 696a9dc9..9b6d04f3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,6 +15,8 @@ jobs: build: name: Create cross-platform build runs-on: ${{ matrix.os }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] diff --git a/README.md b/README.md index 6f3aaea0..a9a49874 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ kubescape scan framework mitre --submit kubescape scan control "Privileged container" ``` -#### Scan using an anternative kubeconfig file +#### Scan using an alternative kubeconfig file ``` kubescape scan --kubeconfig cluster.conf ``` diff --git a/build.py b/build.py index bf33d395..c3329112 100644 --- a/build.py +++ b/build.py @@ -14,14 +14,15 @@ def check_status(status, msg): def get_build_dir(): current_platform = platform.system() - build_dir = "./build/" + build_dir = "" - if current_platform == "Windows": build_dir += "windows-latest" - elif current_platform == "Linux": build_dir += "ubuntu-latest" - elif current_platform == "Darwin": build_dir += "macos-latest" + if current_platform == "Windows": build_dir = "windows-latest" + elif current_platform == "Linux": build_dir = "ubuntu-latest" + elif current_platform == "Darwin": build_dir = "macos-latest" else: raise OSError("Platform %s is not supported!" % (current_platform)) - return build_dir + return os.path.join("build", build_dir) + def get_package_name(): package_name = "kubescape" diff --git a/build/Dockerfile b/build/Dockerfile index 768267d7..8b5c144b 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -9,7 +9,6 @@ ENV CLIENT=$client ENV GO111MODULE= ENV CGO_ENABLED=1 -ENV PATH=$PATH:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin # Install required python/pip ENV PYTHONUNBUFFERED=1 diff --git a/core/cautils/scaninfo_test.go b/core/cautils/scaninfo_test.go index c8705879..a825fcb8 100644 --- a/core/cautils/scaninfo_test.go +++ b/core/cautils/scaninfo_test.go @@ -18,7 +18,8 @@ func TestSetContextMetadata(t *testing.T) { assert.Nil(t, ctx.HelmContextMetadata) assert.Nil(t, ctx.RepoContextMetadata) } - { + // TODO: tests were commented out due to actual http calls ; http calls should be mocked. + /*{ ctx := reporthandlingv2.ContextMetadata{} setContextMetadata(&ctx, "https://github.com/kubescape/kubescape") @@ -31,7 +32,7 @@ func TestSetContextMetadata(t *testing.T) { assert.Equal(t, "kubescape", ctx.RepoContextMetadata.Repo) assert.Equal(t, "kubescape", ctx.RepoContextMetadata.Owner) assert.Equal(t, "master", ctx.RepoContextMetadata.Branch) - } + }*/ } func TestGetHostname(t *testing.T) { diff --git a/core/pkg/hostsensorutils/hostsensorgetfrompod.go b/core/pkg/hostsensorutils/hostsensorgetfrompod.go index d6b8ff0d..a8074261 100644 --- a/core/pkg/hostsensorutils/hostsensorgetfrompod.go +++ b/core/pkg/hostsensorutils/hostsensorgetfrompod.go @@ -278,7 +278,7 @@ func (hsh *HostSensorHandler) CollectResources() ([]hostsensor.HostSensorDataEnv // GetControlPlaneInfo kcData, err = hsh.GetControlPlaneInfo() if err != nil { - addInfoToMap(KubeProxyInfo, infoMap, err) + addInfoToMap(ControlPlaneInfo, infoMap, err) logger.L().Warning(err.Error()) } if len(kcData) > 0 { diff --git a/core/pkg/resourcehandler/k8sresources.go b/core/pkg/resourcehandler/k8sresources.go index a2b322ab..70e4f9a7 100644 --- a/core/pkg/resourcehandler/k8sresources.go +++ b/core/pkg/resourcehandler/k8sresources.go @@ -84,7 +84,7 @@ func (k8sHandler *K8sResourceHandler) GetResources(sessionObj *cautils.OPASessio imgVulnResources := cautils.MapImageVulnResources(ksResourceMap) // check that controls use image vulnerability resources - if false { //len(imgVulnResources) > 0 { + if len(imgVulnResources) > 0 { logger.L().Info("Requesting images vulnerabilities results") cautils.StartSpinner() if err := k8sHandler.registryAdaptors.collectImagesVulnerabilities(k8sResourcesMap, allResources, ksResourceMap); err != nil { diff --git a/core/pkg/resourcehandler/repositoryscanner_test.go b/core/pkg/resourcehandler/repositoryscanner_test.go index 8470f92d..f9ce633b 100644 --- a/core/pkg/resourcehandler/repositoryscanner_test.go +++ b/core/pkg/resourcehandler/repositoryscanner_test.go @@ -13,6 +13,10 @@ var ( urlD = "https://raw.githubusercontent.com/kubescape/kubescape/master/examples/online-boutique/adservice.yaml" ) +/* + +TODO: tests were commented out due to actual http calls ; http calls should be mocked. + func TestScanRepository(t *testing.T) { { files, err := ScanRepository(urlA, "") @@ -112,6 +116,7 @@ func TestGithubGetYamlFromTree(t *testing.T) { assert.Equal(t, 12, len(files)) } } +*/ func TestGithubParse(t *testing.T) { { diff --git a/core/pkg/resourcehandler/urlloader_test.go b/core/pkg/resourcehandler/urlloader_test.go index aa7356c8..1f500197 100644 --- a/core/pkg/resourcehandler/urlloader_test.go +++ b/core/pkg/resourcehandler/urlloader_test.go @@ -2,12 +2,11 @@ package resourcehandler import ( "testing" - - "github.com/stretchr/testify/assert" ) func TestLoadResourcesFromUrl(t *testing.T) { - { + //TODO: tests were commented out due to actual http calls ; http calls should be mocked. + /*{ workloads, err := loadResourcesFromUrl([]string{"https://github.com/kubescape/kubescape/tree/master/examples/online-boutique"}) assert.NoError(t, err) assert.Equal(t, 12, len(workloads)) @@ -62,5 +61,5 @@ func TestLoadResourcesFromUrl(t *testing.T) { assert.Equal(t, "/v1//Service/adservice", w[1].GetID()) } } - } + }*/ } diff --git a/httphandler/build.py b/httphandler/build.py index 7c61397d..ee516c1c 100644 --- a/httphandler/build.py +++ b/httphandler/build.py @@ -14,18 +14,18 @@ def check_status(status, msg): def get_build_dir(): current_platform = platform.system() - build_dir = "build/" + build_dir = "" - if current_platform == "Windows": build_dir += "windows-latest" - elif current_platform == "Linux": build_dir += "ubuntu-latest" - elif current_platform == "Darwin": build_dir += "macos-latest" + if current_platform == "Windows": build_dir = "windows-latest" + elif current_platform == "Linux": build_dir = "ubuntu-latest" + elif current_platform == "Darwin": build_dir = "macos-latest" else: raise OSError("Platform %s is not supported!" % (current_platform)) - return build_dir + return os.path.join("build", build_dir) def get_package_name(): package_name = "kubescape" - + # TODO: if platform.system() == "Windows": packageName += ".exe" - we should find all places were we access the windows executable before changing the extension return package_name