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

Report issues in JSON format #75

Closed
marcinguy opened this issue Jan 3, 2022 · 2 comments
Closed

Report issues in JSON format #75

marcinguy opened this issue Jan 3, 2022 · 2 comments

Comments

@marcinguy
Copy link

Read the docs.

Could not find how to export findings in JSON format.

Only found and tried this using filters

Tried this:

sapp --tool=mariana-trench analyze .
sapp --tool=mariana-trench filter  import ../../configuration/filters/

Then:


sapp --database-name sapp.db filter issues 1 ../../configuration/filters/ --output-format sarif
2022-01-03 15:36:09,958 [INFO] Applying `Input in exported components flows into injection sink` to run `1` resulted in 1 issues
2022-01-03 15:36:09,974 [INFO] Applying `Input in exported components flows into implicit intent launcher` to run `1` resulted in 1 issues
2022-01-03 15:36:09,988 [INFO] Applying `test` to run `1` resulted in 1 issues
2022-01-03 15:36:09,988 [INFO] Total number of issues after filtering: 2
{
  "version": "2.1.0",
  "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
  "runs": [
    {
      "tool": {
        "driver": {
          "name": "Pysa",
          "informationUri": "https://github.com/facebook/pyre-check/",
          "rules": []
        }
      },
      "results": [
        {
          "ruleId": "1",
          "level": "warning",
          "message": {
            "text": "User input flows into code execution sink (RCE): Values from user-controlled source may eventually flow into code execution sink"
          },
          "locations": [
            {
              "physicalLocation": {
                "artifactLocation": {
                  "uri": "com/example/myapplication/MainActivity.java"
                },
                "region": {
                  "startLine": 25,
                  "startColumn": 1,
                  "endColumn": 2
                }
              }
            }
          ]
        },
        {
          "ruleId": "3",
          "level": "warning",
          "message": {
            "text": "User input flows into implicitly launched intent: Values from user-controlled source may eventually flow into an implicit intent and intent launcher"
          },
          "locations": [
            {
              "physicalLocation": {
                "artifactLocation": {
                  "uri": "com/example/myapplication/MainActivity.java"
                },
                "region": {
                  "startLine": 35,
                  "startColumn": 1,
                  "endColumn": 2
                }
              }
            }
          ]
        }
      ]
    }
  ]
}

However, this does not export all the 6 issues found.

Questions

  1. Why the tool is "Pysa" not "mariana-trench"? Little bit confused here

  2. How do I make a filter to show all the 6 issues (in the app), always show all the issues in the sample-app-debug.apk or other apks?

Thanks,

@0xedward
Copy link
Contributor

Hey @marcinguy, sorry I was just made aware of this open issue. SAPP supports outputting issues in json. You should be able to output the issues in json with the following command:

sapp --database-name sapp.db filter issues 1 ../../configuration/filters/ --output-format sapp

Why the tool is "Pysa" not "mariana-trench"? Little bit confused here

We currently only support outputting issues in SARIF for Pysa
https://github.com/facebook/sapp/blob/3eddd84c59bdd3032484efae6ea1174ffd798482/sapp/sarif.py#L54-L71

The reason you were able to get results in SARIF was because when any sapp commands are run without --tool=mariana-trench, sapp assumes the tool is Pysa. This can be very confusing for our users, so we've been working on storing the tool information in the database, so each sapp command will not require specifying the tool name after the initial sapp analyze run.

How do I make a filter to show all the 6 issues (in the app), always show all the issues in the sample-app-debug.apk or other apks?

You use the following SAPP filter (e.g. allow_all_issues.json) that allows all issues to passthrough:

{
    "name": "allow_all_issues",
    "description": "Filter that allows shows all issues",
    "paths": ["%"]
}

Then use that filter in the sapp filter command:

sapp --database-name sapp.db filter issues 1 allow_all_issues.json --output-format sapp

Let me know if that works for you! :)

@sinancepel
Copy link

Closing due to inactivity after @0xedward's answer - please feel free to re-open if you had another question!

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

3 participants