Vulnerability scan sample code

Last Updated: Mar 29, 2017

Vulnerability scan

  1. public class ScanVulnTest {
  2. IAcsClient client = null;
  3. @BeforeMethod
  4. public void init() throws ClientException {
  5. // Replace them with the caller's Access Key and Access Key Secret
  6. IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", "your key", "your secret");
  7. // Initialize an IAcsClient object
  8. client = new DefaultAcsClient(profile);
  9. }
  10. private String getAppInfo() {
  11. JSONObject appInfo = new JSONObject();
  12. appInfo.put("dataType", 1);
  13. appInfo.put("data",
  14. "https://g01.alibaba-inc.com/tfscom/LB1PaMeKXXXXXX8XFXXXXXXXXXX.tfsprivate1446115983140-375");
  15. appInfo.put("md5", "ce86f08da845d0af6d9df2a958de17b0");
  16. appInfo.put("size", 1713656);
  17. appInfo.put("callbackUrl", "https://aaa.com/callback");
  18. appInfo.put("appOsType", 1);
  19. return appInfo.toJSONString();
  20. }
  21. @Test
  22. public void testScanVuln() {
  23. ScanVulnRequest request = new ScanVulnRequest();
  24. request.setExtParam("ext message - scan vuln by xidong111.");
  25. request.setAppInfo(getAppInfo());
  26. try {
  27. ScanVulnResponse response = client.getAcsResponse(request);
  28. System.out.println("error code : " + response.getErrorCode());
  29. System.out.println("error msg : " + response.getErrorMsg());
  30. Data data = response.getData();
  31. //todo
  32. } catch (Exception e) {
  33. e.printStackTrace();
  34. }
  35. }
  36. }

Vulnerability scan result query

  1. public class GetRiskDetailTest {
  2. IAcsClient client = null;
  3. @BeforeMethod
  4. public void init() throws ClientException {
  5. // Replace them with the caller's Access Key and Access Key Secret
  6. IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", "your key", "your secret");
  7. // Initialize an IAcsClient object
  8. client = new DefaultAcsClient(profile);
  9. }
  10. @Test
  11. public void test() {
  12. GetRiskDetailRequest request = new GetRiskDetailRequest(); request.setItemId("b888cd36-a5e4-4103-85d3-5ab0c330a5d3");
  13. try {
  14. GetRiskDetailResponse response = client.getAcsResponse(request);
  15. System.out.println("error code : " + response.getErrorCode());
  16. System.out.println("error msg : " + response.getErrorMsg());
  17. Data data = response.getData();
  18. //todo
  19. } catch (ServerException e) {
  20. e.printStackTrace();
  21. } catch (ClientException e) {
  22. e.printStackTrace();
  23. }
  24. }
  25. }
Thank you! We've received your feedback.