Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native SARIF output support #18

Closed
yongyan-gh opened this issue Feb 24, 2022 · 20 comments · Fixed by #19
Closed

Native SARIF output support #18

yongyan-gh opened this issue Feb 24, 2022 · 20 comments · Fixed by #19

Comments

@yongyan-gh
Copy link

Hi,

We are working with the Github team on the SARIF ecosystem, looking for adding native SARIF output functionality of the clj-watson tool, so that customers can easily create a workflow to scan vulnerabilities in their repo using clj-watson, generate code scanning alerts in Github security tab for each vulnerability found.

To achieve this goal below 3 steps needed:

  1. Native SARIF output support in clj-watson tool.
  2. Add steps in clj-watson-action to upload the SARIF file to Github.
  3. Create clj-watson Github starter workflow.

We are glad to help/contribute to these tasks. I see the SARIF report functionality in clj-holmes, according to the rule's definition and sample output I can find the fields map to SARIF report. But I don't find a document about clj-watson's output and from the sample output I don't figure out which properties should be used for SARIF report. Can you please provide the information about the tool's output?

Below are the required properties of a SARIF report according to a Github article at https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning. Can you please take a look and let me know what properties/values in clj-watson report can map to them?

SARIF properties clj-watson properties description
rule.Id An unique identifier for the rule. The id is referenced from other parts of the SARIF file and may be used by code scanning to display URLs on GitHub.
rule.shortDescription.text A concise description of the rule. Code scanning displays the short description on GitHub next to the associated results.
rule.fullDescription.text A description of the rule. Code scanning displays the full description on GitHub next to the associated results.
rule.help.text Documentation for the rule using text format. Code scanning displays this help documentation next to the associated results.
result.ruleId The unique identifier of the rule (rule.Id)
result.level The severity of the result. This level overrides the default severity defined by the rule. Code scanning uses the level to filter results by severity on GitHub.
result.message.text A message that describes the result. Code scanning displays the message text as the title of the result.
result.location.physicalLocation.artifactLocation.uri A URI indicating the location of an artifact, usually a file either in the repository or generated during a build.
result.location.physicalLocation.region.startLine The line number of the first character in the region.
result.location.physicalLocation.region.startColumn The column number of the first character in the region.
result.location.physicalLocation.region.endLine The line number of the last character in the region.
result.location.physicalLocation.region.endColumn The column number of the character following the end of the region.

Thanks!

cc @eddynaka @michaelcfanning

@mthbernardes
Copy link
Contributor

Hi @yongyan-gh
Not sure if sarif is a good call to clj-watson since it's kind of a dependabot focused on clojure.
It was the main reason for me not to implement the sarif output.

@eddynaka
Copy link

eddynaka commented Mar 3, 2022

Hi @mthbernardes ,

The idea is to use clj-watson in PRs with the SARIF integration and send the data to GHAS. This will create security alert notifications during PR, which would facilitate a lot and prevent anyone from check-in vulnerable packages.

@mthbernardes
Copy link
Contributor

Hm I thought that since the sarif upload was only available for the code scanning functionality it would only make sense to send code analyses and not vulnerable dependencies.
But if u guy think that it's a good idea I'll start implementing it.

@mthbernardes
Copy link
Contributor

This is an example of clj-watson output.

[
  {
    "dependency": "com.fasterxml.jackson.core/jackson-databind",
    "dependents": [
      "com.auth0/java-jwt"
    ],
    "paths": [
      "/Users/username/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.9.8/jackson-databind-2.9.8.jar"
    ],
    "secure-version": {
      "mvn/version": "2.13.1"
    },
    "deps/manifest": "mvn",
    "mvn/version": "2.9.8",
    "parents": [
      [
        "com.auth0/java-jwt"
      ]
    ],
    "remediate-suggestion": {
      "com.auth0/java-jwt": {
        "exclusions": [
          "com.fasterxml.jackson.core/jackson-databind"
        ]
      },
      "com.fasterxml.jackson.core/jackson-databind": {
        "mvn/version": "2.13.1"
      }
    },
    "vulnerabilities": [
      {
        "vulnerableVersionRange": ">= 2.0.0, < 2.9.9",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 7.5
          },
          "identifiers": [
            {
              "value": "GHSA-5ww9-j83m-q7qx"
            },
            {
              "value": "CVE-2019-12086"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.9"
        }
      },
      {
        "vulnerableVersionRange": "< 2.9.10",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 9.8
          },
          "identifiers": [
            {
              "value": "GHSA-85cw-hj65-qqv9"
            },
            {
              "value": "CVE-2019-16335"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10"
        }
      },
      {
        "vulnerableVersionRange": "< 2.9.10",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 9.8
          },
          "identifiers": [
            {
              "value": "GHSA-h822-r4r5-v8jg"
            },
            {
              "value": "CVE-2019-14540"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.1",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 9.8
          },
          "identifiers": [
            {
              "value": "GHSA-gww7-p5w4-wrfv"
            },
            {
              "value": "CVE-2019-20330"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.2"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.2",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 9.8
          },
          "identifiers": [
            {
              "value": "GHSA-4w82-r329-3q67"
            },
            {
              "value": "CVE-2020-8840"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.3"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0.0, <= 2.9.10.3",
        "advisory": {
          "severity": "MODERATE",
          "cvss": {
            "score": 0
          },
          "identifiers": [
            {
              "value": "GHSA-fqwf-pjwf-7vqv"
            },
            {
              "value": "CVE-2020-10673"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.4"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, < 2.9.10",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 0
          },
          "identifiers": [
            {
              "value": "GHSA-qmqc-x3r4-6v39"
            },
            {
              "value": "CVE-2019-14893"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0.0, <= 2.9.10.3",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 9.8
          },
          "identifiers": [
            {
              "value": "GHSA-q93h-jc49-78gg"
            },
            {
              "value": "CVE-2020-9547"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.4"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.3",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.8
          },
          "identifiers": [
            {
              "value": "GHSA-95cm-88f5-f2c7"
            },
            {
              "value": "CVE-2020-10672"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.4"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.3",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-h4rc-386g-6m85"
            },
            {
              "value": "CVE-2020-11620"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.4"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0.0, <= 2.9.10.3",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 9.8
          },
          "identifiers": [
            {
              "value": "GHSA-p43x-xfjf-5jhr"
            },
            {
              "value": "CVE-2020-9548"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.4"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.3",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 9.8
          },
          "identifiers": [
            {
              "value": "GHSA-5p34-5m6p-p58g"
            },
            {
              "value": "CVE-2020-9546"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.4"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.3",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.8
          },
          "identifiers": [
            {
              "value": "GHSA-758m-v56v-grj4"
            },
            {
              "value": "CVE-2020-10969"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.4"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, < 2.9.10",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 7.5
          },
          "identifiers": [
            {
              "value": "GHSA-cf6r-3wgc-h863"
            },
            {
              "value": "CVE-2019-14892"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.3",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.8
          },
          "identifiers": [
            {
              "value": "GHSA-rf6r-2c4q-2vwg"
            },
            {
              "value": "CVE-2020-10968"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.4"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.3",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.8
          },
          "identifiers": [
            {
              "value": "GHSA-v3xw-c963-f5hc"
            },
            {
              "value": "CVE-2020-11111"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.4"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.3",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.8
          },
          "identifiers": [
            {
              "value": "GHSA-9vvp-fxw6-jcxr"
            },
            {
              "value": "CVE-2020-11113"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.4"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.3",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-27xj-rqx5-2255"
            },
            {
              "value": "CVE-2020-11619"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.4"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.3",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.8
          },
          "identifiers": [
            {
              "value": "GHSA-58pp-9c76-5625"
            },
            {
              "value": "CVE-2020-11112"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.4"
        }
      },
      {
        "vulnerableVersionRange": "< 2.9.10",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 9.8
          },
          "identifiers": [
            {
              "value": "GHSA-f3j5-rmmp-3fc5"
            },
            {
              "value": "CVE-2019-17267"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.4",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-mc6h-4qgp-37qh"
            },
            {
              "value": "CVE-2020-14195"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.5"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.4",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-j823-4qch-3rgm"
            },
            {
              "value": "CVE-2020-14060"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.5"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.4",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-c265-37vj-cwcc"
            },
            {
              "value": "CVE-2020-14062"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.5"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.9.0, <= 2.9.10.4",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-c2q3-4qrh-fm48"
            },
            {
              "value": "CVE-2020-14061"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.5"
        }
      },
      {
        "vulnerableVersionRange": "<= 2.9.10.6",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 0
          },
          "identifiers": [
            {
              "value": "GHSA-5949-rw7g-wx7w"
            },
            {
              "value": "CVE-2021-20190"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.7"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.7.0.0, <= 2.9.10.6",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 7.5
          },
          "identifiers": [
            {
              "value": "GHSA-288c-cq4h-88gq"
            },
            {
              "value": "CVE-2020-25649"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.7"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0, <= 2.9.10.7",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-vfqx-33qm-g869"
            },
            {
              "value": "CVE-2020-36189"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.8"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0, <= 2.9.10.7",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-r695-7vr9-jgc2"
            },
            {
              "value": "CVE-2020-36187"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.8"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0, <= 2.9.10.7",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-f9xh-2qgp-cq57"
            },
            {
              "value": "CVE-2020-36188"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.8"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0, <= 2.9.10.7",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-9m6f-7xcq-8vf8"
            },
            {
              "value": "CVE-2020-36183"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.8"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0, <= 2.9.10.7",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-m6x4-97wx-4q27"
            },
            {
              "value": "CVE-2020-36184"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.8"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0, <= 2.9.10.7",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-8c4j-34r4-xr8g"
            },
            {
              "value": "CVE-2020-36180"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.8"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0, <= 2.9.10.7",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-cvm9-fjm9-3572"
            },
            {
              "value": "CVE-2020-36181"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.8"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0, <= 2.9.10.7",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-8w26-6f25-cm9x"
            },
            {
              "value": "CVE-2020-36185"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.8"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0, <= 2.9.10.7",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-9gph-22xh-8x98"
            },
            {
              "value": "CVE-2020-36179"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.8"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0, <= 2.9.10.7",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-89qr-369f-5m5x"
            },
            {
              "value": "CVE-2020-36182"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.8"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0, <= 2.9.10.5",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-qjw2-hr98-qgfh"
            },
            {
              "value": "CVE-2020-24750"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.6"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0.0, <= 2.9.10.7",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-r3gr-cxrf-hg25"
            },
            {
              "value": "CVE-2020-35491"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.8"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0.0, <= 2.9.10.7",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-wh8g-3j2c-rqj5"
            },
            {
              "value": "CVE-2020-35490"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.8"
        }
      },
      {
        "vulnerableVersionRange": "<= 2.9.9.1",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 7.5
          },
          "identifiers": [
            {
              "value": "GHSA-gwp4-hfv6-p7hw"
            },
            {
              "value": "CVE-2019-14439"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.9.2"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0.0, <= 2.9.9",
        "advisory": {
          "severity": "MODERATE",
          "cvss": {
            "score": 5.9
          },
          "identifiers": [
            {
              "value": "GHSA-cmfg-87vq-g5g4"
            },
            {
              "value": "CVE-2019-12814"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.9.1"
        }
      },
      {
        "vulnerableVersionRange": "<= 2.9.9",
        "advisory": {
          "severity": "MODERATE",
          "cvss": {
            "score": 5.9
          },
          "identifiers": [
            {
              "value": "GHSA-mph4-vhrx-mv67"
            },
            {
              "value": "CVE-2019-12384"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.9.1"
        }
      },
      {
        "vulnerableVersionRange": "<= 2.9.10.0",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 9.8
          },
          "identifiers": [
            {
              "value": "GHSA-gjmw-vf9h-g25v"
            },
            {
              "value": "CVE-2019-17531"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.1"
        }
      },
      {
        "vulnerableVersionRange": "<= 2.9.10.0",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 9.8
          },
          "identifiers": [
            {
              "value": "GHSA-fmmc-742q-jg75"
            },
            {
              "value": "CVE-2019-16943"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.1"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0.0, <= 2.9.10",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 9.8
          },
          "identifiers": [
            {
              "value": "GHSA-mx7p-6679-8g3q"
            },
            {
              "value": "CVE-2019-16942"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.1"
        }
      },
      {
        "vulnerableVersionRange": "<= 2.9.9.1",
        "advisory": {
          "severity": "CRITICAL",
          "cvss": {
            "score": 9.8
          },
          "identifiers": [
            {
              "value": "GHSA-6fpp-rgj9-8rwc"
            },
            {
              "value": "CVE-2019-14379"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.9.2"
        }
      },
      {
        "vulnerableVersionRange": ">= 2.0.0, <= 2.9.10.5",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 8.1
          },
          "identifiers": [
            {
              "value": "GHSA-h3cw-g4mq-c5x2"
            },
            {
              "value": "CVE-2020-24616"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.9.10.6"
        }
      }
    ]
  },
  {
    "mvn/version": "42.2.10",
    "deps/manifest": "mvn",
    "parents": [
      []
    ],
    "paths": [
      "/Users/username/.m2/repository/org/postgresql/postgresql/42.2.10/postgresql-42.2.10.jar"
    ],
    "dependency": "org.postgresql/postgresql",
    "vulnerabilities": [
      {
        "vulnerableVersionRange": ">= 9.4.1208, < 42.2.25",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 7
          },
          "identifiers": [
            {
              "value": "GHSA-v7wg-cpwc-24m4"
            },
            {
              "value": "CVE-2022-21724"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "42.2.25"
        }
      },
      {
        "vulnerableVersionRange": "< 42.2.13",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 7.7
          },
          "identifiers": [
            {
              "value": "GHSA-88cc-g835-76rp"
            },
            {
              "value": "CVE-2020-13692"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "42.2.13"
        }
      },
      {
        "vulnerableVersionRange": ">= 42.1.0, < 42.3.3",
        "advisory": {
          "severity": "MODERATE",
          "cvss": {
            "score": 0
          },
          "identifiers": [
            {
              "value": "GHSA-673j-qm5f-xpv8"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "42.3.3"
        }
      }
    ],
    "secure-version": {
      "mvn/version": "42.3.3"
    },
    "remediate-suggestion": {
      "org.postgresql/postgresql": {
        "mvn/version": "42.3.3"
      }
    }
  },
  {
    "dependency": "com.taoensso/nippy",
    "dependents": [
      "com.taoensso/carmine"
    ],
    "paths": [
      "/Users/username/.m2/repository/com/taoensso/nippy/2.14.0/nippy-2.14.0.jar"
    ],
    "secure-version": {
      "mvn/version": "3.1.1"
    },
    "deps/manifest": "mvn",
    "mvn/version": "2.14.0",
    "parents": [
      [
        "io.replikativ/datahike",
        "io.replikativ/hitchhiker-tree",
        "com.taoensso/carmine"
      ]
    ],
    "remediate-suggestion": {
      "io.replikativ/datahike": {
        "exclusions": [
          "com.taoensso/carmine"
        ]
      },
      "com.taoensso/carmine": {
        "mvn/version": "3.2.0-SNAPSHOT"
      }
    },
    "vulnerabilities": [
      {
        "vulnerableVersionRange": "< 2.14.2",
        "advisory": {
          "severity": "HIGH",
          "cvss": {
            "score": 7.8
          },
          "identifiers": [
            {
              "value": "GHSA-p5gm-fgfx-hr7h"
            },
            {
              "value": "CVE-2020-24164"
            }
          ]
        },
        "firstPatchedVersion": {
          "identifier": "2.14.2"
        }
      }
    ]
  }
]

It does not contains a few data necessary to sarif output, like line information and the rule is basically a public cve/github advisory.

@eddynaka
Copy link

eddynaka commented Mar 3, 2022

Hm I thought that since the sarif upload was only available for the code scanning functionality it would only make sense to send code analyses and not vulnerable dependencies. But if u guy think that it's a good idea I'll start implementing it.

This is like https://github.com/aquasecurity/trivy, which analyzes container package dependencies checking for vulnerabilities.

My thoughts were:

  1. you as a developer change some packages in a PR, where one of those is vulnerable
  2. GH Action runs and outputs a SARIF
  3. GH fails the checks since u have a vulnerable package

let us know if you want us to do that work or if u are going to do it. :)

@mthbernardes
Copy link
Contributor

@eddynaka already working to add sarif output support to clj-watson .

@mthbernardes mthbernardes linked a pull request Mar 4, 2022 that will close this issue
@mthbernardes
Copy link
Contributor

I've just implemented it on PR #19 and made a alpha release https://github.com/clj-holmes/clj-watson/releases/tag/v3.0.2-ALPHA
Now you're able to test it and check if I did everything right :)

@mthbernardes
Copy link
Contributor

I generated a report and tested it in this site and the results were detected.
Screen Shot 2022-03-03 at 23 20 39
But I created a public repository with a action to run clj-watson to test the sarif upload and everything seems to work but no alert appeared on code scanning interface.
Screen Shot 2022-03-03 at 23 22 12

@mthbernardes
Copy link
Contributor

output example:

{
  "$schema": "https://www.schemastore.org/schemas/json/sarif-2.1.0-rtm.5.json",
  "version": "2.1.0",
  "runs": [
    {
      "tool": {
        "driver": {
          "name": "clj-watson",
          "informationUri": "https://github.com/clj-holmes/clj-watson",
          "version": "3.0.1",
          "rules": [
            {
              "id": "GHSA-p5gm-fgfx-hr7h",
              "name": "VulnerableDependencyNippy",
              "shortDescription": {
                "text": "Gadget chain attack in Nippy"
              },
              "fullDescription": {
                "text": "A deserialization flaw is present in Taoensso Nippy before 2.14.2. In some circumstances, it is possible for an attacker to create a malicious payload that, when deserialized, will allow arbitrary code to be executed. This occurs because there is automatic use of the Java Serializable interface."
              },
              "help": {
                "text": "Vulnerability found in package com.taoensso/nippy"
              },
              "helpUri": "https://github.com/advisories/GHSA-p5gm-fgfx-hr7h",
              "properties": {
                "security-severity": 7.8
              },
              "defaultConfiguration": {
                "level": "error"
              }
            }
          ]
        }
      },
      "results": [
        {
          "ruleId": "GHSA-p5gm-fgfx-hr7h",
          "message": {
            "text": "Vulnerability found in package com.taoensso/nippy"
          },
          "locations": [
            {
              "physicalLocation": {
                "artifactLocation": {
                  "uri": "deps.edn"
                },
                "region": {
                  "startLine": 5,
                  "endLine": 5,
                  "startColumn": 12,
                  "endColumn": 34
                }
              }
            }
          ]
        }
      ]
    }
  ]
}

@eddynaka
Copy link

eddynaka commented Mar 4, 2022

@yongyan-gh , can you test as well?

@eddynaka
Copy link

eddynaka commented Mar 4, 2022

@mthbernardes , can you add one configuration in ur sarif-upload:
wait-for-processing: true

let's see if we get a result.
Otherwise, I can ask someone from GH to help us.

@yongyan-gh
Copy link
Author

@mthbernardes the output looks pretty good, verified using validator, and looks fine in SARIF web viewer and VS viewer.
Only issue is when open the generated SARIF file in VS Code. it complains about the schema.
image

I replaced the schema in the file (https://www.schemastore.org/schemas/json/sarif-2.1.0-rtm.5.json) with another Uri (https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json) it works for VS code.
I think its an problem with VS code, the SARIF file is valid. When you open new Uri actually redirects to the old Uri.

I tried the create similar workflow @mthbernardes created in another test repo, I see the same issue:
No alert created in Security -> Code scanning alert, even the workflow generated SARIF contains error results and uploaded to GitHub successfully.
Also tried the SARIF file with updated schema Uri, got same issue.

According to GitHub's document https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning , all the required fields are provided in SARIF file.

@eddynaka I haven't seen this kind of issue before, may need GH team to take a look.

Attached the sample SAIRF generated using clj-watson. Artifact

@yongyan-gh
Copy link
Author

yongyan-gh commented Mar 4, 2022

btw I investigate further and found an error while uploading clj-watson's SARIF results (github/codeql-action/upload-sarif@v1):

Waiting for processing to finish
  Analysis upload status is failed.
  Error: Code Scanning could not process the submitted SARIF file:
  parsing restricted subset of SARIF data has failed: parse error: expected string near offset 768 of '7.8'
  Error: Code Scanning could not process the submitted SARIF file:
  parsing restricted subset of SARIF data has failed: parse error: expected string near offset 768 of '7.8'
      at Object.waitForProcessing (/home/runner/work/_actions/github/codeql-action/v1/lib/upload-lib.js:3[23](https://github.com/yongyan-gh/clojurescript/runs/5418124043?check_suite_focus=true#step:8:23):23)
      at async run (/home/runner/work/_actions/github/codeql-action/v1/lib/upload-sarif-action.js:53:13)
      at async runWrapper (/home/runner/work/_actions/github/codeql-action/v1/lib/upload-sarif-action.js:68:9)

The issue seems caused by SARIF file has a property bag "security-severity" value is 7.8

                    "rules": [
                        {
                            "id": "GHSA-p5gm-fgfx-hr7h",
                            "name": "VulnerableDependencyNippy",
                            "shortDescription": {
                                "text": "Gadget chain attack in Nippy"
                            },
                            "fullDescription": {
                                "text": "A deserialization flaw is present in Taoensso Nippy before 2.14.2. In some circumstances, it is possible for an attacker to create a malicious payload that, when deserialized, will allow arbitrary code to be executed. This occurs because there is automatic use of the Java Serializable interface."
                            },
                            "help": {
                                "text": "Vulnerability found in package com.taoensso/nippy"
                            },
                            "helpUri": "https://github.com/advisories/GHSA-p5gm-fgfx-hr7h",
                            "properties": {
                                "security-severity": 7.8
                            },
                            "defaultConfiguration": {
                                "level": "error"
                            }
                        }
                    ]

The value of property bags can be a float/double number according to SARIF spec. Seems GitHub cannot parse it somehow.
In GitHub's document the sample property bags has "security-severity" value as string:

            {
              "id": "R01"
                      ...
              "properties" : {
               "id" : "java/unsafe-deserialization",
               "kind" : "path-problem",
               "name" : "...",
               "problem.severity" : "error",
               "security-severity" : "9.8",
            }

@mthbernardes if you can remove this property or convert it to string in your branch, we can try again to see if it works.

@yongyan-gh
Copy link
Author

@mthbernardes I found other issues in clj-watson's SARIF report when I use parameter --database-strategy dependency-check. The rule's short description text is set to null and region of some results is set to null.

Please see the sample SARIF file: clj-watson2.zip

To summary all above issues below, please take a look.

@mthbernardes
Copy link
Contributor

Thx for all the help @yongyan-gh @eddynaka it's now working.
Screen Shot 2022-03-04 at 12 00 23

@eddynaka
Copy link

eddynaka commented Mar 4, 2022

@yongyan-gh , if you have time, pls suggest the fixes.
@mthbernardes , thanks! We will contact GH to fix the properties problem.

@yongyan-gh
Copy link
Author

@mthbernardes

The rule help text markdown looks very nice in code scanning alert page! 👍

I still see issues with parameter --database-strategy dependency-check.
The rule id is set to null and one of result's region is null.
Here is the link to workflow run.
Can you pls take a look?

[build](https://github.com/yongyan-gh/clojurescript/runs/5429770377?check_suite_focus=true)
Unable to upload "results.sarif" as it is not valid SARIF:
- instance.runs[0].tool.driver.rules[0].id is not of a type(s) string
- instance.runs[0].tool.driver.rules[1].id is not of a type(s) string
- instance.runs[0].tool.driver.rules[2].id is not of a type(s) string
- instance.runs[0].tool.driver.rules[3].id is not of a type(s) string
- instance.runs[0].results[0].ruleId is not of a type(s) string
- instance.runs[0].results[1].ruleId is not of a type(s) string
- instance.runs[0].results[2].ruleId is not of a type(s) string
- instance.runs[0].results[3].ruleId is not of a type(s) string
- instance.runs[0].results[3].locations[0].physicalLocation.region is not of a type(s) object

@yongyan-gh
Copy link
Author

@mthbernardes do you plan to merge the changes from your branch to the main branch and create an official release?

Or you'd like to the action/starter workflow to reference to the alpha version?

actions/starter-workflows#1460

      - name: Dependency scan
        uses: clj-holmes/clj-watson-action@992d0e6270ab50ac6f7d8709f323a77cfa816b66
        with:
          clj-watson-sha: "992d0e6"
          clj-watson-tag: "v3.0.2-ALPHA"
          database-strategy: github-advisory
          aliases: clojure-lsp,test 
          deps-edn-path: deps.edn
          suggest-fix: true
          output-type: sarif
          output-file: clj-watson-results.sarif
        fail-on-result: 'true'

@mthbernardes
Copy link
Contributor

I'll merge the PR without the sarif support to dependency-check scan and create a new issue for it.

@yongyan-gh
Copy link
Author

Thank you @mthbernardes, can you pls also publish a new release of clj-watson-action with the new output-file argument change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants