forked from Georepublic/bucket-antivirus-function
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Georepublic/dev-python3.11
Python3.12
- Loading branch information
Showing
27 changed files
with
642 additions
and
491 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -6,3 +6,6 @@ omit = | |
*/python?.?/* | ||
*/site-packages/nose/* | ||
show_missing = true | ||
|
||
[html] | ||
directory = coverage_html_report |
This file was deleted.
Oops, something went wrong.
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,29 @@ | ||
name: CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.12' | ||
- name: Create virtualenv | ||
run: | | ||
python -m venv venv | ||
source venv/bin/activate | ||
- name: Install dependencies | ||
run: | | ||
pip install -r requirements.txt | ||
pip install -r requirements-dev.txt | ||
- name: Run pytest | ||
run: | | ||
pytest -v | ||
- name: Run pre-commit | ||
run: | | ||
pip install pre-commit | ||
pre-commit install-hooks | ||
pre-commit run --all-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,63 @@ | ||
name: Test with LocalStack | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Install dependencies | ||
run: sudo apt update && sudo apt install -y make wget | ||
- name: build docker image | ||
run: make archive | ||
- name: Start LocalStack | ||
uses: LocalStack/setup-localstack@main | ||
with: | ||
image-tag: 'latest' | ||
install-awslocal: 'true' | ||
- name: Run tests against localstack | ||
run: | | ||
awslocal s3 mb s3://antivirus-definitions | ||
awslocal s3 mb s3://test-bucket | ||
wget https://secure.eicar.org/eicar_com.zip | ||
awslocal s3 cp eicar_com.zip s3://test-bucket/eicar_com.zip | ||
awslocal lambda create-function \ | ||
--function-name update-clamav \ | ||
--runtime python3.12 \ | ||
--handler update.lambda_handler \ | ||
--role arn:aws:iam::123456789012:role/lambda-role \ | ||
--zip-file fileb://./build/lambda.zip \ | ||
--timeout 120 \ | ||
--environment "Variables={AV_DEFINITION_S3_BUCKET=antivirus-definitions}" | ||
sleep 30 | ||
awslocal lambda invoke \ | ||
--function-name update-clamav \ | ||
--invocation-type RequestResponse \ | ||
--log-type Tail \ | ||
--payload '{}' \ | ||
response.json \ | ||
--query 'LogResult' | tr -d '"' | base64 -d | ||
awslocal lambda create-function \ | ||
--function-name scan-clamav \ | ||
--runtime python3.12 \ | ||
--handler scan.lambda_handler \ | ||
--role arn:aws:iam::123456789012:role/lambda-role \ | ||
--zip-file fileb://./build/lambda.zip \ | ||
--timeout 120 \ | ||
--environment "Variables={AV_DEFINITION_S3_BUCKET=antivirus-definitions,AV_DELETE_INFECTED_FILES=True}" | ||
sleep 30 | ||
awslocal lambda invoke \ | ||
--function-name scan-clamav \ | ||
--invocation-type RequestResponse \ | ||
--log-type Tail \ | ||
--payload '{"Records": [{"s3": {"bucket": {"name": "test-bucket"}, "object": {"key": "eicar_com.zip"}}}]}' \ | ||
response.json \ | ||
--query 'LogResult' | tr -d '"' | base64 -d | ||
result=$(awslocal s3 ls s3://test-bucket) | ||
if [ -z "$result" ]; then | ||
echo "Bucket is empty" | ||
else | ||
echo "Bucket is not empty" | ||
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,26 @@ | ||
name: pre-commit | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.12' | ||
- name: Create virtualenv | ||
run: | | ||
python -m venv venv | ||
source venv/bin/activate | ||
- name: Install dependencies | ||
run: | | ||
pip install -r requirements.txt | ||
pip install -r requirements-dev.txt | ||
- name: Run pre-commit | ||
run: | | ||
pip install pre-commit | ||
pre-commit install-hooks | ||
pre-commit run --all-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 |
---|---|---|
|
@@ -117,3 +117,9 @@ tmp/ | |
|
||
# EICAR Files | ||
*eicar* | ||
|
||
# response.json | ||
response.json | ||
|
||
# coverage report | ||
coverage_html_report/ |
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 |
---|---|---|
@@ -1,30 +1,41 @@ | ||
repos: | ||
|
||
- repo: https://github.com/ambv/black | ||
rev: stable | ||
rev: 23.12.1 | ||
hooks: | ||
- id: black | ||
language_version: python3.7 | ||
language_version: python3.12 | ||
exclude: > | ||
(?x)^( | ||
scripts/gen-docs-index| | ||
)$ | ||
- repo: git://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.2.3 | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: check-ast | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: check-yaml | ||
exclude: deploy/ | ||
- id: debug-statements | ||
- id: detect-private-key | ||
- id: fix-encoding-pragma | ||
- id: flake8 | ||
- id: trailing-whitespace | ||
|
||
- repo: git://github.com/igorshubovych/markdownlint-cli | ||
rev: v0.17.0 | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 7.0.0 | ||
hooks: | ||
- id: flake8 | ||
|
||
- repo: https://github.com/igorshubovych/markdownlint-cli | ||
rev: v0.38.0 | ||
hooks: | ||
- id: markdownlint | ||
entry: markdownlint --ignore .github/*.md | ||
|
||
- repo: https://github.com/aws-cloudformation/cfn-python-lint | ||
rev: v0.84.0 | ||
hooks: | ||
- id: cfn-python-lint | ||
files: deploy/ |
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
Oops, something went wrong.