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

Better support of SARIF format #49

Open
fizruk opened this issue Mar 21, 2022 · 3 comments
Open

Better support of SARIF format #49

fizruk opened this issue Mar 21, 2022 · 3 comments

Comments

@fizruk
Copy link
Member

fizruk commented Mar 21, 2022

Please, see this Simple Example in the SARIF tutorials to understand the kind of information current output is lacking:

  • version of the SARIF format used
  • information about the analyser tool(s)
  • information about generated artifacts
  • level of result (error, warning, etc.)
  • location of the defect in the source code

Also, importantly, in relation to #44, any failures in individual analyzer modules should be reported using Notifications.

@fizruk
Copy link
Member Author

fizruk commented Mar 21, 2022

Here's a specific example (from #48). Since imports are not supported by odin, running polystat on the following EO program

+alias main

[x] > test
  main.foo > @
    x

yields the following output in SARIF format:

{
  "results": [
    {
      "ruleId": "AnFaR",
      "message": "\\perp at {x=NONE}"
    },
    {
      "ruleId": "AnOdin",
      "message": "Odin is not able to analyze the code, due to:\nCould not set locator for non-existent object with name \"main\""
    }
  ]
}

However, expected output should look more like the following:

{
  "version": "2.1.0",
  "runs": [
    {
      "tool": {
        "driver": {
          "name": "Polystat",
          "informationUri": "https://polystat.org",
          "rules": [
            {
              "id": "AnFaR",
              "shortDescription": {
                "text": "division by zero"
              },
              "helpUri": "https://eslint.org/docs/rules/no-unused-vars",
              "properties": {
                "category": "Variables"
              }
            },
            {
              "id": "odin-unanticipated-recursion",
              "shortDescription": {
                "text": "unanticipated recursion in subclasses (decorated objects)"
              },
              "helpUri": "https://github.com/polystat/odin/blob/master/docs/analysis/mutual_recursion_analyzer.md",
              "properties": {
                "category": "Fragile base class"
              }
            },
            {
              "id": "odin-unjustified-assumptions",
              "shortDescription": {
                "text": "unjustified assumptions in subclasses (decorated objects) w.r.t. method dependencies in base class"
              },
              "properties": {
                "category": "Fragile base class"
              }
            }
          ],
          "notifications": [
            {
              "id": "NOTIFY_RULE_EXCEPTION",
              "name": "rule-threw-exception",
              "defaultConfiguration": {
                "level": "error"
              },
              "shortDescription": {
                "text": "This notification is triggered when an analysis rule throws an exception."
              },
              "fullDescription": {
                "text": "This notification is triggered when an analysis rule throws an exception while analyzing a file. Depending on the command line options, the rule might either be disabled, or it might continue to run on subsequent files."
              },
              "messageStrings": {
                "disable": {
                  "text": "'{0}' threw a '{1}' exception while analyzing file '{2}'. The rule has been disabled."
                },
                "continue": {
                  "text": "'{0}' threw a '{1}' exception while analyzing file '{2}'. The rule will continue to be run on subsequent files."
                }
              }
            }
          ]
        }
      },
      "results": [
        {
          "ruleId": "AnFaR",
          "message": {
            "text": "Division by zero possible when x = 2"
          },
          "locations": [
            {
              "physicalLocation": {
                "artifactLocation": {
                  "uri": "test.eo"
                },
                "region": {
                  "startLine": 5
                }
              }
            }
          ]
        }
      ],
      "invocations": [
        {
          "executionSuccessful": true
        },
        {
          "executionSuccessful": false,
          "toolExecutionNotifications": [
            {
              "descriptor": {
                "id": "NOTIFY_RULE_EXCEPTION",
                "index": 1
              },
              "message": {
                "id": "continue",
                "arguments": [
                  "odin-unanticipated-recursion",
                  "UnsupportedFeatureException",
                  "test.eo"
                ]
              },
              "exception": {
                "kind": "org.polystat.odin.interop.java.UnsupportedFeatureException",
                "message": "Unable to set locator for non-existent object with name \"main\""
              }
            }
          ]
        }
      ]
    }
  ]
}

This was referenced Mar 22, 2022
@yegor256
Copy link
Member

@fizruk try version 0.6.0, just released

@yegor256
Copy link
Member

@fizruk let's close this?

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

No branches or pull requests

2 participants