【发布时间】:2021-12-07 18:40:04
【问题描述】:
多年来,我一直在使用 REST API(作为消费者和开发人员),并且刚刚开始第一次使用 GraphQL API,具体来说,BurpSuite's Enterprise GraphQL API。我喜欢它,但我肯定遗漏了一些关键概念。
我正在尝试访问他们的GetScan 端点:
curl -k -i -H "Content-Type: application/json" -H "Authorization: <MY_API_KEY>" -X GET -d '{ "query": "query GetScan ($id: ID!) { scan(id: $id) { id status agent { id name } site_application_logins { login_credentials { label username } recorded_logins { label } } audit_items { id issue_counts { total } number_of_requests } scan_configurations { id name } } }"}' 'https://mybsee.example.com/graphql/v1'
为了便于阅读,graphql 查询也是:
query GetScan ($id: ID!) {
scan(id: $id) {
id status
agent { id name }
site_application_logins {
login_credentials { label username }
recorded_logins { label }
}
audit_items {
id
issue_counts { total }
number_of_requests
}
scan_configurations { id name }
}
},
variables {
$agent: "Firefox"
}
<MY_API_KEY> 以上在我运行时具有实际价值(显然,我不能在此处发布)。与 URL 相同(我有一个 BurpSuite 的本地版本正在运行,例如 mybsee.example.com)。
当我运行 curl 时,我得到以下输出:
About to execute: query GetScan ($id: ID!) { scan(id: $id) { id status agent { id name } site_application_logins { login_credentials { label username } recorded_logins { label } } audit_items { id issue_counts { total } number_of_requests } scan_configurations { id name } } }
HTTP/2 200
date: Wed, 20 Oct 2021 23:33:50 GMT
x-frame-options: DENY
<lots of response headers omitted>
{"errors":[{"message":"Unexpected exception occurred. Check logs for more details.","extensions":{"code":77}}]}
我无权访问服务器日志,因此我试图排除客户端的问题(我对GetScan 的调用不正确)。有人觉得有什么不对吗?我是否应该向查询中的任何字段注入值,例如id 或status 等?如果是这样,我如何(具体地)将查询更改为有效?我也不确定是否需要将"query" JSON 字段名称附加到实际查询中。
感谢您在此提供的所有帮助。
更新
我确实意识到这不是一个完美可以回答的问题,因为不幸的是 BurpSuite API 是专有的,除非您购买产品或经历大量 rigamarole,否则您无法从他们那里获得 API 密钥获得免费试用许可证。
但更重要的是,我不是在这里寻找任何人来钓鱼,我希望有人可以教我如何钓鱼。实际上,除了这个之外,我还需要与更多 GraphQL 端点集成,但如果有人能告诉我构造一个查询的正确方法,我可以从那里获取。
【问题讨论】:
-
你错过了
-H "Authorization:结尾处的双引号。 -
感谢@chicks (+1) 这是我的复制粘贴错误;现在修好了!
-
我在您的查询中没有看到任何变量。你在哪里传递特定的 id?
-
(顺便说一句,将 graphql 查询格式化为多行正确缩进的文本会使其更易于阅读)。
-
不过,基本上:
GetScan需要提供一个id作为参数——ID!中的!表示这是强制性的。