Skip to content

deep-security/automation-center-sdk-samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deep Security Automation Center SDK Samples

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.

Contents

Branches

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.

Run the samples

Perform the steps in the following sections to run the samples.

Download or clone this repository

Download or clone this repository to create a local copy.

Download

If you are not familiar with GitHub or Git, you can download a ZIP file that contains the repository.

  1. Click Clone or Download > Download ZIP.
  2. Unzip the archive on your file system.

Clone

  1. Click Clone or Download.
  2. Copy the repository web url for cloning with HTTPS (https://github.com/deep-security/automation-center-sdk-samples.git).
  3. Open a command line interface and change the current directory to the desired location of the local repository.
  4. Enter Git clone https://github.com/deep-security/automation-center-sdk-samples.git.

Get the SDK

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.

Run the Python samples

  1. Open a command line interface and change the current directory to the automation-center-sdk-samples directory of your local repository.

  2. Enter the following command to create a new Git branch: git checkout -b run_examples

  3. In the ./python/src folder, create a file named properties.json and save the following JSON code into it, replacing the values for url and secretkey 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.

  4. Open the ./python/src/main.py file.

  5. Replace any environment-specific values that are used as arguments for running sample modules, such as policy_id.

  6. Comment-out any print statements that you do not want to execute.

  7. Save the file

  8. In the command line interface, change the current directory to ./python/src and then enter python main.py.

Run the JavaScript samples

  1. Open a command line interface and change the current directory to the automation-center-sdk-samples directory of your local repository.

  2. Enter the following command to create a new Git branch: git checkout -b run_examples

  3. In the ./javascript folder, create a file named properties.json and save the following JSON code into it, replacing the values for url and secretkey 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.

  4. Open the ./javascript/App.js file.

  5. Replace any environment-specific values that are used as arguments for running sample modules, such as policyID.

  6. Comment-out the commands that you do not want to execute, and uncomment the commands that you want to execute.

  7. Save the file

  8. In the command line interface, change the current directory to ./javascript/ and then enter node App.js.

Run the Java samples

These instruction use Eclipse as the IDE. However, you can use another Java IDE if you prefer.

  1. Open a command line or terminal and change the current directory to the automation-center-sdk-samples directory of your local repository.

  2. Enter the following command to create a new Git branch: git checkout -b run_examples

  3. Open Eclipse and click File > Import.

  4. Select General > Projects from Folder or Archive and cick Next.

  5. Click Directory and select the java folder in your local repository.

  6. Click Finish.

  7. In the Project Explorer, right-click the project folder and click Properties.

  8. Click Java Build Path, click the Libraries tab, and then click External JARs.

  9. Go to the folder that contains the extracted Java SDK, select the deepsecurity-xx.x.xxx.jar file, and click Open.

  10. Similarly, add all of the files in the lib sub folder from the SDK.

  11. Click Apply and Close.

  12. 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.)

  13. Create a file named example.properties and add the following text into it, replacing the values for url and secretkey 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.

  14. 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.

  15. Change the values of the global variables according to your Deep Security Manager instance, such as the computerID variable.

  16. Click Run > Run As > Java Application.

Support

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.

Contribute

We accept contributions from the community. To submit changes:

  1. Fork this repository.
  2. Create a new feature branch.
  3. Make your changes.
  4. Submit a pull request with an explanation of your changes or additions.

We will review and work with you to release the code.