RobotFrameWork with Eclipse - SSHLibrary 似乎没有做任何事情。 (基于书籍:实用安全自动化和测试)

RobotFrameWork with Eclipse - SSHLibrary doesn't seem to do anything. (based on book: Practical Security Automation and Testing)

我正在学习这本书:Practical Security Autmation and testing。 在第 [124] 页上有一个将 RIDE 与 SSHLibrary 结合使用的脚本。

但是我正在使用 Eclipse,所以我尝试安装它。

pip 安装轮

pip install --upgrade robotframework-sshlibrary

成功了,现在您可以开始编辑 .robot 脚本了。

我做到了这一点:(所以它与书本不同,但这适用于 Eclipse)

*** Settings ***
Library  SSHLibrary
*** Variables ***
${HOST_URL}  http://demo.testfire.net
${output}=  Execute Command  python sqlmap.py -u ${HOST_URL} --batch --banner

*** Test Cases ***
SQL Injection Testing
  Should Not Contain  ${output}  vulnerable

现在的问题是:它说 'passed' 但是当我改变某些东西的 host_url 时我确定它应该失败它也说 'passed'。 换句话说:它似乎没有检查或做任何事情。

我不知道我做错了什么。需要帮助。

您根本没有执行命令 - 无法在变量部分调用关键字。这条线在这里

*** Variables ***
${HOST_URL}  http://demo.testfire.net
${output}=  Execute Command  python sqlmap.py -u ${HOST_URL} --batch --banner

只会创建一个包含该内容的字符串变量。将它移到案例中(或在它自己的关键字中)

*** Test Cases ***
SQL Injection Testing
    ${output}=  Execute Command  python sqlmap.py -u ${HOST_URL} --batch --banner
    Should Not Contain  ${output}  vulnerable

我混合了第 124 页和第 126 页的内容(书籍:实用安全自动化和测试)

第126页有错误,乘坐图片上的代码实际上是RBFW的代码。

这是它没有错误的结果:

*** Settings ***
Library  SSHLibrary
Library  Collections
Library  String
Library  RequestsLibrary
Library  OperatingSystem

*** Variables ***
${HOST_URL}  http://demo.testfire.net
${url}  http://demo.testfire.net
${SpiderScan}  http://localhost:8090/JSON/spider/action/scan/?zapapiformat=JSON&formatMethod=GETurl=${url}&maxChildren=&recurse=&ontextName=&subtreeOnly=

*** Test Cases ***
SQL Injection Testing
  Get Connection    host=http://demo.testfire.net
  ${output}=  Execute Command  python sqlmap.py -u ${HOST_URL} --batch --banner
  Should Not Contain  ${output}  vulnerable
  

ZAP Spider Scan
  [Tags]  get skip
  Create session   ZAP  ${SpiderScan}
  ${resp}=    Get Request     ZAP   /
  Should Be Equal As Strings    ${resp.status_code}    200