Merge remote-tracking branch 'armo/dev' into dev

This commit is contained in:
Moshe-Rappaport-CA
2022-10-26 12:11:42 +03:00
11 changed files with 41 additions and 32 deletions
+13 -11
View File
@@ -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
+2
View File
@@ -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]
+1 -1
View File
@@ -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
```
+6 -5
View File
@@ -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"
-1
View File
@@ -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
+3 -2
View File
@@ -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) {
@@ -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 {
+1 -1
View File
@@ -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 {
@@ -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) {
{
+3 -4
View File
@@ -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())
}
}
}
}*/
}
+6 -6
View File
@@ -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