Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f71e894
Adding the new workflow
ofiriro3 Feb 14, 2023
cf30520
Add image replacement step
ofiriro3 Feb 14, 2023
fb4c41a
Update actions checkout
ofiriro3 Feb 14, 2023
9908a76
Different format
ofiriro3 Feb 14, 2023
fd344eb
adding cat before
ofiriro3 Feb 14, 2023
abac56c
Moving the image to manifest.yaml
ofiriro3 Feb 14, 2023
124178b
trying to edit the command
ofiriro3 Feb 14, 2023
85b00c5
Trying to use environment variable for it
ofiriro3 Feb 14, 2023
cd1ccd9
Trying to use environment variable for it
ofiriro3 Feb 14, 2023
0303ede
merge vanilla to mine
ofiriro3 Feb 15, 2023
ea5285a
merge vanilla to mine
ofiriro3 Feb 15, 2023
5067c19
adding the image replace flow
ofiriro3 Feb 15, 2023
c649c6f
Revert weekly environment to use same image
ofiriro3 Feb 15, 2023
6c9a3a6
Trying to upgrade the flow to SNAPSHOT 8.7
ofiriro3 Feb 15, 2023
b797ae8
removing manifest file
ofiriro3 Feb 15, 2023
42e160c
fixing spaces
ofiriro3 Feb 15, 2023
acc2af3
Trying to upgrade the flow to SNAPSHOT 8.7.0
ofiriro3 Feb 15, 2023
fdf4b40
Bump oauthlib from 3.2.1 to 3.2.2 in /tests (#710)
dependabot[bot] Feb 20, 2023
46ea3b7
Bump github.com/elastic/elastic-agent-libs from 0.3.0 to 0.3.1 (#751)
dependabot[bot] Feb 21, 2023
cd58bc6
Fix concurrency (#748)
olegsu Feb 21, 2023
45bf871
Update Hermit env vars (#760)
oren-zohar Feb 21, 2023
7831201
[CIS AWS] Fix multiple bugs (#761)
uri-weisman Feb 21, 2023
3ad78c5
Updating flow to use stagging environment
ofiriro3 Feb 22, 2023
b89b0e1
Vulnerability POC (#671)
jeniawhite Feb 23, 2023
f217bc8
Weekly environment - Vanilla POC (#746)
ofiriro3 Feb 23, 2023
067beea
Merge main to mine
ofiriro3 Feb 23, 2023
d997ee9
Trying to install vanilla integration using only the vanilla input
ofiriro3 Feb 23, 2023
086eac7
aws functional tests poc (#770)
gurevichdmitry Feb 23, 2023
7f0ddd4
Merge branch 'main' into weekly-enviroment-vanilla-work-with-SNAPSHOT
ofiriro3 Feb 23, 2023
61d49b0
Terraform formatting
ofiriro3 Feb 23, 2023
170ca5c
Merge remote-tracking branch 'origin/weekly-enviroment-vanilla-work-w…
ofiriro3 Feb 23, 2023
473fee2
Reduce time in Cloudbeat CI (#773)
ofiriro3 Feb 26, 2023
b6e0ae0
Merge branch 'main' into weekly-enviroment-vanilla-work-with-SNAPSHOT
ofiriro3 Feb 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
branches:
- main
- '[0-9]+.[0-9]+'
- "[0-9]+.[0-9]+"
types: [opened, synchronize, reopened]
push:
branches:
Expand All @@ -13,7 +13,6 @@ on:
env:
K8S_MANIFEST_DIR: deploy


concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
Expand All @@ -22,7 +21,7 @@ jobs:
unit_tests:
name: Unit Tests
runs-on: ubuntu-20.04
timeout-minutes: 15
timeout-minutes: 20
steps:
- name: Check out the repo
uses: actions/checkout@v3
Expand Down Expand Up @@ -50,7 +49,7 @@ jobs:

- name: Unit-Test Cloudbeat
run: |
GOOS=linux go test -v -coverpkg=./... -coverprofile=cover.out.tmp ./...
GOOS=linux go test -v -race -coverpkg=./... -coverprofile=cover.out.tmp ./...
cat cover.out.tmp | grep -v "mock_.*.go" > cover.out # remove mock files from coverage report

- name: Upload coverage artifact
Expand Down Expand Up @@ -116,6 +115,7 @@ jobs:
- uses: actions/setup-go@v3
with:
go-version-file: .go-version

- name: Check out the repo
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -153,3 +153,16 @@ jobs:
run: |
cfn-lint --version
cfn-lint -I -t ./deploy/cloudformation/elastic-agent-ec2.yml

terraform-linter:
name: terraform-lint
runs-on: ubuntu-20.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Init Hermit
run: ./bin/hermit env -r >> $GITHUB_ENV

- name: Terraform fmt
run: terraform fmt -check -recursive
25 changes: 5 additions & 20 deletions .github/workflows/weekly-enviroment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ env:
TF_VAR_ec_api_key: ${{ secrets.WEEKLY_ENVIRONMENT_EC_API_KEY }}
TF_VAR_environment: ${{ github.event.inputs.logLevel }}
TF_LOG: ${{ github.event.inputs.logLevel }}
TF_VAR: 8.6.1
TF_VAR_stack_version: 8.7.0-SNAPSHOT

jobs:
terraform:
name: Deploy KSPM/CSPM cloud environment
name: Deploy KSPM cloud environment
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -39,36 +39,24 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v2

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.3.5
terraform_wrapper: false

- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true
- name: Init Hermit
run: ./bin/hermit env -r >> $GITHUB_ENV
working-directory: ./

- name: Terraform Init
id: init
run: terraform init -no-color

- name: Terraform Validate
id: validate
run: terraform validate -no-color

- name: Deploy Elastic Cloud
id: apply
run: terraform apply --auto-approve

- name: Set terraform output as env variable
id: kibana_url
run: |
echo "KIBANA_URL=$(terraform output kibana_url)" >> $GITHUB_ENV

- name: Set sensitive terraform output as env variable
id: set_sensitive_output
run: |
export ELASTICSEARCH_USERNAME=$(terraform output elasticsearch_username)
echo "::add-mask::$ELASTICSEARCH_USERNAME"
Expand All @@ -79,13 +67,11 @@ jobs:
echo "ELASTICSEARCH_PASSWORD=$ELASTICSEARCH_PASSWORD" >> $GITHUB_ENV

- name: Install KSPM vanilla integration
id: install_vanilla_integration
working-directory: ${{ env.SCRIPTS_DIR }}
run: |
./install-kspm-vanilla-integration.sh ${{ env.KIBANA_URL }} ${{ env.ELASTICSEARCH_PASSWORD }}

- name: Deploy agent on EC2
id: deploy_agent_on_ec2
working-directory: ${{ env.SCRIPTS_DIR }}
run: |
echo -e "${{ secrets.WEEKLY_ENVIRONMENT_EC2_PRIVATE_KEY }}" > weekly-key.pem
Expand All @@ -97,7 +83,6 @@ jobs:

# Once https://github.com/slackapi/slack-github-action/issues/84 will be resolved we can push the payload to a different file
- name: Send custom JSON data to Slack workflow
id: slack
uses: slackapi/slack-github-action@v1.23.0
with:
payload: |
Expand Down
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.18.6
1.19
59 changes: 59 additions & 0 deletions beater/beater.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package beater

import (
"fmt"

"github.com/elastic/cloudbeat/config"
"github.com/elastic/cloudbeat/flavors"
"github.com/elastic/cloudbeat/launcher"

"github.com/elastic/beats/v7/libbeat/beat"
"github.com/elastic/beats/v7/libbeat/common/reload"
agentconfig "github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/logp"
)

func New(b *beat.Beat, cfg *agentconfig.C) (beat.Beater, error) {
log := logp.NewLogger("launcher")
reloader := launcher.NewListener(log)
validator := &validator{}

s, err := launcher.New(log, "Cloudbeat", reloader, validator, NewBeater, cfg)
if err != nil {
return nil, err
}

reload.RegisterV2.MustRegisterInput(reloader)
return s, nil
}

// NewBeater creates an instance of beater.
func NewBeater(b *beat.Beat, cfg *agentconfig.C) (beat.Beater, error) {
c, err := config.New(cfg)
if err != nil {
return nil, fmt.Errorf("NewBeater: could not parse configuration %v, skipping with error: %w", cfg.FlattenedKeys(), err)
}
switch c.Deployment {
case config.VulnerabilityType:
return flavors.NewVulnerability(b, cfg)
default:
return flavors.NewPosture(b, cfg)
}
}
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/go
2 changes: 1 addition & 1 deletion bin/gofmt
2 changes: 1 addition & 1 deletion bin/hermit.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
env = {
"CLOUDBEAT_VERSION": "8.7.0",
"CLOUDBEAT_VERSION": "8.8.0",
"ELK_VERSION": "${CLOUDBEAT_VERSION}-SNAPSHOT",
}
9 changes: 6 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ import (
"github.com/elastic/elastic-agent-libs/config"
)

const DefaultNamespace = "default"

const ResultsDatastreamIndexPrefix = "logs-cloud_security_posture.findings"
const (
DefaultNamespace = "default"
VulnerabilityType = "cloudbeat/vuln_mgmt_aws"
ResultsDatastreamIndexPrefix = "logs-cloud_security_posture.findings"
)

var ErrBenchmarkNotSupported = launcher.NewUnhealthyError("benchmark is not supported")

Expand All @@ -43,6 +45,7 @@ type Fetcher struct {

type Config struct {
Benchmark string `config:"config.v1.benchmark"`
Deployment string `config:"config.v1.deployment"`
CloudConfig CloudConfig `config:"config.v1"`
Fetchers []*config.C `config:"fetchers"`
KubeConfig string `config:"kube_config"`
Expand Down
4 changes: 2 additions & 2 deletions deploy/cloud/modules/api/terraform.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
terraform {
required_providers {
restapi = {
source = "mastercard/restapi"
source = "mastercard/restapi"
version = "~> 1.18.0"
}
http = {
source = "hashicorp/http"
source = "hashicorp/http"
version = "~> 3.2.1"
}
}
Expand Down
8 changes: 4 additions & 4 deletions deploy/cloud/modules/provision-apps/aws-ebs-csi-driver.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
resource "helm_release" "aws_ebs_csi_driver" {
chart = "aws-ebs-csi-driver"
name = "aws-ebs-csi-driver"
namespace = var.namespace
chart = "aws-ebs-csi-driver"
name = "aws-ebs-csi-driver"
namespace = var.namespace
repository = "https://kubernetes-sigs.github.io/aws-ebs-csi-driver"


set {
name = "controller.serviceAccount.name"
name = "controller.serviceAccount.name"
value = "ebs-csi-controller-sa"
}

Expand Down
10 changes: 5 additions & 5 deletions deploy/cloud/modules/provision-apps/nginx-ingress.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
resource "helm_release" "nginx_ingress" {
chart = "nginx-ingress-controller"
name = "nginx-ingress-controller"
chart = "nginx-ingress-controller"
name = "nginx-ingress-controller"

repository = "https://charts.bitnami.com/bitnami"
timeout = 600
namespace = var.namespace
timeout = 600
namespace = var.namespace

set {
name = "service.type"
value = "ClusterIP"
}

set {
name = "replicaCount"
name = "replicaCount"
value = var.replica_count
}
}
2 changes: 1 addition & 1 deletion deploy/cloud/modules/provision-apps/terraform.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
helm = {
source = "hashicorp/helm"
source = "hashicorp/helm"
version = ">=2.8.0"
}

Expand Down
4 changes: 2 additions & 2 deletions deploy/cloud/modules/provision-apps/variables.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
variable "namespace" {
type = string
type = string
default = "default"
}

variable "replica_count" {
type = string
type = string
default = "2"
}
7 changes: 7 additions & 0 deletions deploy/k8s/kind/kind-mono.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,12 @@ nodes:
extraMounts:
- hostPath: ./tests/allure/results
containerPath: /tmp/data
extraPortMappings:
- containerPort: 9200
hostPort: 9200
listenAddress: "127.0.0.1"
- containerPort: 5601
hostPort: 5601
listenAddress: "127.0.0.1"

# Todo Enable EphemeralContainers on kind config for debug
3 changes: 2 additions & 1 deletion deploy/weekly-environment/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
provider "ec" {
apikey = var.ec_api_key
apikey = var.ec_api_key
endpoint = var.endpoint
}

module "ec_deployment" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,24 @@
"data_stream": {
"type": "logs",
"dataset": "cloud_security_posture.findings"
},
"release": "ga"
}
]
},
{
"type": "cloudbeat/cis_eks",
"policy_template": "kspm",
"enabled": false,
"streams": [
{
"enabled": false,
"data_stream": {
"type": "logs",
"dataset": "cloud_security_posture.findings"
},
"release": "ga",
"vars": {
"access_key_id": {
"type": "text"
},
"secret_access_key": {
"type": "text"
},
"session_token": {
"type": "text"
},
"shared_credential_file": {
"type": "text"
},
"credential_profile_name": {
"type": "text"
},
"role_arn": {
"type": "text"
}
}
}
]
}
],
"package": {
"name": "cloud_security_posture",
"title": "Kubernetes Security Posture Management (KSPM)",
"version": "1.1.1"
"title": "Security Posture Management (CSPM/KSPM)",
"version": "1.2.10"
},
"vars": {
"posture": {
"value": "kspm",
"type": "text"
},
"deployment": {
"value": "cloudbeat/cis_k8s",
"type": "text"
}
}
}
Loading