Coder Social home page Coder Social logo

dart-analyzer-sarif's People

Contributors

aegilops avatar felickz avatar parroty avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

dart-analyzer-sarif's Issues

info level analysis not compatible with Code Scanning level

Consider converting severity info to note?

Sample app secDevLabs

dart analyze output contains both error and info (no warning in my sample - but also a supported level)

 error - lib/views/auth_screen.dart:59:7 - The named parameter 'resizeToAvoidBottomPadding' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'resizeToAvoidBottomPadding'. - undefined_named_parameter
   info - lib/models/session_token.dart:2:10 - Name non-constant identifiers using lowerCamelCase. - non_constant_identifier_names
...

Converted Sarif: cool_games.zip

{
          "level": "info",
          "locations": [
            {
              "physicalLocation": {
                "artifactLocation": {
                  "uri": "lib/models/session_token.dart",
                  "uriBaseId": "SRCROOT"
                },
                "region": {
                  "startLine": 2,
                  "startColumn": 10
                }
              }
            }
          ],
          "message": {
            "text": "Name non-constant identifiers using lowerCamelCase."
          },
          "ruleId": "non_constant_identifier_names"
        },

Code Scanning error:

Error: Unable to upload "owasp-top10-2016-mobile/m2/cool_games/mobile/dart_analyze.sarif" as it is not valid SARIF:
- instance.runs[0].results[1].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[2].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[3].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[4].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[5].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[6].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[7].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[8].level is not one of enum values: none,note,warning,error
Error: Unable to upload "owasp-top10-2016-mobile/m2/cool_games/mobile/dart_analyze.sarif" as it is not valid SARIF:
- instance.runs[0].results[1].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[2].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[3].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[4].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[5].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[6].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[7].level is not one of enum values: none,note,warning,error
- instance.runs[0].results[8].level is not one of enum values: none,note,warning,error
    at validateSarifFileSchema (/home/runner/work/_actions/github/codeql-action/v2/lib/upload-lib.js:201:15)
    at uploadFiles (/home/runner/work/_actions/github/codeql-action/v2/lib/upload-lib.js:251:9)
    at Object.uploadFromActions (/home/runner/work/_actions/github/codeql-action/v2/lib/upload-lib.js:137:18)
    at async run (/home/runner/work/_actions/github/codeql-action/v2/lib/upload-sarif-action.js:48:30)
    at async runWrapper (/home/runner/work/_actions/github/codeql-action/v2/lib/upload-sarif-action.js:70:9)

Feature Request: dart analyze run against a sub directory in a monorepo - add SARIF support for Code Scanning paths

To avoid preview unavailable:
image

when running dart analyze on a sub directory: the path used in the output relative to the directory working directory being scanned... ex: dart analyze path/to/app run with files in directory path/to/app/lib/... will have output:

  error - lib/views/auth_screen.dart:59:7 - The named parameter 'resizeToAvoidBottomPadding' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'resizeToAvoidBottomPadding'. - undefined_named_parameter
   info - lib/models/session_token.dart:2:10 - Name non-constant identifiers using lowerCamelCase. - non_constant_identifier_names

Workaround

    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - uses: dart-lang/setup-dart@v1
      - name: Dart Analyze
        run: dart analyze path/to/app > dart_analyze.txt || true
      - name: Dart Analyze to SARIF
        uses: advanced-security/dart-analyzer-sarif@main
        with:
          input: dart_analyze.txt
          output: dart_analyze.sarif
      # This tools allows users to update broken SARIF files that have relative paths that aren't based on the root GitHub Repository folder.
      - uses: advanced-security/sarif-toolkit/relativepaths@main
        with:
          # SARIF File / Directory location
          sarif: "./dart_analyze.sarif"
          # Working Directory (sub folder of the working directory)
          working: "path/to/app"
      - name: Upload SARIF
        uses: github/codeql-action/upload-sarif@v1
        with:
          sarif_file: dart_analyze.sarif

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.