Giter Site home page Giter Site logo

konveyor / analyzer-lsp Goto Github PK

View Code? Open in Web Editor NEW
7.0 11.0 38.0 9.66 MB

Add-on that is focused on providing analysis based on the Language Server Protocol.

License: Apache License 2.0

Go 95.75% Dockerfile 1.60% Makefile 0.78% C# 0.04% Java 1.83% Procfile 0.01%

analyzer-lsp's Introduction

Analyzer Rule Engine

In this project, we are writing a rule engine that can use pluggable providers for rules to make a consistent way to execute rules for Konveyor.

One of the primary drivers for this repository is adding providers for specific languages using the Language Server Protocol. Today these providers are in tree, but we will be moving them out in the future.

Quick Demo

If you would like to run a quick demo we have a Dockerfile that has all the dependencies.

To run this demo build the containers:

podman build -f Dockerfile -t quay.io/konveyor/analyzer-lsp
podman build -f demo.Dockerfile -t test-analyzer-engine

This will build the engine, and include the current set of rules and examples in the container to be used.

To run the rules (rule-example.yaml) against the examples, and save the output to the demo-output.yaml file:

podman run -v $(pwd)/demo-output.yaml:/analyzer-lsp/output.yaml:Z test-analyzer-engine

Running from source code

To run the engine from source code, you need to:

  • Configure providers. By default, providers are configured in provider_settings.json. See Providers for instructions on configuring providers.
  • Configure rules. By default, rules are present in rules_example.yaml. See Rules for details on rule format.

Once the providers are configured, you can run:

go run cmd/analyzer/main.go

CLI Options:

Flags:
      --analysis-mode string        select one of full or source-only to tell the providers what to analyize. This can be given on a per provider setting, but this flag will override
      --context-lines int           When violation occurs, A part of source code is added to the output, So this flag configures the number of source code lines to be printed to the output. (default 10)
      --dep-label-selector string   an expression to select dependencies based on labels. This will filter out the violations from these dependencies as well these dependencies when matching dependency conditions
      --enable-jaeger               enable tracer exports to jaeger endpoint (default true)
      --error-on-violation          exit with 3 if any violation are found will also print violations to console
  -h, --help                        help for analyze
      --jaeger-endpoint string      jaeger endpoint to collect tracing data (default "http://localhost:14268/api/traces")
      --label-selector string       an expression to select rules based on labels
      --limit-code-snips int        limit the number code snippets that are retrieved for a file while evaluating a rule, 0 means no limit (default 20)
      --limit-incidents int         Set this to the limit incidents that a given rule can give, zero means no limit (default 1500)
      --no-dependency-rules         Disable dependency analysis rules
      --output-file string          filepath to to store rule violations (default "output.yaml")
      --provider-settings string    path to the provider settings (default "provider_settings.json")
      --rules stringArray           filename or directory containing rule files (default [rule-example.yaml])
      --verbose int                 level for logging output (default 9)

Code Base Starting Point

Using the LSP/Protocal from Golang https://github.com/golang/tools/tree/master/gopls/internal/lsp/protocol and stripping out anything related to serving, proxy or anything. Just keeping the types for communication

Using JSONRPC2 from google.org/x/tools/internal. Copied and removed anything to do with serving.

Code of Conduct

Refer to Konveyor's Code of Conduct page

analyzer-lsp's People

Contributors

adiakhileshsingh15 avatar ascheman avatar aufi avatar chanakya-ts avatar djzager avatar dymurray avatar eemcmullan avatar fabianvf avatar jmle avatar jmontleon avatar jonahsussman avatar jwmatthews avatar krishnaduttpanchagnula avatar mdsahil-oss avatar neerajnagure avatar parthiba-hazra avatar pranavgaikwad avatar ripulhandoo avatar sarthaksarthak9 avatar savitharaghunathan avatar shawn-hurley avatar utkarshumre avatar vickysomtee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

analyzer-lsp's Issues

Rules v1beta1

Publish first version of rule format with documentation.

Add comments to non-intuitive rules

Until we decide on the final schema for the rules and generate docs, would it be possible to add a comment about the rule if its not so intuitive. Thanks in advance :)

Prototype integrating into Konveyor

This is to track work on the first iteration of integration work for Analyzers <-> Konveyor. Mainly things I am looking at is passing stuff coming from the Hub as an input to analyzers and pushing back results as a JSON back into the Hub.

Return schemas for Extras for a Violation and Incident

We have ability to return schemas for template context info created by providers. We need something similar for Violations that captures extra information put in there so that end users can parse the extras correctly

Update README

We need to get README to a point where a user / contributor can run an analyzer independently by following instructions.

Inter-rule pipelining

We addressed inter-condition pipelining in Demo A. This issue captures the need for pipelining within rules.

POC Windup rules

Let's start thinking about how we want to get windup rules in analyzers

Decide on templating language and/or implementation

Today we do not have a defined approach to how to pass templated context values into condition information fields.

Right now, this is the responsibility of the provider, but when moving to external providers, I believe that this needs to become the responsibility of the engine.

I think that for now, we can test out the functionality we do have and this will have to be part of the external provider work.

CLI Options

Add support for following CLI options:

Option Description Tracking Issue
--rules Input one or more Rulesets / Rules Completed #128
--output-file Output file location Completed
--label-selector Label selector logic to include/exclude #130
--no-dep Skip dependency analysis #135
--exlude-deps Don't analyze dependencies #136
--limit-incidents Limt the number of incidents per rule #153
--limit-cond-snip Limt the number of incidents per rule that have code snippet found #154

Support yaml rules

Currently rules can only be written in json but yaml is a superset of json that is more fun to write and read so we should support that too

Consider adding a category field for violations

There is value in classifying violations based on factors such as severity, urgency etc. In windup, there is a separate field category to define those characteristics about a violation. We should consider having something similar in analyzers.

Reporting errors on partial matches

We need to report errors occurred when creation of violations when a rule partially matches or otherwise. Windup has an Optional category for violations that address this.

Track source as fileuri when reporting dependencies

Currently we don't point to where the dependencies are coming from, which could be a useful piece of information. We should track and report that. We should also change the Location field in the dependency.Dep to match Location in the rest of the code base (ie it should point somewhere in the codebase) and find a different term to report what it currently gathers for java (or add it to an extras field for arbitrary metadata)

Adding Tracing in engine and providers

One of the concerns could be the performance of a given provider. We will want the ability to quickly diagnose if the time taken is in the engine or a given provider.

We will also want to see the traces from our providers to see if anything is taking longer than it should.

Consolidating Categories

Current State

Today there are 4 Categories in the windup project.

  1. Potential
  2. Mandatory
  3. Information
  4. optional

The potential is supposed to mean that the Rule ran successfully, and there may or may not be an issue. We can't tell.

Mandatory is that the Rule ran correctly and the Rule states this must be fixed

Information is that the Rule ran correctly, and the Rule states that this is just for information, which could mean there is a problem in the future but not something you must fix.

Optional is that a rule ran unsuccessfully, and it might have a violation and may not.

Proposed State

Consolidating these and making it easier for both end users to understand what the category is supposed to mean and what a rule writer should set is the goal of this issue.

For the Rule's categories, I am proposing two mutually exclusive buckets.

  1. Mandatory will be when the Rule states that this must be fixed based on the ruleset. This will only be set for rules that have run successfully
  2. Potential will be when the Rule states this is potentially an issue. This will only be set for rules that have run successfully

We need to create a new bucket for partial matches/errors. I would prefer to call this something like Errors, which will be different than the violations that use the categories above. In this world, we would have two new error categories:

  1. Partial Match -> This Rule ran semi-successfully, and some conditions matched, but there were failures in others. This should include the error message and other stuff
  2. Failure -> this Rule did not run successfully in any way.

We also need a third bucket of rules for rules that ran successfully but did not have any violations. I believe this should just be something like PassedRules or something.

We should discuss the names here so that once we implement it, we can point back to this.

Adding in folks that this will probably have an impact on:
@rromannissen @jortel @ibolton336 @pranavgaikwad @fabianvf

Windup integration

LSP analyzers must support windup rules. The goal is to support 80% of existing windup rules. In the first phase, windup rules can be converted to analyzers manually. In the next phase, a windup shim will facilitate running windup rules with analyzers.

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.