Skip to content

Commit 767d4e2

Browse files
authored
update to latest version: v1.1.0 (#16)
1 parent c8c4ae1 commit 767d4e2

28 files changed

+1338
-529
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
1010

1111
on:
12-
push:
12+
release:
13+
types: [published]
1314

1415
permissions:
1516
contents: read
@@ -34,7 +35,7 @@ jobs:
3435
3536
- name: Build a binary wheel and a source tarball
3637
run: >-
37-
make -f ./tools/Makefile build
38+
make build
3839
3940
- name: tox
4041
run: >-

.github/workflows/unit-test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: unittest
2+
on:
3+
pull_request:
4+
branches:
5+
- "main"
6+
7+
jobs:
8+
unit-test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
12+
- uses: actions/checkout@v3
13+
14+
# Set up python 3.9
15+
- name: Prepare python env
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: "3.9"
19+
20+
# Install pipenv
21+
- name: Install pipenv
22+
run: pip install pipenv
23+
24+
# Pack and publish Python SDK
25+
- name: Exec py client unit test
26+
run: make test

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# general things to ignore
2+
build/
3+
dist/
4+
*.egg-info/
5+
*.egg
6+
*.py[cod]
7+
__pycache__/
8+
*.so
9+
*~
10+
11+
# due to using tox and pytest
12+
.tox
13+
.cache

CHANGELOG.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
# CHANGELOG
22

3+
## 1.1.0 - 2024-04-03
4+
5+
* Update protos
6+
* Enable PML (Predictive Machine Learning) detection and smart feedback
7+
* Enable bulk mode
8+
* Enable India region
9+
* Support for scanning large files (over 2GB)
10+
11+
## 1.0.5 - 2023-12-28
12+
13+
* fix linting issues
14+
315
## 1.0.4 - 2023-05-18
16+
417
* set default timeout_in_seconds to 180 seconds
518

619
## 1.0.3 - 2023-05-10
20+
721
* Change LICENSE
822

923
## 1.0.2 - 2023-05-10
24+
1025
* Change README.md
1126

1227
## 1.0.1 - 2023-05-04
28+
1329
* Add scan_buffer() function
14-
30+
1531
## 1.0.0 - 2023-05-01
16-
* Initial release
32+
33+
* Initial release

tools/Makefile renamed to Makefile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
# ROOT_DIR := $(abspath ../../)
2-
# include $(ROOT_DIR)/build-scripts/variables.mk
3-
41
PIPY_URL ?= https://upload.pypi.org/legacy/
52
TOKEN ?=
3+
VERSION := $(shell cat VERSION | tr -d '\n')
64

7-
build: clean
5+
proto:
86
pipenv sync --dev
9-
pipenv run python -m grpc_tools.protoc -Iamaas/grpc/protos=./amaas/protos \
7+
pipenv run python -m grpc_tools.protoc -Iamaas/grpc/protos=./protos \
108
--python_out=. \
119
--pyi_out=. \
1210
--grpc_python_out=. \
13-
./amaas/protos/scan.proto
11+
./protos/scan.proto
12+
13+
build: proto
1414
pipenv run pipenv-setup sync
1515
pipenv run python setup.py sdist bdist_wheel
1616

17+
test: proto
18+
pipenv run pytest tests
19+
1720
upload:
18-
#pipenv run twine upload ./dist/*.whl
1921
pipenv run twine upload --repository-url $(PIPY_URL) -u __token__ -p $(TOKEN) ./dist/*.whl --skip-existing
2022

2123
clean:
22-
@rm -rf dist build amaas/*.egg-info amaas/grpc/protos/
24+
@rm -rf dist build *.egg-info amaas/grpc/protos/

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Cloud One VSAPI Python Client
2-
Copyright 2023 Trend Micro Inc.
2+
Copyright 2023 Trend Micro Inc.

Pipfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ pytest = "~=7.1"
1414
twine = "~=4.0"
1515
pipenv-setup = "~=3.2"
1616
vistir = "==0.6.1"
17-
autopep8 = "~=2.0"
17+
pytest-mock = "~=3.11"
18+
pytest-asyncio = "~=0.21"
1819

1920
[requires]
2021
python_version = "3"

Pipfile.lock

Lines changed: 391 additions & 330 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Install the File Security SDK package with pip:
2020

2121
## Obtain an API Key
2222

23-
The File Security SDK requires a valid API Key provided as parameter to the SDK client object. It can accept Trend Vision One API keys.
23+
The File Security SDK requires a valid API Key provided as parameter to the SDK client object. It can accept Trend Vision One API keys.
2424

2525
When obtaining the API Key, ensure that the API Key is associated with the region that you plan to use. It is important to note that Trend Vision One API Keys are associated with different regions, please refer to the region flag below to obtain a better understanding of the valid regions associated with the respective API Key.
2626

@@ -29,9 +29,9 @@ If you plan on using a Trend Vision One region, be sure to pass in region parame
2929
1. Login to the Trend Vision One.
3030
2. Create a new Trend Vision One API key:
3131

32-
* Navigate to the Trend Vision One User Roles page.
33-
* Verify that there is a role with the "Run file scan via SDK" permissions enabled. If not, create a role by clicking on "Add Role" and "Save" once finished.
34-
* Directly configure a new key on the Trend Vision One API Keys page, using the role which contains the "Run file scan via SDK" permission. It is advised to set an expiry time for the API key and make a record of it for future reference.
32+
- Navigate to the Trend Vision One User Roles page.
33+
- Verify that there is a role with the "Run file scan via SDK" permissions enabled. If not, create a role by clicking on "Add Role" and "Save" once finished.
34+
- Directly configure a new key on the Trend Vision One API Keys page, using the role which contains the "Run file scan via SDK" permission. It is advised to set an expiry time for the API key and make a record of it for future reference.
3535

3636
## Run SDK
3737

@@ -52,12 +52,14 @@ If you plan on using a Trend Vision One region, be sure to pass in region parame
5252

5353
3. Current Python examples support following command line arguments
5454

55-
| Command Line Arguments | Value | Optional |
56-
| :------------------ | :----------------------- | :------- |
57-
| --region or -r | The region you obtained your API key. Value provided must be one of the Vision One regions, e.g. `us-east-1`, `eu-central-1`, `ap-southeast-1`, `ap-southeast-2`, `ap-northeast-1` | Yes, either -r or -a |
58-
| --addr or -a | Trend Vision One File Security server, such as: antimalware.__REGION__.cloudone.trendmicro.com:443 | Yes, either -r or -a |
59-
| --api_key | Vision One API Key | No |
60-
| --filename or -f | File to be scanned | No |
55+
| Command Line Arguments | Value | Optional |
56+
|------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------|
57+
| --region or -r | The region you obtained your API key. Value provided must be one of the Vision One regions, e.g. `us-east-1`, `eu-central-1`, `ap-southeast-1`, `ap-southeast-2`, `ap-northeast-1` | Yes, either -r or -a |
58+
| --addr or -a | Trend Vision One File Security server, such as: antimalware.__REGION__.cloudone.trendmicro.com:443 | Yes, either -r or -a |
59+
| --api_key | Vision One API Key | No |
60+
| --filename or -f | File to be scanned | No |
61+
| --pml | Predictive Machine Learning | Yes |
62+
| --tags or -f | List of tags | Yes |
6163

6264
4. Run one of the examples.
6365

@@ -82,46 +84,3 @@ If you plan on using a Trend Vision One region, be sure to pass in region parame
8284
```sh
8385
python3 client_aio.py -f FILENAME -a antimalware._REGION_.cloudone.trendmicro.com:443 --tls true --api_key API_KEY
8486
```
85-
86-
### Code Examples
87-
88-
```python
89-
import json
90-
import amaas.grpc
91-
92-
handle = amaas.grpc.init(YOUR_FILE_SECURITY_SERVER, YOUR_VISION_ONE_KEY, True)
93-
94-
result = amaas.grpc.scan_file(args.filename, handle)
95-
print(result)
96-
97-
result_json = json.loads(result)
98-
print("Got scan result: %d" % result_json['scanResult'])
99-
100-
amaas.grpc.quit(handle)
101-
102-
```
103-
104-
to use asyncio with coroutines and tasks,
105-
106-
```python:
107-
import json
108-
import pprint
109-
import asyncio
110-
import amaas.grpc.aio
111-
112-
async def scan_files():
113-
handle = amaas.grpc.aio.init(YOUR_FILE_SECURITY_SERVER, YOUR_VISION_ONE_KEY, True)
114-
115-
tasks = [asyncio.create_task(amaas.grpc.aio.scan_file(file_name, handle))]
116-
117-
scan_results = await asyncio.gather(*tasks)
118-
119-
for scan_result in scan_results:
120-
pprint.pprint(json.loads(scan_result))
121-
122-
await amaas.grpc.aio.quit(handle)
123-
124-
125-
asyncio.run(scan_files())
126-
127-
```

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.1.0

0 commit comments

Comments
 (0)