Service Virtualization

  • 1.  How to execute a ".sh" file from SSH step where the shell script should accept the variables from project.config

    Broadcom Employee
    Posted Nov 21, 2017 01:54 PM

    Hi ,

     

     

    I have a groovy script, refer below for groovy script content:

     

     

    import com.***;

      

    // Enter core server IP address

    String coreServerIpAddress = System.getProperty("core.server.url");

      

    private ReferenceDataServiceCover refSrv = null;

     


    refSrv = new ReferenceDataServiceCover(coreServerIpAddress);

      

    long versionId = Long.valueOf(args[1]);

    String source = args[2];

    String url = args[3];

    String description = args[4];

    double score = Double.valueOf(args[5]);

    String severity = args[6];

      

    println("versionId: " + versionId);

    println("source: " + source);

    println("url: " + url);

    println("description: " + description);

    println("score: " + score);

    println("severity: " + severity);

      

      

    if (refSrv == null) {

    throw new Exception("Unable to initialize app instance at: ${Url}");

    }

      

    if (refSrv != null) {

     


    try {

    long vulnId=refSrv.createVulnerability(versionId, source, url, description,

    score, severity)

    println("Sucessfully created/updated vulnerability."+vulnId);

    } catch (Exception e) {

    e.printStackTrace();

    println("Unable to create vulnerability.");

    }

     


    }

    ========================


    Create a .sh file with following content


    #!/bin/bash

    PAL_JAVA_HOME=/opt/java/jdk1.8.0_151

      

    #!/bin/bash

    export PAL_JAVA_HOME

      

    #!/bin/bash

    cd /root/VulScriptRunner/scriptRunner/scripts

      

    #!/bin/bash

    ../bin/scriptRunner.sh -c http://server/ -u ahmmo05 securitynotifications/createVulnerability.groovy DEV $1 $2 $3 $4 $5 $

     


    Create 6 variables that accept the above 6 arguments in project.confih


    create SSH step > add host details > In SSH command enter following:

     

     

    ./createNewVulnerabilities.sh {{VersionID}} {{VulName}} {{URL}} {{Description}} {{Score}} {{Severity}}

     


    This throws number format exception

     

     

    It works if we pass SSH command as :

    ./createNewVulnerabilities..sh "3058290" "test_javaxvul1" "javaxurl" "javaxdesc" "0.0" "high"


    Please do suggest a solution

     

     

    Regards


    Irfan



  • 2.  Re: How to execute a ".sh" file from SSH step where the shell script should accept the variables from project.config

    Posted Nov 21, 2017 04:57 PM

    Hi,

       Can you try this one

    ./createNewVulnerabilities.sh "{{VersionID}}"  "{{VulName}}" "{{URL}}" "{{Description}}" "{{Score}}" "{{Severity}}"

    Thanks,

    Vish



  • 3.  Re: How to execute a ".sh" file from SSH step where the shell script should accept the variables from project.config

    Broadcom Employee
    Posted Nov 22, 2017 01:19 AM

    I tried it but it is not working



  • 4.  Re: How to execute a ".sh" file from SSH step where the shell script should accept the variables from project.config

    Broadcom Employee
    Posted Nov 22, 2017 02:21 AM

    Hi,

     

    How did you set the values for the properties {{VersionID}}, {{VulName}}, {{URL}}, {{Description}}, {{Score}} and {{Severity}} before the SSH Step?

     

    It is very hard to understand your explanation.

     

    I think you already got the suiteble results when you wrote SSH command line like:
    ./createNewVulnerabilities.sh "3058290" "test_javaxvul1" "javaxurl" "javaxdesc" "0.0" "high"

    But you got exception when you wrote SSH command line like:
    ./createNewVulnerabilities.sh {{VersionID}} {{VulName}} {{URL}} {{Description}} {{Score}} {{Severity}}
    or
    ./createNewVulnerabilities.sh "{{VersionID}}" "{{VulName}}" "{{URL}}" "{{Description}}" "{{Score}}" "{{Severity}}"

     

    Then it is very important that the properties {{VersionID}}, {{VulName}}, {{URL}}, {{Description}}, {{Score}} and {{Severity}} have suitable values or not.

     

    Cheers,



  • 5.  Re: How to execute a ".sh" file from SSH step where the shell script should accept the variables from project.config

    Broadcom Employee
    Posted Nov 22, 2017 02:30 AM

    Hi,

     

    Please take care that the property name is case sensitive.
    Then {{VersionID}} and {{versionID}} are defined as different properties.

     

    Cheers



  • 6.  Re: How to execute a ".sh" file from SSH step where the shell script should accept the variables from project.config
    Best Answer

    Broadcom Employee
    Posted Nov 22, 2017 03:03 AM

    Hi,

     

    During the phone call and screen sharing by skype.
    It is better to use only one property which includes the command line like:
    ./createNewVulnerabilities.sh 3058290 test_javaxvul1 javaxurl javaxdesc 0.0 high

    And you need to add the "Execute Script (JSR-223) step" before the SSH step to create the property from the properties {{VersionID}}, {{VulName}}, {{URL}}, {{Description}}, {{Score}} and {{Severity}} .

     

    Cheers,

    Yusuke