This repository contains sample code for the Trend Micro Deep Security SDK. The examples in the Automation Center guides are based on these samples. Samples for each programming language are located in the python, javascript, and java folders.
The samples in the master branch of this repository are compatible with the current version of Deep Security as a Service. They are not guaranteed to run correctly with previous versions installed on other platforms.
Note: The tenant-related examples are not supported on Deep Security as a Service, as this platform does not offer the tenant feature.
As new releases of Deep Security are released, branches are created and named according to the version of Deep Security with which they are compatible.
Perform the steps in the following sections to run the samples.
Download or clone this repository to create a local copy.
If you are not familiar with GitHub or Git, you can download a ZIP file that contains the repository.
- Click Clone or Download > Download ZIP.
- Unzip the archive on your file system.
- Click Clone or Download.
- Copy the repository web url for cloning with HTTPS (
https://github.com/deep-security/automation-center-sdk-samples.git
). - Open a command line interface and change the current directory to the desired location of the local repository.
- Enter
Git clone https://github.com/deep-security/automation-center-sdk-samples.git
.
Install the SDK and required software for the language that you are interested in. SDK download and installation instructions are on the Automation Center:
- Python
- JavaScript
- Java -- Note that if you are importing the Eclipse project that we provide in this repository, you add the SDK to your project's build path after you import the project. See the Run the Java samples section.
-
Open a command line interface and change the current directory to the
automation-center-sdk-samples
directory of your local repository. -
Enter the following command to create a new Git branch:
git checkout -b run_examples
-
In the ./python/src folder, create a file named properties.json and save the following JSON code into it, replacing the values for
url
andsecretkey
with the URL and API key for your Deep Security Manager instance:{ "url": "https://192.168.17.143:4119/api", "secretkey": "8C9AECC0-7213-5E16-8C15-C1646C128C33:PEN/DJELmA75dCVn6/vWKo4mW6dKWjJ0imW5POBObyw=" }
Note: The properties.json file is listed in the .gitignore file so it is not included in the repository. In this way, this sensitive data is not shared outside your local hard drive.
-
Open the ./python/src/main.py file.
-
Replace any environment-specific values that are used as arguments for running sample modules, such as
policy_id
. -
Comment-out any
print
statements that you do not want to execute. -
Save the file
-
In the command line interface, change the current directory to
./python/src
and then enterpython main.py
.
-
Open a command line interface and change the current directory to the
automation-center-sdk-samples
directory of your local repository. -
Enter the following command to create a new Git branch: git checkout -b run_examples
-
In the ./javascript folder, create a file named properties.json and save the following JSON code into it, replacing the values for
url
andsecretkey
with the URL and API key for your Deep Security Manager instance:{ "url": "https://192.168.17.143:4119/api", "secretkey": "8C9AECC0-7213-5E16-8C15-C1646C128C33:PEN/DJELmA75dCVn6/vWKo4mW6dKWjJ0imW5POBObyw=" }
Note: The properties.json file is listed in the .gitignore file so it is not included in the repository. In this way, this sensitive data is not shared outside your local hard drive.
-
Open the ./javascript/App.js file.
-
Replace any environment-specific values that are used as arguments for running sample modules, such as
policyID
. -
Comment-out the commands that you do not want to execute, and uncomment the commands that you want to execute.
-
Save the file
-
In the command line interface, change the current directory to
./javascript/
and then enternode App.js
.
These instruction use Eclipse as the IDE. However, you can use another Java IDE if you prefer.
-
Open a command line or terminal and change the current directory to the
automation-center-sdk-samples
directory of your local repository. -
Enter the following command to create a new Git branch:
git checkout -b run_examples
-
Open Eclipse and click File > Import.
-
Select General > Projects from Folder or Archive and cick Next.
-
Click Directory and select the
java
folder in your local repository. -
Click Finish.
-
In the Project Explorer, right-click the project folder and click Properties.
-
Click Java Build Path, click the Libraries tab, and then click External JARs.
-
Go to the folder that contains the extracted Java SDK, select the deepsecurity-xx.x.xxx.jar file, and click Open.
-
Similarly, add all of the files in the lib sub folder from the SDK.
-
Click Apply and Close.
-
Below src, right-click com/trendmicro/deepsecurity/docs/Resources and click New > File. (Depending on your version of Eclipse, you might have to click New > Other, then select General/File.)
-
Create a file named
example.properties
and add the following text into it, replacing the values forurl
andsecretkey
with the URL and API key for your Deep Security Manager instance:secretkey=2:8C9AECC0-7213-5E16-8C15-C1646C128C33:PEN/DJELmA75dCVn6/vWKo4mW6dKWjJ0imW5POBObyw= url=https://192.168.17.143:4119
Note: The example.properties file is listed in the .gitignore file so it is not included in the repository. In this way, this sensitive data is not shared outside your local hard drive.
-
Open the
src/com.trendmicro/deepsecurity/docs/RunExamples.java
file. The file contains code that runs policy-related examples. To run other examples, add similar code. -
Change the values of the global variables according to your Deep Security Manager instance, such as the
computerID
variable. -
Click Run > Run As > Java Application.
This is an Open Source community project. Project contributors may be able to help, depending on their time and availability. Please be specific about what you're trying to do, your system, and steps to reproduce the problem.
For bug reports or feature requests, please open an issue. You are welcome to contribute.
Official support from Trend Micro is not available. Individual contributors may be Trend Micro employees, but are not official support.
If you have questions about using the SDK, consider asking on Stack Overflow. Tag your question with deepsecurity
and it will get pushed to our internal automation support Slack channel.
We accept contributions from the community. To submit changes:
- Fork this repository.
- Create a new feature branch.
- Make your changes.
- Submit a pull request with an explanation of your changes or additions.
We will review and work with you to release the code.