-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Asset Inventory][Azure] Add test cases and installation script (#2498)
- Loading branch information
Showing
15 changed files
with
579 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: 'Azure Asset Inventory CI' | ||
description: 'Azure Asset Inventory integration tests' | ||
inputs: | ||
elk-version: | ||
description: 'ELK version' | ||
required: true | ||
azure-client-id: | ||
description: 'Azure client id' | ||
required: true | ||
azure-tenant-id: | ||
description: 'Azure tenant id' | ||
required: true | ||
azure-client-secret: | ||
description: 'Azure client secret' | ||
required: true | ||
|
||
debug: | ||
description: 'debug' | ||
required: false | ||
default: 'false' | ||
runs: | ||
using: composite | ||
steps: | ||
- name: Init Integration | ||
uses: ./.github/actions/init-integration | ||
with: | ||
elk-version: ${{ inputs.elk-version }} | ||
|
||
- name: Run cloudbeat in background | ||
env: | ||
ES_HOST: http://localhost:9200 | ||
ES_USERNAME: elastic | ||
ES_PASSWORD: changeme | ||
AZURE_ACCOUNT_TYPE: single-account | ||
AZURE_CREDENTIALS_TYPE: service_principal_with_client_secret | ||
AZURE_CLIENT_ID: ${{ inputs.azure-client-id }} | ||
AZURE_TENANT_ID: ${{ inputs.azure-tenant-id }} | ||
AZURE_CLIENT_SECRET: ${{ inputs.azure-client-secret }} | ||
shell: bash | ||
run: | | ||
./cloudbeat -c deploy/asset-inventory/cloudbeat-azure-asset-inventory.yml -d '*' & | ||
- name: Wait for cloudbeat to send some events | ||
shell: bash | ||
run: sleep 15 | ||
|
||
- name: Check for findings | ||
working-directory: ./tests | ||
env: | ||
USE_K8S: "false" | ||
shell: bash | ||
run: poetry run pytest -k "asset_inventory_azure" --alluredir=./allure/results/ --clean-alluredir | ||
|
||
- name: Upload test results | ||
if: ${{ always() }} | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: allure-results-ci-azure | ||
path: tests/allure/results/ | ||
overwrite: true | ||
|
||
- if: ${{ failure() || cancelled() || inputs.debug == 'true' }} | ||
name: Upload cloudbeat logs | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: cloubeat-logs-ci-azure | ||
path: logs/ | ||
if-no-files-found: warn | ||
retention-days: 1 | ||
overwrite: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
deploy/asset-inventory/cloudbeat-azure-asset-inventory.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
cloudbeat: | ||
type: cloudbeat/asset_inventory | ||
config: | ||
v1: | ||
type: asset_inventory | ||
asset_inventory_provider: azure | ||
azure: | ||
account_type: ${AZURE_ACCOUNT_TYPE:""} | ||
credentials: | ||
type: ${AZURE_CREDENTIALS_TYPE:""} | ||
client_id: ${AZURE_CLIENT_ID:""} | ||
tenant_id: ${AZURE_TENANT_ID:""} | ||
client_secret: ${AZURE_CLIENT_SECRET:""} | ||
# Defines how often an event is sent to the output | ||
period: 30s | ||
evaluator: | ||
decision_logs: false | ||
# =================================== Kibana =================================== | ||
setup.kibana: | ||
# Kibana Host | ||
host: "http://host.docker.internal:5601" | ||
# =============================== Elastic Cloud ================================ | ||
|
||
# These settings simplify using Cloudbeat with the Elastic Cloud (https://cloud.elastic.co/). | ||
|
||
# The cloud.id setting overwrites the `output.elasticsearch.hosts` and | ||
# `setup.kibana.host` options. | ||
# You can find the `cloud.id` in the Elastic Cloud web UI. | ||
#cloud.id: | ||
|
||
# The cloud.auth setting overwrites the `output.elasticsearch.username` and | ||
# `output.elasticsearch.password` settings. The format is `<user>:<pass>`. | ||
#cloud.auth: | ||
|
||
# ---------------------------- Elasticsearch Output ---------------------------- | ||
output.elasticsearch: | ||
# Array of hosts to connect to. | ||
hosts: ${ES_HOST} | ||
|
||
# Protocol - either `http` (default) or `https`. | ||
# protocol: "https" | ||
|
||
# Authentication credentials - either API key or username/password. | ||
#api_key: "id:api_key" | ||
username: ${ES_USERNAME} | ||
password: ${ES_PASSWORD} | ||
|
||
# Enable to allow sending output to older ES versions | ||
allow_older_versions: true | ||
|
||
# ================================= Processors ================================= | ||
processors: | ||
- add_cloud_metadata: ~ | ||
- add_docker_metadata: ~ | ||
- drop_fields: | ||
fields: ["host.name"] | ||
# Sets log level. The default log level is info. | ||
# Available log levels are: error, warning, info, debug | ||
logging.level: debug | ||
# Enable debug output for selected components. To enable all selectors use ["*"] | ||
# Other available selectors are "beat", "publisher", "service" | ||
# Multiple selectors can be chained. | ||
#logging.selectors: ["publisher"] | ||
|
||
# Send all logging output to stderr. The default is false. | ||
#logging.to_stderr: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "tf-ap-asset-inventory-azure", | ||
"namespace": "default", | ||
"monitoring_enabled": [ | ||
"logs", | ||
"metrics" | ||
] | ||
} |
30 changes: 30 additions & 0 deletions
30
deploy/cloud/data/package_policy_asset_inventory_azure.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"policy_id": "${agent_policy_id}", | ||
"package": { | ||
"name": "cloud_asset_inventory", | ||
"version": "0.2.1" | ||
}, | ||
"name": "pkg-plcy-asset-inventory-azure-tf", | ||
"description": "", | ||
"namespace": "default", | ||
"inputs": { | ||
"asset_inventory-cloudbeat/asset_inventory_aws": { | ||
"enabled": false, | ||
"streams": { | ||
"cloud_asset_inventory.asset_inventory": { | ||
"enabled": false, | ||
"vars": {} | ||
} | ||
} | ||
}, | ||
"asset_inventory-cloudbeat/asset_inventory_azure": { | ||
"enabled": true, | ||
"streams": { | ||
"cloud_asset_inventory.asset_inventory": { | ||
"enabled": true, | ||
"vars": {} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.