Use the Trend Vision One™ File Security Python SDK to scan files for malware.
The Python SDK for Trend Vision One™ File Security empowers you to craft applications
that seamlessly integrate with File Security. With this SDK you can perform a
thorough scan of data and artifacts within your applications to identify potential
malicious elements.
Follow the steps below to set up your development environment and configure your
project, laying the foundation to effectively use File Security.
Checking prerequisites
Before installing the SDK, ensure you have the following:
-
Trend Vision One account associated with your region
-
Configuring custom user roles with File Security permissions
Creating an API key
The File Security SDK requires a valid API key provided as a parameter to the SDK
client object. Trend Vision One API keys are associated with different regions.
Refer to the region flag below to obtain a better understanding of the valid
regions associated with the API key.
Procedure
- Go to .
- Click Add API Key.
- Configure the API key to use the role with the Run file scan via SDK permission.
- Verify that the API key is associated with the region you plan to use.
- Set an expiry time for the API key and make a record of it for future reference.
Installing the SDK
Procedure
- Install the File Security SDK package with pip:
python -m pip install visionone-filesecurity
Running the SDK
Procedure
- Go to the Examples folder in GitHub.
- Review the Python examples in the folder:
-
The
client_aio.py
example uses regular file input/output (i/o). -
The
client.py
example uses asynchronous i/o.
The Python examples support the command line arguments in the table below.Python Examples
Command Line Arguments Value Optional --region or -r
The region for your API key. Value must be one of the Vision One regions: ap-northeast-1
ap-south-1
ap-southeast-1
ap-southeast-2
eu-central-1
us-east-1
Yes, either -r
or-a
--addr or -a
File Security server, for example: antimalware.REGION.cloudone.trendmicro.com:443
Yes, either -r
or-a
--api_key
Trend Vision One API key No --filename or -f
File to be scanned No --pml
Predictive Machine Learning Yes --tags or -f
List of tags Yes -
- Run one of the examples. You can also use these examples to write your own program.
Customizing the Examples
You can customize one of the example programs by configuring it
with the API key. For custom programs, pass
in the region parameter to specify the region of the API key and verify you have
the proper authorization.
Procedure
- Assign the value of the
API_KEY
to the variable. - Set
FILENAME
to the desired target file.python3 client.py -f FILENAME -r us-1 --api_key API_KEY
You can use the File Security server address-a
instead of region-r
.python3 client.py -f FILENAME -a antimalware._REGION_.cloudone.trendmicro.com:443 --api_key API_KEY
You can also use the asynchronous IO example program.python3 client_aio.py -f FILENAME -a antimalware._REGION_.cloudone.trendmicro.com:443 --api_key API_KEY