Athena

关于Athena程序发布

该分类用于 Athena 程序的发布,用户可以进行下载对本地环境的更新

Athena 程序暂无 release ,请等待后续的升级更新

本程序,可以通过交互式方式进行启动,也可以通过脚本运行的方式启动

交互式方式启动

➜  build./node_darwin_amd64 -i
          _   _
     /\  | | | |
    /  \ | |_| |__   ___ _ __   __ _
   / /\ \| __| '_ \ / _ \ '_ \ / _  |
  / ____ \ |_| | | |  __/ | | | (_| |
 /_/    \_\__|_| |_|\___|_| |_|\__,_|

[2020-12-31 13:42:46] DEBUG Node: 正在创建运行环境
[2020-12-31 13:42:46] DEBUG Node: 正在载入模块
[2020-12-31 13:42:46] DEBUG Node: 正在装载程序:
> http = require("http")
> resp = http.get("https://www.baidu.com")
> print(resp.code)
200
> htmlparse = require("htmlparse")
> title = htmlparse:new(resp.body):find("title"):text()
> print(title)
百度一下,你就知道

脚本方式进行启动

样例代码

local http = require("http")
local htmlparse = require("htmlparse")

-- 任务分发函数
function assign(service, params)
    if service == "test" then
        return true, params
    end
end

-- 审计函数
function audit(param)
    local resp = http.get(param)
    if resp.code == 200 then
        local title = htmlparse:new(resp.body):find("title"):str()
        print(title)
    end
end

-- 测试方法
function test()
    local checkrun, params = assign("test", "https://www.baidu.com")
    if checkrun then
        audit(params)
    end
end

运行

➜  build ./node_darwin_amd64 -f test.poc
          _   _
     /\  | | | |
    /  \ | |_| |__   ___ _ __   __ _
   / /\ \| __| '_ \ / _ \ '_ \ / _  |
  / ____ \ |_| | | |  __/ | | | (_| |
 /_/    \_\__|_| |_|\___|_| |_|\__,_|

[2021-01-01 19:08:51] DEBUG Node: 正在创建运行环境
[2021-01-01 19:08:51] DEBUG Node: 正在载入模块
[2021-01-01 19:08:51] DEBUG Node: 正在装载程序:test.poc
[2021-01-01 19:08:51] DEBUG Node: 正在运行 test 测试方法
百度一下,你就知道
[2021-01-01 19:08:51]  INFO Node: [INFO] 发送报告: 百度一下,你就知道
[2021-01-01 19:08:51] DEBUG Node: 运行时间:72.388804ms

需要注意的是,测试程序中,运行流程为 加载脚本 -> 运行test方法
一般的测试代码都是通过 test 方法进行测试