首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Jq到string过滤器

Jq到string过滤器
EN

Stack Overflow用户
提问于 2022-08-23 12:05:32
回答 1查看 96关注 0票数 0

尝试过滤来自Json的输出,到目前为止,当软件版本不存在时,当软件版本被找到时,使用的过滤器将按预期工作,jq将导致错误。基本上,如何在csv文件中转义()并返回空值。

代码语言:javascript
复制
.result [] | [ "https://vuldb.com/?id." + .entry.id ,.software.vendor // "empty"
,.software.name // "empty", (.software.version []| tostring // "empty")
,.software.type // "empty"
,.software.platform //"empty" ]
代码语言:javascript
复制
    "result": [
        {
            "entry": {
                "id": "206880",
                "title": "CrowdStrike Falcon 6.31.14505.0\/6.42.15610 Uninstallation authorization",
                "summary": "A vulnerability was found in CrowdStrike Falcon 6.31.14505.0\/6.42.15610. It has been classified as problematic. Affected is some unknown functionality of the component Uninstallation Handler. There is no information about possible countermeasures known. It may be suggested to replace the affected object with an alternative product.",
                "details": {
                    "affected": "A vulnerability was found in CrowdStrike Falcon 6.31.14505.0\/6.42.15610. It has been classified as problematic.",
                    "vulnerability": "CWE is classifying the issue as CWE-862. The software does not perform an authorization check when an actor attempts to access a resource or perform an action.",
                    "impact": "This is going to have an impact on availability.",
                    "exploit": "It is declared as functional. The vulnerability was handled as a non-public zero-day exploit for at least 54 days. During that time the estimated underground price was around $0-$5k.",
                    "countermeasure": "There is no information about possible countermeasures known. It may be suggested to replace the affected object with an alternative product.",
                    "sources": "Further details are available at modzero.com."
                },
                "timestamp": {
                    "create": "1661155277",
                    "change": "1661155462"
                },
                "changelog": [
                    "vulnerability_cvss3_meta_basescore",
                    "vulnerability_cvss3_meta_tempscore",
                    "vulnerability_cvss3_researcher_basescore"
                ]
            },
            "software": {
                "vendor": "CrowdStrike",
                "name": "Falcon",
                "version": [
                    "6.31.14505.0",
                    "6.42.15610"
                ],
EN

回答 1

Stack Overflow用户

发布于 2022-08-30 20:31:35

抑制错误并为空值提供一个替代方案:

代码语言:javascript
复制
.result | map(
    "https://vuldb.com/?id.\(.entry.id)",
    (
        .software |
        .vendor // "empty",
        .name // "empty",
        (.version[] | tostring // "empty")? // "no version",
        .type // "empty",
        .platform // "empty"
    )
)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73458432

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档