Protection Engine for Cloud Services

 View Only
  • 1.  Issue while passing Hyge Binary Data to Scan Engine

    Posted Sep 03, 2012 10:08 PM

    Hi  all ,

     

    we have built  a java code (by refering the sample code from the installation package) to send binary data to Scan Engine . The code works fine for the data below 500KB. When i pass data above that , its failing at the command -

    Result result = streamScanRequest.finish();

     

    Below is the error stack trace :

    com.symantec.scanengine.api.ScanException: Unable to communicate with Symantec Scan Engine.
     at BusinessServices.SubProcess.Scanner.ScannerCheckForVirus.invoke(ScannerCheckForVirus.java:235)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at com.tibco.plugin.java.JavaActivity.eval(JavaActivity.java:383)
     at com.tibco.pe.plugin.Activity.eval(Activity.java:241)
     at com.tibco.pe.core.TaskImpl.eval(TaskImpl.java:574)
     at com.tibco.pe.core.Job.a(Job.java:712)
     at com.tibco.pe.core.Job.k(Job.java:501)
     at com.tibco.pe.core.JobDispatcher$JobCourier.a(JobDispatcher.java:249)
     at com.tibco.pe.core.JobDispatcher$JobCourier.run(JobDispatcher.java:200)
    Caused by: com.symantec.scanengine.api.ScanException: Unable to communicate with Symantec Scan Engine.
     at com.symantec.scanengine.api.RequestImpl.readResult1(Unknown Source)
     at com.symantec.scanengine.api.RequestImpl.finish(Unknown Source)
     at BusinessServices.SubProcess.Scanner.ScannerCheckForVirus.invoke(ScannerCheckForVirus.java:198)

     

     

    Can you please let know , is there any size limit set for the Scan Engine?  Because the code works perfectly fine for the data below 500KB. When the data is more than 500 kb , we are getting the above error. Please help me in solving this issue.

     

    Thanks,

    Sravani



  • 2.  RE: Issue while passing Hyge Binary Data to Scan Engine

    Broadcom Employee
    Posted Sep 04, 2012 12:00 PM

    Scan Engine has a hard limit of 2,000,000,000 bytes. What you are describing sounds like you need to increase a timeout in your code somewhere.



  • 3.  RE: Issue while passing Hyge Binary Data to Scan Engine

    Posted Sep 18, 2012 05:56 AM

    Hi Davis,

     

    we have set the default size in the scan engine. we have not changed anything in the default settings. The code.

     PFB the code we are using to communcate to java engine. the code is failing for the input data tha have 1060522 bytes. Can you please advice , what should be done. 

     


    byte[] binaryData = AttachmentData;
    String SCAN_OUTPUT_FILE_NAME =FileOutput;
    String scanEngineHost = scanEngineHostName;
    int scanEnginePort=scanEnginePortNumber;
    Policy scPolicy= Policy.SCANDELETE;

    ScanEngine scanEngine=null;
    Vector scanEnginesForScanning = null;
    FileOutputStream output = null;
    FileInputStream fileInputStream = null;
    File file = null;
    byte[] buffer  = new byte[4096];
    StringBuffer outputFileName = null;


    Long myTimeStamp;
    myTimeStamp = System.currentTimeMillis();


    outputFileName = new StringBuffer(SCAN_OUTPUT_FILE_NAME);
    ScanEngine.ScanEngineInfo scanEngTobeUsed = new ScanEngine.ScanEngineInfo(scanEngineHost,scanEnginePort);

    scanEnginesForScanning = new Vector();

    scanEnginesForScanning.add(scanEngTobeUsed);

    scanEngine = ScanEngine.createScanEngine(scanEnginesForScanning);

    output = new FileOutputStream(outputFileName.toString());

    StreamScanRequest streamScanRequest = null;

     

    streamScanRequest = scanEngine.createStreamScanRequest("",null,output,scPolicy);

     

    // Send the data to the scanning engine
         ByteArrayInputStream BinaryData=new ByteArrayInputStream(binaryData);

       long fileLength = BinaryData.available();
         long bytesToRead = fileLength;
       int buffCapRead = buffer.length;
       long bytesRead = 0;
       int i =1;

       FileLength=fileLength;

     

    // Read the input file and send the data to the scanning engine
       do {


       // System.out.println("Iteration :"+i);
        if (bytesToRead >= buffCapRead)
        {
         buffCapRead = buffer.length;
        }
        else
        {
         buffCapRead = (int) bytesToRead;
        }

        // Refresh data buffer.
        buffer = new byte[buffCapRead];

         bytesRead = BinaryData.read(buffer, 0, buffCapRead);

        // Send the bytes to scan engine
        streamScanRequest.send(buffer);
       bytesToRead = bytesToRead - bytesRead;
       i=i+1;

        } while (bytesToRead > 0);

     

       if(fileLength >0)
       {
       // Getting the result of the scanning for virus
    Thread.sleep(50000);
        
       Result result = streamScanRequest.finish();


        //Check if the Scan is complete and the result is clean. Return true.
        if((result != null && result.getStatus().compareTo(ResultStatus.CLEAN)==0))
        {
        virusFlag = true;
        }
        else
        {
         if(result == null || result.getStatus().compareTo(ResultStatus.INFECTED_REPLACED)==0 ||
           result.getStatus().compareTo(ResultStatus.INFECTED_UNREPAIRED)==0)
           {
          virusFlag = false;
           }
         else{

          //System.out.println("Could not Scan");
          }
        }
    }

    output.close();
    File myOutputFile = new File(outputFileName.toString());
    myOutputFile.delete();


    }
    catch (ScanException e)
    {
    StringWriter sw = new StringWriter();
    new Throwable(e).printStackTrace(new PrintWriter(sw));
    ErrorStack = sw.toString();
    ErrorMessage = e.getMessage();
    }


    catch (Exception g)
    {
    StringWriter sw = new StringWriter();
    new Throwable(g).printStackTrace(new PrintWriter(sw));
    ErrorStack = sw.toString();
    ErrorMessage = g.getMessage();
    }


    //return virusFlag;

    }

    }



  • 4.  RE: Issue while passing Hyge Binary Data to Scan Engine

    Broadcom Employee
    Posted Sep 18, 2012 01:07 PM

    The example files we provide are examples only, not for use in production. The timeouts in that code are very low and should be increased.

     

    Also, make sure that you are using the SDL for 5.2.11 or later, as we had a known issue documented here:

     

    http://www.symantec.com/docs/TECH153635



  • 5.  RE: Issue while passing Hyge Binary Data to Scan Engine

    Posted Sep 19, 2012 04:54 AM
      |   view attached

    Hello Davis,

    The files are scanning are fairely small. The version of Symantec Scan Engine we are using is 5.2.13. We are also using the the SymJavaAPI.jar which came with the installation.

     

    We have gone through the Java DOC api, and was not able to find out an API call to increase the Timeout (setTimeOut() method for example)

    The documentation state the socketTimeout can be increased in the console (image attached), and we are not able to see SocketTimeOut under

    /configuration/resources/System/SocketTimeOut.

     

    Can you help us increase the timeout value and point to the right place where we could do the same. 

     



  • 6.  RE: Issue while passing Hyge Binary Data to Scan Engine

    Broadcom Employee
    Posted Sep 19, 2012 11:57 AM

    This is not a timeout in Scan Engine. You need to adjust the timeout in your code so it waits longer for Scan Engine to give its verdict.



  • 7.  RE: Issue while passing Hyge Binary Data to Scan Engine

    Posted Sep 19, 2012 11:58 PM

    Hey Davis ,,

     

    Can you please let us know , where exactly do we need to adjust the timeout in the code and how to do that.

    Do we need to increase the time in the Thread.sleep() here?

     

    Please let us know , where to increase the time out.

    Thanks,

    Sravani.



  • 8.  RE: Issue while passing Hyge Binary Data to Scan Engine

    Broadcom Employee
    Posted Sep 20, 2012 11:14 AM

    I am not a developer and I have no idea how to write software.



  • 9.  RE: Issue while passing Hyge Binary Data to Scan Engine

    Posted Sep 20, 2012 11:59 AM
      |   view attached

    The example code is provided as an example only and is only intended to demonstrate not for incorperation into your custom connector. Technical Support has limited ablity to provide support for the SDK. If please refer to the SDK guide for addtional details on use of the SDK. Which I have attached.

     

    Attachment(s)