Skip to content

Commit 5c04eec

Browse files
authored
Merge pull request #10 from trendmicro/update_to_latest_version_v1.1.2
update to latest version: v1.1.2
2 parents d1f0e6a + 7514358 commit 5c04eec

File tree

4 files changed

+164
-23
lines changed

4 files changed

+164
-23
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CHANGELOG
22

3+
## 1.1.2 - 2024-04-10
4+
5+
* Update README.md
6+
* Extend default timeout to 300s
7+
38
## 1.1.1 - 2024-04-04
49

510
* Fix bug in SPN smart feedback

README.md

Lines changed: 157 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
# Trend Vision One File Security Go SDK User Guide
1+
# Trend Vision One File Security Go SDK User Guide
22

3-
The Trend Vision One File Security Go SDK empowers developers to craft applications seamlessly integrating with the cloud-based Trend Vision One anti-malware file scanning service. This ensures a thorough scan of data and artifacts within the applications, identifying potential malicious elements.
3+
Trend Vision One™ - File Security is a scanner app for files and cloud storage. This scanner can detect all types of malicious software (malware) including trojans, ransomware, spyware, and more. Based on fragments of previously seen malware, File Security detects obfuscated or polymorphic variants of malware.
4+
File Security can assess any file type or size for malware and display real-time results. With the latest file reputation and variant protection technologies backed by leading threat research, File Security automates malware scanning.
5+
File Security can also scan objects across your environment in any application, whether on-premises or in the cloud.
46

5-
This guide outlines the steps to establish your development environment and configure your project, laying the foundation for utilizing the File Security Go SDK effectively.
7+
The Go software development kit (SDK) for Trend Vision One™ File Security empowers you to craft applications which 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.
8+
Follow the steps below to set up your development environment and configure your project, laying the foundation to effectively use File Security.
69

710
## Environment
811

912
- Golang 1.19 or newer
10-
- Trend Vision One account with a chosen region - for more information, see the [Trend Vision One documentation](https://docs.trendmicro.com/en-us/enterprise/trend-micro-xdr-help/Home).
11-
- A Trend Vision One API key with proper role - for more information, see the [Trend Vision One API key documentation](https://docs.trendmicro.com/en-us/enterprise/trend-vision-one/administrative-setti/accountspartfoundati/api-keys.aspx).
13+
- Trend Vision One account with a chosen region - for more information, see the [Trend Vision One documentation](https://docs.trendmicro.com/en-us/documentation/article/trend-vision-one-trend-micro-xdr-abou_001).
14+
- A Trend Vision One API key with proper role - for more information, see the [Trend Vision One API key documentation](https://docs.trendmicro.com/en-us/documentation/article/trend-vision-one-api-keys).
1215

1316
## Installation
1417

1518
To integrate with our service using the Golang SDK, you need to import the SDK package into your project. Here are the installation steps:
19+
1620
1. Open your Go project or create a new one if you haven't already.
1721
2. Import the SDK package into your project by adding the following import statement:
1822

@@ -42,9 +46,9 @@ If you plan on using a Trend Vision One region, be sure to pass in region parame
4246
1. Login to the Trend Vision One.
4347
2. Create a new Trend Vision One API key:
4448

45-
* Navigate to the Trend Vision One User Roles page.
46-
* 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.
47-
* 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.
49+
- Navigate to the Trend Vision One User Roles page.
50+
- 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.
51+
- 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.
4852

4953
## Initialization
5054

@@ -60,14 +64,8 @@ if err != nil {
6064
panic(err)
6165
}
6266
```
63-
Replace "YOUR_API_KEY_OR_TOKEN" and "YOUR_REGION" with your actual API key or token and the desired region.
64-
65-
**_Parameters_**
6667
67-
| Parameter | Description |
68-
|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
69-
| region | 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-northeast-1`, `ap-southeast-2`, `ap-southeast-1`, `ap-south-1`, etc. |
70-
| apikey | Your own Vision One API Key. |
68+
Replace "YOUR_API_KEY_OR_TOKEN" and "YOUR_REGION" with your actual API key or token and the desired region.
7169
7270
## Basic Usage
7371
@@ -105,6 +103,7 @@ if err != nil {
105103
```
106104
107105
**_Note_**
106+
108107
- Max number of tags is 8. And the length of each tag can't exceed 63.
109108

110109
## Additional Functions
@@ -144,7 +143,120 @@ You can enable SPN feedback by calling the `SetFeedbackEnable` function:
144143
client.SetFeedbackEnable()
145144
```
146145

146+
## Golang Client SDK API Reference
147+
148+
### ```func NewClient(key string, region string) (c *AmaasClient, e error)```
149+
150+
Creates a new instance of the client object, and provisions essential settings, including authentication/authorization credentials (API key), preferred service region, etc.
151+
152+
**_Parameters_**
153+
154+
| Parameter | Description |
155+
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
156+
| key (string) | A valid API key must be provided if the environment variable `TM_AM_AUTH_KEY` is not set. |
157+
| region (string) | The region you obtained your api key. Value provided must be one of the Vision One regions: `us-east-1`, `eu-central-1`, `ap-southeast-1`, `ap-southeast-2`, `ap-northeast-1`, `ap-south-1` |
158+
159+
**_Return values_**
160+
161+
| Parameter | Description |
162+
|------------------|-------------------------------------------------------|
163+
| c (*AmaasClient) | Pointer to an client object. Nil if error encountered |
164+
| e (error) | Nil if no error encountered; non-nil otherwise. |
165+
166+
**_Errors Conditions_**
167+
168+
- Invalid authentication
169+
- Invalid region
170+
171+
---
172+
173+
### ```func (ac *AmaasClient) ScanFile(filePath string, tags []string) (resp string, e error)```
174+
175+
### ```func (ac *AmaasClient) ScanBuffer(buffer []byte, identifier string, tags []string) (resp string, e error)```
176+
177+
Submit content of a file or buffer to be scanned.
178+
179+
**_Parameters_**
180+
181+
| Parameter | Description |
182+
|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
183+
| filePath (string) | Path of the file to scan |
184+
| buffer ([]byte) | Buffer containing the data to scan |
185+
| identifier (string) | A caller-chosen string to associate with the scan that will be returned in JSON response as part of `fileName` name/value; can be empty |
186+
| tags ([]string) | Tags to be used for scanning |
187+
188+
**_Return values_**
189+
190+
| Parameter | Description |
191+
|---------------|----------------------------------------------------|
192+
| resp (string) | JSON-formatted response describing the scan result |
193+
| e (error) | Nil if no error encountered; non-nil otherwise. |
194+
195+
**_Sample JSON response_**
196+
197+
```json
198+
{
199+
"scannerVersion":"1.0.0-27",
200+
"schemaVersion":"1.0.0",
201+
"scanResult": 1,
202+
"scanId": "25072030425f4f4d68953177d0628d0b",
203+
"scanTimestamp": "2022-11-02T00:55:31Z",
204+
"fileName": "EICAR_TEST_FILE-1.exe",
205+
"filePath": "AmspBvtTestSamples/BVT_RightClickScan_DS/unclean/EICAR_TEST_FILE-1.exe",
206+
"foundMalwares": [
207+
{
208+
"fileName": "Eicar.exe",
209+
"malwareName": "Eicar_test_file"
210+
}
211+
],
212+
"fileSHA1":"fc7042d1d8bbe655ab950355f86a81ded9ee4903",
213+
"fileSHA256":"1b9f8773919a1770fec35e2988650fde3adaae81a3ac2ad77b67cafd013afcdc"
214+
}
215+
```
216+
217+
When malicious content is detected in the scanned object, `scanResult` will show a non-zero value. Otherwise, the value will be `0`. Moreover, when malware is detected, `foundMalwares` will be non-empty containing one or more name/value pairs of `fileName` and `malwareName`. `fileName` will be filename of malware detected while `malwareName` will be the name of the virus/malware found.
218+
219+
**_Errors Conditions_**
220+
221+
- Invalid authentication
222+
- Invalid path specified
223+
- Request timed out (deadline exceeded)
224+
- Incompatible client used
225+
- Service unreachable
226+
- Client not ready for operation
227+
228+
---
229+
230+
### ```func (ac *AmaasClient) Destroy()```
231+
232+
Frees up internal resources used by client. It should only be invoked after one has finished scanning and no longer needs the client object.
233+
234+
---
235+
236+
### ```func SetLoggingLevel(level LogLevel)```
237+
238+
For configuring the SDK's active logging level. The change is applied globally to all client instances. Default level is `LogLevelOff`, corresponding to all logging disabled. If logging is enabled, unless custom logging is configured using `ConfigLoggingCallback()` logs will be written to stdout.
239+
240+
**_Parameters_**
241+
242+
| Parameter | Description |
243+
|------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
244+
| level (LogLevel) | Valid values are LogLevelOff, LogLevelFatal, LogLevelError, LogLevelWarning, LogLevelInfo, and LogLevelDebug; default level is LogLevelOff |
245+
246+
---
247+
248+
### ```func ConfigLoggingCallback(f func(level LogLevel, levelStr string, format string, a ...interface{}))```
249+
250+
For setting up custom logging by provisioning the SDK with a custom callback function that is invoked whether the SDK wants to record a log.
251+
252+
**_Parameters_**
253+
254+
| Parameter | Description |
255+
|--------------|--------------------------------------------------------------------------------------------------------|
256+
| f (function) | A function with the prototype `func(level LogLevel, levelStr string, format string, a ...interface{})` |
257+
147258
## Usage Examples
259+
148260
As examples, you can find two important files in the `tools/` directory of the SDK package:
149261
150262
`client.go`: This file contains the main client initialization logic and functions for scanning a single file.
@@ -156,13 +268,14 @@ You can refer to these files for a deeper understanding of how to integrate and
156268
## Usage Instructions for File Security SDK Programs
157269
158270
### Prerequisites
271+
159272
Build the client tools requires the following:
160273
Execute `make build` in the root directory to build the client tools.
161274
162275
The build process will produce the following inside the `tools/` directory:
163276
164-
* client
165-
* scanfiles
277+
- client
278+
- scanfiles
166279
167280
### client
168281
@@ -173,7 +286,7 @@ This program is located in the `tools/` folder. It supports the gRPC-based serve
173286
The following flags are supported:
174287
175288
`-tls`
176-
Specify to enable server authentication by client for gRPC
289+
Specify to enable server authentication by client for gRPC. TLS should always be enabled when connecting to the File Security service. For more information, see the 'Ensuring Secure Communication with TLS' section.
177290
178291
`-region <string>`
179292
Specify the region to connect to for gRPC
@@ -214,7 +327,7 @@ Specify if scanning good/non-malicious files.
214327
Specify if scanning of multiple files should be carried out simultaneously instead of sequentially.
215328
216329
`-tls`
217-
Specify to enable server authentication by client for gRPC
330+
Specify to enable server authentication by client for gRPC. TLS should always be enabled when connecting to the File Security service. For more information, see the 'Ensuring Secure Communication with TLS' section.
218331
219332
`-region <string>`
220333
Specify the region to connect to for gRPC
@@ -234,15 +347,38 @@ Specify to enable SPN feedback
234347
`-tag <string>`
235348
Specify the tags to be used for scanning, separated by commas
236349
237-
238350
## Proxy Configuration
239351
240352
The cli tool loads the proxy configuration from the following set of optional environment variables
241353
242354
| Environment Variable | Required/Optional | Description |
243355
|----------------------|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
244356
| `NO_PROXY` | Optional | Add the endpoints to the comma-separated list of host names if you want to skip proxy settings. Note: only an asterisk, '\*' matches all hosts |
245-
| `HTTP_PROXY ` | Optional | `http://proxy.example.com` |
357+
| `HTTP_PROXY` | Optional | `http://proxy.example.com` |
246358
| `HTTPS_PROXY` | Optional | `https://proxy.example.com`<br><br>If the proxy server is a SOCKS5 proxy, you must specify the SOCKS5 protocol in the URL as `socks5://socks_proxy.example.com` |
247359
| `PROXY_USER` | Optional | Optional username for authentication header used in `Proxy-Authorization` |
248360
| `PROXY_PASS` | Optional | Optional password for authentication header used in `Proxy-Authorization`, used only when `PROXY_USER` is configured |
361+
362+
## Environment Variables
363+
364+
The following environment variables are supported by Golang Client SDK and can be used in lieu of values specified as function arguments.
365+
366+
For example, the API key can be specified using the `TM_AM_AUTH_KEY` environment variable instead of hardcoded into the application.
367+
368+
| Variable Name | Description & Purpose | Valid Values |
369+
|---------------------------|-----------------------------------------------------------------------------|----------------------------|
370+
| `TM_AM_SCAN_TIMEOUT_SECS` | Specify, in number of seconds, to override the default scan timeout period | 0, 1, 2, ... ; default=300 |
371+
| `TM_AM_AUTH_KEY` | Can be used to specify the authorization key; overrides function call value | empty or string |
372+
373+
## Thread Safety
374+
375+
- ScanFile() or ScanBuffer() are designed to be thread-safe. It should be able to invoke ScanFile() concurrently from multiple threads without protecting ScanFile() with mutex or other synchronization mechanisms.
376+
377+
- The Destroy() method is NOT thread-safe, so it should only be called upon completion of all the scan routines.
378+
379+
## Ensuring Secure Communication with TLS
380+
381+
The communication channel between the client program or SDK and the Trend Vision One™ File Security service is fortified with robust server-side TLS encryption. This ensures that all data transmitted between the client and Trend service remains thoroughly encrypted and safeguarded.
382+
The certificate employed by server-side TLS is a publicly-signed certificate from Trend Micro Inc, issued by a trusted Certificate Authority (CA), further bolstering security measures.
383+
384+
The File Security SDK consistently adopts TLS as the default communication channel, prioritizing security at all times. It is strongly advised not to disable TLS in a production environment while utilizing the File Security SDK, as doing so could compromise the integrity and confidentiality of transmitted data.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
1.1.2

sdk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
const (
1111
_defaultCommPort = 443 // Port used by AMaaS Client to communicate with server.
12-
_defaultTimeoutSecs = 180 // 3 minutes
12+
_defaultTimeoutSecs = 300 // 5 minutes
1313
)
1414

1515
const (

0 commit comments

Comments
 (0)