Skip to content

Commit

Permalink
pr review
Browse files Browse the repository at this point in the history
  • Loading branch information
kobymeir committed Jul 6, 2023
1 parent 443309d commit 7ced59a
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 69 deletions.
3 changes: 0 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,8 @@ references:
echo "demisto-sdk version: $(demisto-sdk --version)"
echo "mypy version: $(mypy --version)"
echo "flake8 py2 version: $(python2 -m flake8 --version)"
echo "flake8 py3 version: $(python3 -m flake8 --version)"
echo "bandit py2 version: $(python2 -m bandit --version 2>&1)"
echo "bandit py3 version: $(python3 -m bandit --version 2>&1)"
echo "vulture py2 version: $(python2 -m vulture --version 2>&1)"
echo "vulture py3 version: $(python3 -m vulture --version 2>&1)"
mkdir ./unit-tests
Expand Down
27 changes: 15 additions & 12 deletions .gitlab/ci/bucket-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs-done-check-upload-flow:
extends:
- .jobs-done-check
- .bucket-upload-rule
needs: ['run-unittests-and-lint-upload-flow', 'run-validations-upload-flow', 'mpv2-prepare-testing-bucket-upload-flow', 'upload-id-set-bucket', 'xpanse-prepare-testing-bucket-upload-flow', 'xsoar-prepare-testing-bucket-upload-flow', 'install-packs-in-server6_6', 'install-packs-in-server6_8', 'install-packs-in-server6_9', 'install-packs-in-server6_10', 'install-packs-in-server-master', 'install-packs-in-xsiam-ga', 'sync-buckets-between-projects', 'upload-packs-to-marketplace', 'upload-packs-to-marketplace-v2', 'upload-packs-to-xpanse-marketplace']
needs: ['run-unittests-and-lint-upload-flow', 'run-validations-upload-flow', 'mpv2-prepare-testing-bucket-upload-flow', 'upload-id-set-bucket', 'xpanse-prepare-testing-bucket-upload-flow', 'xsoar-prepare-testing-bucket-upload-flow', 'install-packs-in-server6_8', 'install-packs-in-server6_9', 'install-packs-in-server6_10', 'install-packs-in-server6_11', 'install-packs-in-server-master', 'install-packs-in-xsiam-ga', 'sync-buckets-between-projects', 'upload-packs-to-marketplace', 'upload-packs-to-marketplace-v2', 'upload-packs-to-xpanse-marketplace']
tags:
- gke

Expand Down Expand Up @@ -134,11 +134,12 @@ xpanse-prepare-testing-bucket-upload-flow:
script:
- EXIT_CODE=0
- section_start "Download configuration"
- ./Tests/scripts/download_demisto_conf.sh >> $ARTIFACTS_FOLDER/logs/installations.log
- ./Tests/scripts/download_conf_repos.sh >> $ARTIFACTS_FOLDER/logs/installations.log
- SECRET_CONF_PATH=$(cat secret_conf_path)
- python3 ./Tests/scripts/add_secrets_file_to_build.py -sa "$GSM_SERVICE_ACCOUNT" -sf "$SECRET_CONF_PATH" -u "$DEMISTO_USERNAME" -p "$DEMISTO_PASSWORD" -gpid "$GSM_PROJECT_ID"
- ./Tests/scripts/download_conf_repos.sh >> $ARTIFACTS_FOLDER/logs/download_conf_repos.log
- section_end "Download configuration"
- !reference [.open-ssh-tunnel]
- !reference [.ssh-config-setup]
- section_start "Get Instance Variables"
- echo INSTANCE_ROLE="$INSTANCE_ROLE"
- echo INSTANCE_CREATED="$INSTANCE_CREATED"
Expand All @@ -150,17 +151,12 @@ xpanse-prepare-testing-bucket-upload-flow:
- ./Tests/Marketplace/install_packs.sh "$INSTANCE_ROLE" || EXIT_CODE=$?
- section_end "Install Packs"
- section_start "Destroy instances"
- python3 ./Tests/scripts/destroy_instances.py $ARTIFACTS_FOLDER $ARTIFACTS_FOLDER/env_results.json "$INSTANCE_ROLE" "$TIME_TO_LIVE" || EXIT_CODE=$?
- python3 ./Tests/scripts/destroy_instances.py --aritfacts-dir $ARTIFACTS_FOLDER --env-file $ARTIFACTS_FOLDER/env_results.json --instance-role "$INSTANCE_ROLE" || EXIT_CODE=$?
- section_end "Destroy instances"
- job-done
- exit "$EXIT_CODE"


install-packs-in-server6_6:
extends: .install_packs_in_xsoar_server
variables:
INSTANCE_ROLE: "Server 6.6"

install-packs-in-server6_8:
extends: .install_packs_in_xsoar_server
variables:
Expand All @@ -176,6 +172,11 @@ install-packs-in-server6_10:
variables:
INSTANCE_ROLE: "Server 6.10"

install-packs-in-server6_11:
extends: .install_packs_in_xsoar_server
variables:
INSTANCE_ROLE: "Server 6.11"

install-packs-in-server-master:
extends: .install_packs_in_xsoar_server
variables:
Expand Down Expand Up @@ -205,9 +206,10 @@ install-packs-in-server-master:
script:
- EXIT_CODE=0
- section_start "Download configuration"
- ./Tests/scripts/download_demisto_conf.sh >> $ARTIFACTS_FOLDER/logs/installations.log
- ./Tests/scripts/download_conf_repos.sh >> $ARTIFACTS_FOLDER/logs/installations.log
- SECRET_CONF_PATH=$(cat secret_conf_path)
- python3 ./Tests/scripts/add_secrets_file_to_build.py -sa "$GSM_SERVICE_ACCOUNT" -sf "$SECRET_CONF_PATH" -u "$DEMISTO_USERNAME" -p "$DEMISTO_PASSWORD" -gpid "$GSM_PROJECT_ID"
- ./Tests/scripts/download_conf_repos.sh >> $ARTIFACTS_FOLDER/logs/download_conf_repos.log
- section_end "Download configuration"
- section_start "Lock Machine"
- echo "Authenticating GCP"
Expand Down Expand Up @@ -257,12 +259,13 @@ install-packs-in-xsiam-ga:
GCS_MACHINES_BUCKET: "marketplace-v2-dist-dev/upload-flow/builds-xsiam"
CLOUD_SERVERS_FILE: "xsiam_servers_path"
CLOUD_API_KEYS: $XSIAM_API_KEYS
UNREMOVABLE_PACKS: "Base,CoreAlertFields,Core,CortexAttackSurfaceManagement"


upload-packs-to-marketplace:
tags:
- gke
needs: ["run-validations-upload-flow", "install-packs-in-server6_6", "install-packs-in-server6_8", "install-packs-in-server6_9", "install-packs-in-server6_10", "run-unittests-and-lint-upload-flow"]
needs: ["run-validations-upload-flow", "install-packs-in-server6_8", "install-packs-in-server6_9", "install-packs-in-server6_10", "install-packs-in-server6_11", "run-unittests-and-lint-upload-flow"]
stage: upload-to-marketplace
artifacts:
expire_in: 48 hrs
Expand All @@ -282,7 +285,7 @@ upload-packs-to-marketplace:
- .bucket-upload-rule
- .default-job-settings
script:
- !reference [.open-ssh-tunnel]
- !reference [.ssh-config-setup]
- *check_user_permissions_to_upload_packs
- section_start "Upload Packs To Marketplace Storage"
- |
Expand Down
16 changes: 6 additions & 10 deletions .gitlab/ci/global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@

.download-demisto-conf:
- section_start "Download content-test-conf" --collapsed
- ./Tests/scripts/download_demisto_conf.sh | tee --append $ARTIFACTS_FOLDER/logs/download_demisto_conf.log
- ./Tests/scripts/download_conf_repos.sh >> $ARTIFACTS_FOLDER/logs/download_demisto_conf.log
- SECRET_CONF_PATH=$(cat secret_conf_path)
- python3 ./Tests/scripts/add_secrets_file_to_build.py -sa "$GSM_SERVICE_ACCOUNT" -sf "$SECRET_CONF_PATH" -u "$DEMISTO_USERNAME" -p "$DEMISTO_PASSWORD" -gpid "$GSM_PROJECT_ID"
- ./Tests/scripts/download_conf_repos.sh >> $ARTIFACTS_FOLDER/logs/download_conf_repos.log
- section_end "Download content-test-conf"

.open-ssh-tunnel:
- section_start "Open SSH Tunnel" --collapsed
- cat $SSH_CONFIGURATION >> ~/.ssh/config
.ssh-config-setup:
- section_start "SSH config setup" --collapsed
- cp $GCP_SSH_CONFIGURATION ~/.ssh/config
- chmod 700 ~/.ssh/config
- ./Tests/scripts/open_ssh_tunnel.sh
- section_end "Open SSH Tunnel"
- section_end "SSH config setup"

.check_build_files_are_up_to_date: &check_build_files_are_up_to_date
- section_start "Check Build Files Are Up To Date"
Expand Down Expand Up @@ -175,7 +175,6 @@
- neo4j-admin dbms set-initial-password contentgraph
- neo4j start
- python --version
- python2 --version
- python3 --version
- pip3 --version
- node --version
Expand Down Expand Up @@ -248,11 +247,8 @@
else
echo "demisto-sdk version: $(demisto-sdk --version)"
echo "mypy version: $(mypy --version)"
echo "flake8 py2 version: $(python2 -m flake8 --version)"
echo "flake8 py3 version: $(python3 -m flake8 --version)"
echo "bandit py2 version: $(python2 -m bandit --version 2>&1)"
echo "bandit py3 version: $(python3 -m bandit --version 2>&1)"
echo "vulture py2 version: $(python2 -m vulture --version 2>&1)"
echo "vulture py3 version: $(python3 -m vulture --version 2>&1)"
SHOULD_LINT_ALL=$(./Tests/scripts/should_lint_all.sh)
mkdir ./unit-tests
Expand Down
4 changes: 2 additions & 2 deletions .gitlab/ci/instance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ test_instances:
script:
- EXIT_CODE=0
- !reference [.download-demisto-conf]
- !reference [.open-ssh-tunnel]
- !reference [.ssh-config-setup]
- python3 ./Tests/scripts/wait_until_server_ready.py "$INSTANCE_ROLE" || EXIT_CODE=$?
- ./Tests/scripts/instance_test.sh || EXIT_CODE=$?
- python3 ./Tests/scripts/destroy_instances.py $ARTIFACTS_FOLDER $ARTIFACTS_FOLDER/env_results.json "$INSTANCE_ROLE" "$TIME_TO_LIVE" || EXIT_CODE=$?
- python3 ./Tests/scripts/destroy_instances.py --aritfacts-dir $ARTIFACTS_FOLDER --env-file $ARTIFACTS_FOLDER/env_results.json --instance-role "$INSTANCE_ROLE" || EXIT_CODE=$?
- exit "$EXIT_CODE"
30 changes: 15 additions & 15 deletions .gitlab/ci/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,8 @@ validate-content-conf:
if [[ ${MARKETPLACE_VERSION} = "xsoar" ]]; then
echo "Creating Instances, only for XSOAR."
[ -n "${TIME_TO_LIVE}" ] && TTL=${TIME_TO_LIVE} || TTL=300
python3 ./Tests/scripts/awsinstancetool/aws_instance_tool.py -envType "$IFRA_ENV_TYPE" -timetolive $TTL -outfile "$ARTIFACTS_FOLDER/env_results.json"
time python3 ./gcp/create_instance.py --env-type "$IFRA_ENV_TYPE" --outfile "$ARTIFACTS_FOLDER/env_results.json" --creds $CONTENET_BUILD_GCP --zone $GCP_ZONE
fi
- section_end "Create Instances for XSOAR"

- section_start "Upload Artifacts to GCP" --collapsed
- ./Tests/scripts/upload_artifacts.sh
- section_end "Upload Artifacts to GCP"
Expand Down Expand Up @@ -254,7 +252,7 @@ xpanse-prepare-testing-bucket:
job-done
exit 0
fi
- !reference [.open-ssh-tunnel]
- !reference [.ssh-config-setup]
- python3 ./Tests/scripts/wait_until_server_ready.py "$INSTANCE_ROLE"
- |
# workaround for the hard-coded value in the sdk
Expand Down Expand Up @@ -284,45 +282,45 @@ xpanse-prepare-testing-bucket:
if [ -z "${TIME_TO_LIVE}" -a "$CI_PIPELINE_SOURCE" = "contrib" ]; then
TIME_TO_LIVE=300
fi
python3 ./Tests/scripts/destroy_instances.py $ARTIFACTS_FOLDER $ARTIFACTS_FOLDER/env_results.json "$INSTANCE_ROLE" "$TIME_TO_LIVE" || EXIT_CODE=$?
python3 ./Tests/scripts/destroy_instances.py --aritfacts-dir $ARTIFACTS_FOLDER --env-file $ARTIFACTS_FOLDER/env_results.json --instance-role "$INSTANCE_ROLE" || EXIT_CODE=$?
- job-done
- exit $EXIT_CODE

xsoar_server_6_6:
xsoar_server_6_8:
extends: .test_content_on_xsoar_server_instances_base
# No need to trigger in case of release branch or docker update branches (non-nightly packs)
rules:
- !reference [.filter-non-nightly-docker-updates-rule, rules]
- if: '$CI_PIPELINE_SOURCE =~ /^(push|contrib)$/'
variables:
INSTANCE_ROLE: "Server 6.6"
INSTANCE_ROLE: "Server 6.8"

xsoar_server_6_8:
xsoar_server_6_9:
extends: .test_content_on_xsoar_server_instances_base
# No need to trigger in case of release branch or docker update branches (non-nightly packs)
rules:
- !reference [.filter-non-nightly-docker-updates-rule, rules]
- if: '$CI_PIPELINE_SOURCE =~ /^(push|contrib)$/'
variables:
INSTANCE_ROLE: "Server 6.8"
INSTANCE_ROLE: "Server 6.9"

xsoar_server_6_9:
xsoar_server_6_10:
extends: .test_content_on_xsoar_server_instances_base
# No need to trigger in case of release branch or docker update branches (non-nightly packs)
rules:
- !reference [.filter-non-nightly-docker-updates-rule, rules]
- if: '$CI_PIPELINE_SOURCE =~ /^(push|contrib)$/'
variables:
INSTANCE_ROLE: "Server 6.9"
INSTANCE_ROLE: "Server 6.10"

xsoar_server_6_10:
xsoar_server_6_11:
extends: .test_content_on_xsoar_server_instances_base
# No need to trigger in case of release branch or docker update branches (non-nightly packs)
rules:
- !reference [.filter-non-nightly-docker-updates-rule, rules]
- if: '$CI_PIPELINE_SOURCE =~ /^(push|contrib)$/'
variables:
INSTANCE_ROLE: "Server 6.10"
INSTANCE_ROLE: "Server 6.11"

xsoar_server_master:
extends:
Expand Down Expand Up @@ -376,14 +374,14 @@ jobs-done-check-on-push:
optional: true
- job: xsiam_server_ga
optional: true
- job: xsoar_server_6_6
optional: true
- job: xsoar_server_6_8
optional: true
- job: xsoar_server_6_9
optional: true
- job: xsoar_server_6_10
optional: true
- job: xsoar_server_6_11
optional: true
- job: xsoar_server_master
optional: true
tags:
Expand Down Expand Up @@ -528,6 +526,7 @@ xsiam_server_ga:
GCS_MACHINES_BUCKET: "marketplace-v2-dist-dev/upload-flow/builds-xsiam"
SERVER_TYPE: "XSIAM"
MARKETPLACE_NAME: "marketplacev2"
UNREMOVABLE_PACKS: "Base,CoreAlertFields,Core,CortexAttackSurfaceManagement"
needs:
- job: mpv2-prepare-testing-bucket
optional: true
Expand All @@ -552,6 +551,7 @@ xsoar_ng_server_ga:
GCS_MACHINES_BUCKET: "marketplace-dist-dev/upload-flow/builds-xsoar-ng"
SERVER_TYPE: "XSIAM"
MARKETPLACE_NAME: "xsoar"
UNREMOVABLE_PACKS: "Base"
needs:
- job: xsoar-prepare-testing-bucket
optional: true
Expand Down
9 changes: 4 additions & 5 deletions .gitlab/ci/sdk-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ demisto-sdk-nightly:run-commands-against-instance:
stage: run-instances
needs: ["demisto-sdk-nightly:xsoar-prepare-testing-bucket"]
script:
- !reference [.open-ssh-tunnel]
- !reference [.ssh-config-setup]
- python3 ./Tests/scripts/wait_until_server_ready.py "$INSTANCE_ROLE"
- !reference [.download-demisto-conf]
- |
export DEMISTO_BASE_URL="https://localhost:$(cat $ARTIFACTS_FOLDER/env_results.json | jq -r '.[0].TunnelPort')"
export DEMISTO_BASE_URL="https://$(cat $ARTIFACTS_FOLDER/env_results.json | jq -r '.[0].InstanceDNS')"
echo "Server URL: $DEMISTO_BASE_URL"
- section_start "Unlock HelloWorld Integration and Playbook" --collapsed
- python3 Tests/sdknightly/unlock_entity.py integration "HelloWorld,HelloWorld Feed"
Expand Down Expand Up @@ -208,7 +208,7 @@ demisto-sdk-nightly:run-commands-against-instance:
- *change-file-ids
- *upload-entities-to-cortex-xsoar
- section_start "Destroy instances"
- python3 ./Tests/scripts/destroy_instances.py $ARTIFACTS_FOLDER $ARTIFACTS_FOLDER/env_results.json "$INSTANCE_ROLE" "$TIME_TO_LIVE"
- python3 ./Tests/scripts/destroy_instances.py --aritfacts-dir $ARTIFACTS_FOLDER --env-file $ARTIFACTS_FOLDER/env_results.json --instance-role "$INSTANCE_ROLE"
- section_end "Destroy instances"
- job-done

Expand All @@ -229,13 +229,12 @@ demisto-sdk-nightly:run-end-to-end-tests:
needs: ["demisto-sdk-nightly:xsoar-prepare-testing-bucket"]
stage: run-instances
script:
- !reference [.open-ssh-tunnel]
- |
mkdir $ARTIFACTS_FOLDER/demisto-sdk
git clone -b master --single-branch --depth 1 https://github.com/demisto/demisto-sdk.git $ARTIFACTS_FOLDER/demisto-sdk
TUNNEL_PORT=$(cat $ARTIFACTS_FOLDER/env_results.json | jq "map(select(.Role == \"$INSTANCE_ROLE\")) | .[].TunnelPort")
export DEMISTO_BASE_URL="https://localhost:$TUNNEL_PORT"
export DEMISTO_BASE_URL="https://$(cat $ARTIFACTS_FOLDER/env_results.json | jq -r '.[0].InstanceDNS')"
echo "Server URL: $DEMISTO_BASE_URL"
unset DEMISTO_API_KEY # a temporary fix
python3 -m pytest $ARTIFACTS_FOLDER/demisto-sdk/tests_end_to_end/ || EXIT_CODE=$?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def args_to_filter_for_dismiss_and_resolve_alerts(alert_ids: Any, custom_filter:
return request_data


def module_test(client: Client, is_fetch: Optional[Any], custom_filter: Optional[str]):
def test_module(client: Client, is_fetch: Optional[Any], custom_filter: Optional[str]):
try:
if client.auth_mode == "device code flow":
raise DemistoException(
Expand Down Expand Up @@ -962,7 +962,7 @@ def main(): # pragma: no cover
demisto.debug(f'Command being called is {command}')

if command == 'test-module':
result = module_test(client, params.get('isFetch'), params.get('custom_filter'))
result = test_module(client, params.get('isFetch'), params.get('custom_filter'))
return_results(result)

elif command == 'fetch-incidents':
Expand Down

0 comments on commit 7ced59a

Please sign in to comment.