forked from demisto/content
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'contrib/SEKOIA-IO_Add/SekoiaXDR' into Add/SekoiaXDR
- Loading branch information
Showing
1,362 changed files
with
60,059 additions
and
12,720 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,14 @@ | ||
import os | ||
from demisto_sdk.commands.test_content.execute_test_content import _add_pr_comment | ||
from demisto_sdk.commands.test_content.execute_test_content import ParallelLoggingManager | ||
|
||
|
||
JOB_ID = os.environ.get("CIRCLE_WORKFLOW_JOB_ID") | ||
COVERAGE_LINK = f'https://output.circle-artifacts.com/output/job/{JOB_ID}/artifacts/0/artifacts/coverage_report/html/' \ | ||
f'index.html' | ||
COVERAGE_REPORT_COMMENT = f'Link to the unit tests coverage report: \n {COVERAGE_LINK}' | ||
|
||
|
||
if __name__ == "__main__": | ||
logging_manager = ParallelLoggingManager('UT_coverage_report.log') | ||
_add_pr_comment(COVERAGE_REPORT_COMMENT, logging_manager) |
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,19 @@ | ||
#!/bin/bash | ||
|
||
|
||
# Run flake8 pylint and mypy on all non-Packs. Packs are handled in pre-commit. | ||
errors=0 | ||
all_dirs=$(find . -type d -not \( -path "*cache*" -o -path "./.*" -o -path "./Templates*" -o -path "./TestPlaybooks*" -o -path "./node_modules*" -o -path "./venv*" -o -path "./Packs*" -o -path "./artifacts*" -o -path "*infrastructure_tests*" -o -path "*scripts/awsinstancetool*" -o -path "./docs*" \)) | ||
all_1_depth_dirs=$(find . -maxdepth 1 -type d -not \( -path "*cache*" -o -path . -o -path ./Packs -o -path ./venv -o -path ./Templates -o -path ./TestPlaybooks -o -path ./node_modules -o -path "./artifacts*" -o -path "./.*" -o -path ./docs \)) | ||
|
||
echo -e "Top level folders to scan (used by ruff):\n${all_1_depth_dirs}\n" | ||
echo -e "Folders to be used for lint scan (used by pylint and mypy):\n${all_dirs}\n" | ||
|
||
./.circleci/mypy.sh $all_1_depth_dirs || errors=$? | ||
python3 -m ruff $all_1_depth_dirs --select=E,F,PLC,PLE --ignore=PLC1901 || errors=$? | ||
|
||
|
||
echo 'analyze non-packs files exit code:' $errors | ||
if [[ $errors -ne 0 ]]; then | ||
exit 1 | ||
fi |
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,67 @@ | ||
import re | ||
import sys | ||
|
||
from spell_checker import spell_checker | ||
from demisto_sdk.commands.common.tools import run_command, find_type | ||
from demisto_sdk.commands.common.constants import DESCRIPTION_REGEX, FileType | ||
|
||
|
||
IGNORED_FILES = ['.devcontainer/devcontainer.json', '.vscode/extensions.json'] | ||
|
||
|
||
def get_modified_files(files_string): | ||
"""Get lists of the modified files in your branch according to the files string. | ||
Args: | ||
files_string (string): String that was calculated by git using `git diff` command. | ||
Returns: | ||
(yml_files, md_files). Tuple of sets. | ||
""" | ||
all_files = files_string.split('\n') | ||
yml_files = set([]) | ||
md_files = set([]) | ||
for f in all_files: | ||
file_data = f.split() | ||
if not file_data: | ||
continue | ||
|
||
file_status = file_data[0] | ||
file_path = file_data[1] | ||
if file_path in IGNORED_FILES: | ||
continue | ||
if file_path.endswith('.js') or file_path.endswith('.py'): | ||
continue | ||
if file_status.lower().startswith('r'): | ||
file_path = file_data[2] | ||
|
||
if file_status.lower() == 'm' or file_status.lower() == 'a' or file_status.lower().startswith('r'): | ||
if find_type(file_path) in [FileType.INTEGRATION, FileType.BETA_INTEGRATION, FileType.SCRIPT, | ||
FileType.PLAYBOOK]: | ||
yml_files.add(file_path) | ||
elif re.match(DESCRIPTION_REGEX, file_path, re.IGNORECASE): | ||
md_files.add(file_path) | ||
|
||
return yml_files, md_files | ||
|
||
|
||
def check_changed_files(): | ||
branch_name = sys.argv[1] | ||
|
||
if branch_name != "master": | ||
all_changed_files_string = run_command("git diff --name-status origin/master...{}".format(branch_name)) | ||
yml_files, md_files = get_modified_files(all_changed_files_string) | ||
for yml_file in yml_files: | ||
print("Checking the file - {}".format(yml_file)) | ||
spell_checker(yml_file) | ||
|
||
for md_file in md_files: | ||
print("Checking the file - {}".format(md_file)) | ||
spell_checker(md_file, is_md=True) | ||
|
||
else: | ||
print("Not checking for spelling errors in master branch") | ||
|
||
|
||
if __name__ == "__main__": | ||
check_changed_files() |
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,64 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
import os | ||
import sys | ||
|
||
import requests | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Add a comment to a pull request in the repo.') | ||
parser.add_argument('-p', '--pr_number', help='Pull request number') | ||
parser.add_argument('-c', '--comment', help='The comment to add') | ||
args = parser.parse_args() | ||
|
||
pr_number = args.pr_number | ||
comment = args.comment | ||
token = os.environ['CONTENT_GITHUB_TOKEN'] | ||
|
||
comments_url = get_pr_comments_url(pr_number) | ||
|
||
headers = {'Authorization': 'Bearer ' + token} | ||
response = requests.post(comments_url, json={'body': comment}, headers=headers) | ||
response.raise_for_status() | ||
|
||
print('Successfully added the comment to the PR.') | ||
|
||
|
||
def get_pr_comments_url(pr_number: str) -> str: | ||
""" | ||
Get the comments URL for a PR. If the PR contains a comment about an instance test (for contrib PRs), | ||
it will use that comment. | ||
Args: | ||
pr_number: The pull request number | ||
Returns: | ||
The comments URL for the PR. | ||
""" | ||
pr_url = f'https://api.github.com/repos/demisto/content/pulls/{pr_number}' | ||
response = requests.get(pr_url) | ||
response.raise_for_status() | ||
pr = response.json() | ||
if not pr: | ||
print('Could not find the pull request to reply on.') | ||
sys.exit(1) | ||
page = 1 | ||
comments_url = pr['comments_url'] | ||
while True: | ||
response = requests.get(comments_url, params={'page': str(page)}) | ||
response.raise_for_status() | ||
comments = response.json() | ||
if not comments: | ||
break | ||
|
||
link_comments = [comment for comment in comments if 'Instance is ready.' in comment.get('body', '')] | ||
if link_comments: | ||
comments_url = link_comments[0]['url'] | ||
break | ||
page += 1 | ||
|
||
return comments_url | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
# this file has been deprecated and relocated to the contribution/utils directory | ||
#Be aware, only contributors should run this script. | ||
|
||
echo "This file has been deprecated and relocated to the contribution/utils directory" | ||
|
||
CONTENT_URL='https://github.com/demisto/content.git' | ||
|
||
if [ -z "$1" ] | ||
then | ||
CURRENT=$(git branch --show-current) | ||
else | ||
CURRENT=$1 | ||
fi | ||
|
||
( | ||
git remote add upstream_content $CONTENT_URL || | ||
git remote set-url upstream_content $CONTENT_URL | ||
) && | ||
git fetch upstream_content && | ||
git checkout master && | ||
git rebase upstream_content/master && | ||
git push -f origin master && | ||
git checkout $CURRENT && | ||
git pull origin master | ||
|
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
Oops, something went wrong.