如何在Graphql中获取特定的安全咨询信息库

时间:2019-11-19 10:34:12

标签: api github graphql github-api

I have Tried

我已经尝试过此代码

`# Type queries into this side of the screen, and you will 
# see intelligent typeaheads aware of the current GraphQL type schema, 
# live syntax, and validation errors highlighted within the text.

# We'll get you started with a simple query showing your username!


query {
  securityAdvisories(orderBy: {field: PUBLISHED_AT, direction: DESC}, first: 2) {
    nodes {
      description
      ghsaId
      summary
      publishedAt
    }
  }
}

并得到以下答复

{
  "data": {
    "securityAdvisories": {
      "nodes": [
        {
          "description": "In Symfony before 2.7.51, 2.8.x before 2.8.50, 3.x before 3.4.26, 4.x before 4.1.12, and 4.2.x before 4.2.7, when service ids allow user input, this could allow for SQL Injection and remote code execution. This is related to symfony/dependency-injection.",
          "ghsaId": "GHSA-pgwj-prpq-jpc2",
          "summary": "Critical severity vulnerability that affects symfony/dependency-injection",
          "publishedAt": "2019-11-18T17:27:31Z"
        },
        {
          "description": "Tapestry processes assets `/assets/ctx` using classes chain `StaticFilesFilter -> AssetDispatcher -> ContextResource`, which doesn't filter the character `\\`, so attacker can perform a path traversal attack to read any files on Windows platform.",
          "ghsaId": "GHSA-89r3-rcpj-h7w6",
          "summary": "Moderate severity vulnerability that affects org.apache.tapestry:tapestry-core",
          "publishedAt": "2019-11-18T17:19:03Z"
        }
      ]
    }
  }
}

但是我想得到针对特定安全建议like this

的回复

即我要获取以下示例的特定ID的graphql响应url ID为GHSA-wmx6-vxcf-c3gr

谢谢!

1 个答案:

答案 0 :(得分:1)

最简单的方法是使用securityAdvisory()查询。

query {
securityAdvisory(ghsaId: "GHSA-wmx6-vxcf-c3gr") {
  ghsaId
  summary
    }
}

如果由于某种原因需要使用securityAdvisories()查询,只需添加一个identifier:。以下查询应获取GHSA-wmx6-vxcf-c3gr的不同条目。

query {
securityAdvisory(ghsaId: "GHSA-wmx6-vxcf-c3gr") {
  ghsaId
  summary
    }
}